counterfact icon indicating copy to clipboard operation
counterfact copied to clipboard

Edge cases around response headers

Open pmcelhaney opened this issue 1 year ago • 2 comments

  • 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 avatar Mar 19 '24 23:03 pmcelhaney

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 avatar Mar 22 '24 01:03 pmcelhaney

The second bullet point is solved as of 0.38.1.

pmcelhaney avatar Mar 22 '24 21:03 pmcelhaney