Skip to content

Bug: Headers that use refs aren't included in output #624

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
rustyconover opened this issue May 30, 2021 · 2 comments · Fixed by #971
Closed

Bug: Headers that use refs aren't included in output #624

rustyconover opened this issue May 30, 2021 · 2 comments · Fixed by #971

Comments

@rustyconover
Copy link

Hi there,

If a header is specified as a reference (i.e. as part of a response) the header isn't included in the produced objects.

An example response schema is:

"responses": {
    "200": {
    "content": {
        "application/json": {
        "schema": {
            "$ref": "#/components/schemas/Result_Ok_GetGroups"
        }
        }
    },
    "description": "OK",
    "headers": {
        "ETag": {
        "$ref": "#/components/headers/ETag"
        }
    }
}

That would produce a type with:

200: {
    headers: {};
    content: {
        "application/json": components["schemas"]["Result_Ok_GetGroups"];
    };
}

The reason is because of the check:

https://github.com/drwpow/openapi-typescript/blob/e2fb371f053c90af4d958c48b7b6b04271b257ca/src/transform/headers.ts#L17

v.schema won't be defined because the header is included by reference.

Properly handling the headers relies on resolving the reference (even if it is external).

Since the majority of my PR has not been merged that deals with resolving references, I'm going to just link to the commit that fixes this problem:

rustyconover@9c21864

Please feel free to cherry pick.

Rusty

@njanor
Copy link

njanor commented May 18, 2022

Hi,

This is an exact issue we're running into in our project currently. Will this be resolved at any time?

I've tried to have a look at the related issue (#586), but this seems to be something that can be included without the challenges presented and discussed in that issue.

@nsb
Copy link

nsb commented Oct 30, 2022

Just hit the same issue.

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

Successfully merging a pull request may close this issue.

3 participants