openapi: 3.0.0
info:
  title: Gamenight
  version: '1.0'
  contact:
    name: Dennis Brentjes
    email: dennis@brentj.es
    url: 'https://brentj.es'
  description: Api specifaction for a Gamenight server
  license:
    name: MIT
servers:
  - url: 'http://localhost:8080'
    description: Gamenight
paths:
  /token:
    get:
      summary: ''
      operationId: get-token
      responses:
        '200':
          $ref: '#/components/responses/TokenResponse'
        '401':
          $ref: '#/components/responses/FailureResponse'
      requestBody:
        $ref: '#/components/requestBodies/LoginRequest'
      description: Submit your credentials to get a JWT-token to use with the rest of the api.
      parameters: []
  /user:
    post:
      summary: ''
      operationId: post-register
      requestBody:
        $ref: '#/components/requestBodies/RegisterRequest'
      responses:
        '200':
          description: ''
        '422':
          $ref: '#/components/responses/FailureResponse'
      description: 'Create a new user given a registration token and user information, username and email must be unique, and password and password_repeat must match.'
    parameters: []
    get:
      description: 'Get a user from primary id'
      parameters: []
      responses:
        '200':
          $ref: '#/components/responses/UserResponse'
  /gamenights:
    get:
      summary: Your GET endpoint
      responses:
        '200':
          $ref: '#/components/responses/GamenightsResponse'
        '400':
          $ref: '#/components/responses/FailureResponse'
        '401':
          $ref: '#/components/responses/FailureResponse'
      operationId: get-gamenights
      security:
        - JWT-Auth: []
      description: Retrieve the list of gamenights on this gamenight server. Requires authorization.
  /gamenight:
    post:
      summary: ''
      operationId: post-gamenight
      responses:
        '200':
          description: OK
        '401':
          $ref: '#/components/responses/FailureResponse'
        '422':
          $ref: '#/components/responses/FailureResponse'
      security:
        - JWT-Auth: []
      requestBody:
        $ref: '#/components/requestBodies/AddGamenight'
      description: 'Add a gamenight by providing a name and a date, only available when providing an JWT token.'
    get:
      summary: ''
      operationId: get-gamenight
      responses:
        '200':
          $ref: '#/components/responses/GamenightResponse'
        '401':
          $ref: '#/components/responses/FailureResponse'
        '422':
          $ref: '#/components/responses/FailureResponse'
      requestBody:
        $ref: '#/components/requestBodies/GetGamenight'
      security:
        - JWT-Auth: []
components:
  schemas:
    Gamenight:
      title: Gamenight
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        datetime:
          type: string
        owner_id:
          type: string
        participants:
          type: array
          items:
            type: string
      required:
        - id
        - name
        - datetime
        - owner_id
        - participants
    Failure:
      title: Failure
      type: object
      properties:
        message:
          type: string
      description: ''
    Token:
      title: Token
      type: object
      properties:
        jwt_token:
          type: string
    Login:
      title: Login
      type: object
      properties:
        username:
          type: string
        password:
          type: string
      required:
        - username
        - password
    Registration:
      title: Registration
      type: object
      properties:
        username:
          type: string
        email:
          type: string
        password:
          type: string
        password_repeat:
          type: string
        registration_token:
          type: string
      required:
        - username
        - email
        - password
        - password_repeat
        - registration_token
    AddGamenightRequestBody:
      title: AddGamenightRequestBody
      type: object
      properties:
        name:
          type: string
        datetime:
          type: string
    User:
      type: object
      properties:
        id:
          type: string
        username:
          type: string
        email:
          type: string
      required:
        - username
  requestBodies:
    LoginRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Login'
    RegisterRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Registration'
    AddGamenight:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AddGamenightRequestBody'
    GetGamenight:
      content:
        application/json:
          schema:
            type: object
            properties:
              id:
                type: string
  responses:
    TokenResponse:
      description: Example response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Token'
    FailureResponse:
      description: Example response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Failure'
        application/xml:
          schema:
            type: object
            properties:
              message:
                type: string
            required:
              - message
    GamenightsResponse:
      description: Example response
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/Gamenight'
    GamenightResponse:
      description: A gamenight being hosted
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Gamenight'
    UserResponse:
      description: A user in the gamenight system
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/User'
  securitySchemes:
    JWT-Auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: ''