fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
941 stars 209 forks source link

fix: Pass JSON Schema keywords into OpenAPI Header Spec #704

Closed WoH closed 1 year ago

WoH commented 1 year ago

Checklist

Instead of just fixing the problem for enum (see #701), I assume we can pass everything from the JSON Schema into the OpenAPI parameter's spec. See the last OpenAPI test for an, admittedly, contrived scenario, which may however show why it may be short-sighted to only render the string specific keywords (pattern, format, minLength, maxLength). [This test is only for demo purposes]

Whenever the type is not string, it may make sense to make to explicitly set the style property. https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameter-object https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#style-values

In the end, this is similar to how we handle query parameters already, so this PR ended up basically just removing code.

While I'd always recommend separating the OpenAPI (Web) specific spec props (style, explode) from the JSON Schema, we pass it on in case of query params, so we should do that for headers the same way we treat query params anyway.

Currently, we do not pass allowReserved (OpenAPI v3), which I assume to be missing rather than an intended exclusion, in that case, should we add it? Added

mcollina commented 1 year ago

Currently, we do not pass allowReserved (OpenAPI v3), which I assume to be missing rather than an intended exclusion, in that case, should we add it?

I think so!

WoH commented 1 year ago

Added :)