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

Accept header with multiple types default to "text/plain" #599

Closed
Mcourt opened this issue Sep 10, 2019 · 0 comments · Fixed by #604
Closed

Accept header with multiple types default to "text/plain" #599

Mcourt opened this issue Sep 10, 2019 · 0 comments · Fixed by #604
Assignees
Labels

Comments

@Mcourt
Copy link

Mcourt commented Sep 10, 2019

Describe the bug
When I request prism with an "accept" header that has multiple types (ex: application/json, text/plain, */*), prism will try to send back "text/plain" response.

To Reproduce

  1. Given this OpenAPI document
openapi: 3.0.0
info:
  title: My title
  version: 1.0.0
paths:
  /check-email:
    post:
      tags:
        - User
      summary: Check the availability of an email
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  example: [email protected]
        required: true
      responses:
        "204":
          description: OK, the email is available
          content:
            application/json:
              schema:
                nullable: true
        "400":
          description: Bad Request, the email is not available
          content:
            application/json:
              schema:
                nullable: true
  1. Run this CLI command http POST 127.0.0.1:4010/check-email [email protected] Accept:'application/json, text/plain, */*'
  2. See error
{
    "detail": "Cannot serialise complex objects as text/plain",
    "status": 500,
    "title": "Cannot serialise complex objects as text/plain",
    "type": "https://stoplight.io/prism/errors#NO_COMPLEX_OBJECT_TEXT_PLAIN"
}

Expected behavior
I expected the server to respond with a 204 response.

Environment (remove any that are not applicable):

  • Library version: 3.1.0
  • OS: Ubuntu 18.04.3 LTS (Bionic Beaver)

Additional context
I am using "axios" to make the call and it defaults to application/json, text/plain, */*' for its 'Accept' header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants