Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI renders the "Response content type" Drop down for operations with no produces #3532

Open
DavidBiesack opened this issue Aug 7, 2017 · 2 comments

Comments

@DavidBiesack
Copy link

For the OpenAPI 2.0 document below, Swagger UI renders the Response content type drop down and tries to pass an Accept header even though the DELETE operation does not have a produces: value

swagger: "2.0"
info:
  version: "1"
  title: Delete prompts for Accept media type
  description: Delete prompts for Accept media type
basePath: /delete-accept
schemes:
- "http"
paths:
  /models/{modleId}:
    delete:
      summary: Delete a model
      description: "Even though this operation does not produce anything,
        Swagger UI still prompts for and passes the Accept: header"
      operationId: deleteModel
      parameters:
      - name: modelId
        in: path
        required: true
        type: string
        description: The ID of the model to delete
      responses:
        204:
          description: No Content. The model was deleted.
        404:
          description: Not Found

Try it out -> execute shows the command:

curl -X DELETE "http://localhost/delete-accept/models/{modleId}" -H "accept: application/json"

The screenshot shows the rendering
delete-accept

@shockey
Copy link
Contributor

shockey commented Aug 7, 2017

The Responses component defaults to application/json if no produces value is set:

produces: fromJS(["application/json"]),

That's probably the source of this. @webron, can you speak to why the default is in place?

@webron
Copy link
Contributor

webron commented Aug 11, 2017

It's one of the downsides of 2.0. Often people write definitions that don't specify the produces even when there is a chance to get a payload. We could enhance the behavior by checking if a 2XX/default response has a schema, and only then set the default to application/json.

@DavidBiesack DavidBiesack changed the title UI redners the "Response content type" Drop down for operations with no produces UI renders the "Response content type" Drop down for operations with no produces Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants