imports:
  commons: commons.yml
types:
  PlaylistId: string
  Playlist:
    extends: PlaylistCreateRequest
    properties:
      playlist_id: PlaylistId
      owner-id: commons.UserId

  PlaylistCreateRequest:
    properties:
      name: string
      problems: list<commons.ProblemId>

  UpdatePlaylistRequest:
    properties:
      name: string
      problems:
        type: list<commons.ProblemId>
        docs: The problems that make up the playlist.
  PlaylistIdNotFoundErrorBody:
    union:
      playlistId: PlaylistId

  ReservedKeywordEnum:
    enum:
      - is
      - as

service:
  auth: true
  base-path: /v2/playlist/{serviceParam}
  path-parameters:
    serviceParam: integer
  endpoints:
    createPlaylist:
      docs: Create a new playlist
      method: POST
      path: /create
      request:
        name: CreatePlaylistRequest
        query-parameters:
          datetime: datetime
          optionalDatetime: optional<datetime>
        body: PlaylistCreateRequest
      response: Playlist

    getPlaylists:
      docs: Returns the user's playlists
      method: GET
      path: /all
      response: list<Playlist>
      request:
        name: GetPlaylistsRequest
        query-parameters:
          limit: optional<integer>
          otherField:
            docs: i'm another field
            type: string
          multiLineDocs:
            docs: |
              I'm a multiline
              description
            type: string
          optionalMultipleField:
            type: optional<string>
            allow-multiple: true
          multipleField:
            type: string
            allow-multiple: true

    getPlaylist:
      docs: Returns a playlist
      method: GET
      path: /{playlistId}
      auth: false
      path-parameters:
        playlistId: PlaylistId
      response: Playlist
      errors:
        - PlaylistIdNotFoundError
        - UnauthorizedError

    updatePlaylist:
      docs: Updates a playlist
      method: PUT
      path: /{playlistId}
      path-parameters:
        playlistId: PlaylistId
      request:
        body:
          type: optional<UpdatePlaylistRequest>
      response: optional<Playlist>
      errors:
        - PlaylistIdNotFoundError

    deletePlaylist:
      docs: Deletes a playlist
      method: DELETE
      path: /{playlist_id}
      path-parameters:
        playlist_id: PlaylistId

errors:
  PlaylistIdNotFoundError:
    type: PlaylistIdNotFoundErrorBody
    status-code: 404
  UnauthorizedError:
    status-code: 401
