Skip to content

Responses without bodies also omit headers from generated output. #1109

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

Closed
1 task
openreply-dleinhaeuser opened this issue May 12, 2023 · 0 comments · Fixed by #1280
Closed
1 task

Responses without bodies also omit headers from generated output. #1109

openreply-dleinhaeuser opened this issue May 12, 2023 · 0 comments · Fixed by #1280
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library

Comments

@openreply-dleinhaeuser
Copy link

Description

When an OpenAPI spec does not specify a response body for a response (say 204 No Content), the generated type for that response becomes never, which omits any headers that might be specfied for that response.

Name Version
openapi-typescript 6.2.4
Node.js 20.1.0
OS + version macOS 13.3.1

Reproduction

Convert the following OpenAPI schema to TypeScript using openapi-typescript:

openapi: "3.0.2"
info:
  title: Response header bug example
  version: "1.0.0"
  contact:
    email: [email protected]
servers:
  - description: local server
    url: http://localhost
paths:
  "/foo":
    get:
      responses:
        "204":
          description: No Content
          headers:
            foo:
              schema:
                type: string
  "/bar":
    get:
      responses:
        "200":
          description: OK
          headers:
            "bar":
              schema:
                type: string
          content:
            "application/json":
              schema:
                type: object

Expected result

paths["/foo"]["get"]["responses"][204] is { headers: { foo?: string; } }; content: {}; } or something similar instead of never.

Checklist

@drwpow drwpow added the bug Something isn't working label May 12, 2023
@drwpow drwpow added the openapi-ts Relevant to the openapi-typescript library label May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants