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

Conversion: Accept header in request when a response has an empty content type #623

Open
thim81 opened this issue Sep 20, 2022 · 3 comments
Labels

Comments

@thim81
Copy link
Contributor

thim81 commented Sep 20, 2022

We have noticed an issue in generated Postman collections if there is a 2xx response without content type defined. It seems very similar to issue reported in apideck-libraries/portman#392.

Here is an example of a specification, where one of responses has no content (204):

openapi: 3.0.0
info:
  title: Test
  version: '1.0'
paths:
  /test/endpoint:
    post:
      summary: Test endpoint
      responses:
        '204':
          description: 204 description
        '401':
          description: 401 description
          content:
            application/problem+json:
              schema:
                type: string
      requestBody:
        content:
          application/json:
            schema:
              type: string

Generated Postman collection will contain:
2022-09-20 at 20 57 42@2x

      "request": {
        "name": "Test endpoint",
...
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/problem+json"
          }
        ],
...
      }

Note an "Accept: application/problem+json" in request part of a generated file.

Though if we add at least one responce with "application/json" content (201), then generated Postman collection contains "Accept: application/json".

openapi: 3.0.0
info:
  title: Test
  version: '1.0'
paths:
  /test/endpoint:
    post:
      summary: Test endpoint
      responses:
        '204':
          description: 204 description
        '201':
          description: 201 description
          content:
            application/json:
              schema:
                type: string
        '401':
          description: 401 description
          content:
            application/problem+json:
              schema:
                type: string
      requestBody:
        content:
          application/json:
            schema:
              type: string

Generated Postman collection will contain:

      "request": {
        "name": "Test endpoint",
...
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
...
      }
@thim81
Copy link
Contributor Author

thim81 commented Sep 20, 2022

Linked to apideck-libraries/portman#400

@VShingala
Copy link
Member

@thim81 It seems to be correct behavior to me. So Accept request HTTP header indicates which content types, expressed as MIME types, the client is able to understand.

Here, as only content-type defined in response is application/problem+json, we add accept header with that as value but in the second example/case we also have application/json so we use that.

Could you also mention what would be expected behavior according to you?

@disha-shah1
Copy link

@thim81 Hi, is there any update on this? i have a delete request which does not have any content type for 204, same request has different response codes having different content type. now when i run for 204, it adds request header "Accept":"application/problem+json", which fails my test with unsupported media type. Please help me with this,

@VShingala VShingala added the awaiting-response Awaiting response from the User label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants