Skip to content

API: Issue with schema.yaml

Describe the bug

The schema for publishing episodes is describing a body as JSON:

post:
      summary: Publish an episode
      operationId: publish-episode
      parameters:
        - name: episodeId
          in: path
          description: The id of the episode to publish
          required: true
          schema:
            type: integer
            format: int64
      requestBody:
        description: Publish parameters
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EpisodePublishRequest"

While the post for publishing a new episode required multipart/form-data:

/episodes/{episodeId}/publish:
    post:
      summary: Publish an episode
      operationId: publish-episode
      parameters:
        - name: episodeId
          in: path
          description: The id of the episode to publish
          required: true
          schema:
            type: integer
            format: int64
      requestBody:
        description: Publish parameters
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EpisodePublishRequest"

BUT the publishing new episode only works if I pass the body as form data, not JSON.

Steps to reproduce

Publishing new episode only works if I pass the body as form data, not JSON.

$body = @{
    'publication_method' = 'now'
    'created_by' = 1
}

$response = Invoke-RestMethod `
    -Uri "https://myserver/api/rest/v1/episodes/83/publish" `
    -Method Post `
    -Headers $headers `
    -Form $body

Expected behavior

Expectation is that publishing a the new episode will work as described by the API schema.

Actual behavior

Publishing new episode does not work if you post application/json.

Context

  • Castopod: lastest production function
  • OS: Docker
  • Browser: Any
  • Web server: Whatever is in the Docker container

Possible fixes

This schema definition:

/episodes/{episodeId}/publish:
    post:
      summary: Publish an episode
      operationId: publish-episode
      parameters:
        - name: episodeId
          in: path
          description: The id of the episode to publish
          required: true
          schema:
            type: integer
            format: int64
      requestBody:
        description: Publish parameters
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EpisodePublishRequest"

Should be

/episodes/{episodeId}/publish:
    post:
      summary: Publish an episode
      operationId: publish-episode
      parameters:
        - name: episodeId
          in: path
          description: The id of the episode to publish
          required: true
          schema:
            type: integer
            format: int64
      requestBody:
        description: Publish parameters
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/EpisodePublishRequest"

The bug is content in the requestBody should be multipeart/form-data.

I will provide a fix if this is an accurate description of the bug and an actual bug.

Edited by Ben Richards