Skip to content
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

Edge cases around response headers #810

Open
pmcelhaney opened this issue Mar 19, 2024 · 2 comments
Open

Edge cases around response headers #810

pmcelhaney opened this issue Mar 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@pmcelhaney
Copy link
Owner

  • if a response header is required, the random() function should fill it in when missing
  • if a response header is not required, a response that's constructed without that header should type check (in OpenAPI 2, assume all headers are optional, as there's no way to mark it required)
@pmcelhaney pmcelhaney added the bug Something isn't working label Mar 19, 2024
@pmcelhaney
Copy link
Owner Author

In order to make the type check work, the generated code passed as a type argument to ResponseBuilderFactory is going to have a have a requiredHeaders type.

When all of the required headers and content types are exhausted, but there remain some optional headers, the return type will have to add a dummy property like "allHeadersAreOptional". So that { allHeadersAreOptional: string } is a valid return type.

If you're reading this and it makes no sense, don't worry. It makes sense to me. At least today it does. Hopefully I'll finish before it stops making sense. One day I'll document properly how this crazy type system works.

@pmcelhaney
Copy link
Owner Author

The second bullet point is solved as of 0.38.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant