-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for typed headers in the response #77
Comments
Interestingly this is not supported by openapi-generator OpenAPITools/openapi-generator#12855 |
The pet store API has an example which returns headers as part of the response:
Currently our TypeScript generator creates a method with the following signature:
How do we return the information provided by the headers? This is tricky in the above example because the
I'm leaning towards (3) as it has zero impact on APIs that don't return headers, and keeps the return types as simple as possible. Thoughts? |
I agree choosing option (2) won't have many implications in the API but I don't find it structurally correct to expose I also find the selective wrapping of (3) creates inconsistencies in the API for the end user. (e.g. one API endpoint returning I would either go with option (1) or approach from another angle where we store the additional header information into the |
Thanks for the feedback @gkocak-scottlogic - you're right, none of the 3 options are great. I like your alternative approach. Headers are often used in APIs for more general metadata, e.g. rate limits, paging etc. Perhaps having an API where you can request the most recently returned headers would make sense. In this example, that could look like:
|
I think I like the way it looks in the example. It's definitely a solid option. We can go through that if everyone agrees on it. |
A few thoughts based on our experiences with swagger-typescript-api:
|
Thanks for the feedback @OiNutter that was very useful, based on this, and from having had a look at various other API generators, I've taken the route of creating a response object that hosts both the data and headers. This feature has been added to all generators. Keeping this issue open, the generated client return headers, but don't apply any of the type information present within the schema. |
Example response object:
The text was updated successfully, but these errors were encountered: