Skip to content

Feature Request: Automatically Generate Accept Headers #938

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

Open
Daniel-Vetter-Coverwhale opened this issue Jun 4, 2023 · 1 comment · May be fixed by #1464
Open

Feature Request: Automatically Generate Accept Headers #938

Daniel-Vetter-Coverwhale opened this issue Jun 4, 2023 · 1 comment · May be fixed by #1464
Labels
enhancement New feature or request openapi-features OpenAPI features support issues

Comments

@Daniel-Vetter-Coverwhale
Copy link
Contributor

Description

It would be really awesome if ogen would automatically generate an Accept header parameter and enum options for it based on the content-types in the response for a given operation. That way we can avoid specifying an Accept header ourselves (which I think openapi doesn't want us to do) and we can automatically deal with new content types as they are added to the spec without having to manually keep the enum in the header parameter in sync.

          "200": {
            "description": "200 OK",
            "content": {
              "application/vnd.sambasafety.json;version=2.0.4": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligentMvrJson2_04Response"
                }
              },
              "application/vnd.sambasafety.json;version=3.0.0": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligentMvrJson3_00Response"
                }
              },
              "application/vnd.sambasafety.xml;version=2.0.0": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligentMvrXml2_00Response"
                }
              },
              "application/vnd.sambasafety.xml;version=2.0.2": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligentMvrXml2_02Response"
                }
              },
              "application/vnd.sambasafety.xml;version=2.0.3": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligentMvrXml2_03Response"
                }
              },
              "application/vnd.sambasafety.html": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligentMvrHtmlResponse"
                }
              },
              "application/vnd.sambasafety.pdf": {
                "schema": {
                  "$ref": "#/components/schemas/IntelligentMvrPdfResponse"
                }
              }
            }
          },

References

https://swagger.io/docs/specification/describing-parameters/
image

@Daniel-Vetter-Coverwhale Daniel-Vetter-Coverwhale added enhancement New feature or request openapi-features OpenAPI features support issues labels Jun 4, 2023
@mxk
Copy link

mxk commented Jun 4, 2024

The spec seems unambiguous about this, so this should be categorized as a bug. The parameter documentation also says:

If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.

We're currently having to add Accept headers for responses that can return different content types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request openapi-features OpenAPI features support issues
Projects
None yet
2 participants