openapi: 3.0.3
info:
  title: Plain Event Calendar API
  description: A set of endpoints to manage Plain Event Calendar database
  version: 2.0.5
tags:
  - name: event
    description: Everything about your events
servers:
  - url: /wp-json/plain-event-calendar/v2
paths:
  /event:
    get:
      tags:
        - event
      description: Returns all events.
      parameters:
        - name: limit
          in: query
          description: How many to return
          required: false
          schema:
            type: integer
            format: int64
            default: 10
        - name: offset
          in: query
          description: Listing offset
          required: false
          schema:
            type: integer
            format: int64
            default: 0
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Event'
        '400':
          description: Invalid status value
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
      # security:
        # - petstore_auth:
            # - write:pets
            # - read:pets
    post:
      tags:
        - event
      description: Adds a new event to the database.
      parameters:
        - name: X-WP-PlainEventCalendar-Token
          in: header
          description: Authentication token
          required: true
          schema:
            type: integer
            format: int64
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Event'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Event'
        required: true
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        '400':
          description: Invalid input
        '401':
          description: Invalid authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Invalid authorization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Validation exception
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventError'
        default:
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
      # security:
        # - petstore_auth:
            # - write:pets
            # - read:pets
  /event/{id}:
    get:
      tags:
        - event
      description: Returns a single event.
      parameters:
        - name: id
          in: path
          description: ID of event to return
          required: true
          schema:
            type: integer
            format: int64
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        '404':
          description: Event not found
      # security:
        # - api_key: []
        # - petstore_auth:
            # - write:pets
            # - read:pets
    put:
      tags:
        - event
      description: Updates a single event.
      parameters:
        - name: id
          in: path
          description: ID of the event
          required: true
          schema:
            type: integer
            format: int64
        - name: X-WP-PlainEventCalendar-Token
          in: header
          description: Authentication token
          required: true
          schema:
            type: integer
            format: int64
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Event'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/Event'
        required: true
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        '404':
          description: Event not found
        '400':
          description: Invalid input
        '401':
          description: Invalid authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Invalid authorization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Validation exception
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventError'
      # security:
        # - api_key: []
        # - petstore_auth:
            # - write:pets
            # - read:pets
components:
  schemas:
    Event:
      required:
        - title
        - startDate
        - endDate
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 10
        title:
          type: string
          example: Amazing meeting
        description:
          type: string
          example: It is going to be an amazing event!
        startDate:
          type: date
          example: 2025-11-14
        endDate:
          type: date
          example: 2025-11-20
    EventError:
      type: object
      properties:
        startDate:
          type: string
          example: Required field
        endDate:
          type: string
          example: The end date should be after the start date
    Error:
      type: object
      properties:
        error:
          type: string
          example: An error message
      required:
        - error