OpenAPITools / OpenAPITools/openapi-generator

[BUG] [Typescript] Response headers are not available.

Open
#12,855 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I want to access the response headers for an E-tag. In the openAPI yaml file, the headers are defined for the response but it doesn't generate anything to access them

      responses:
        '200':
          description: Resource returned OK.
          headers:
            Cache-Control:
              $ref: '#/components/headers/CacheControlHeader'
            ETag:
              $ref: '#/components/headers/ETagHeader'
            Version:
              $ref: '#/components/headers/VersionHeader'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/....'

the header is defined as follows:

    ETagHeader:
      description: 'Caching: An opaque string which identifies a specific version of the returned resource.'
      schema:
        type: string

The problem with the headers in the response not being accessible (especially E-tag) seems to be faced by other typescript-xxx client generators https://github.com/OpenAPITools/openapi-generator/issues/6527

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript client generators and the supplied OpenAPI response definition, then inspect how generated responses expose headers. Confirm the behavior across the affected typescript-xxx generator and add access to the ETag and other declared headers; done means a generated client can read them from the response.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.