mikunn / openapi-schema-to-json-schema

Converts OpenAPI Schema Object to JSON Schema
75 stars 6 forks source link

Add support for request parameters and response headers. #19

Open ehmicky opened 6 years ago

ehmicky commented 6 years ago

This is a continuation of #9

Main issue is that the library currently does not support passing OpenAPI 2.0 request parameters and response headers.

In OpenAPI 2.0, request parameters, request body, response body and response headers can be described using a slight variation of JSON schema v4. For some reasons, the designers of the specification decided to use 3 different shapes for those JSON schemas depending on where it's used:

This is arguably confusing and that's probably why they corrected it in OpenAPI 3.0 where there is only one JSON schema definition.

However many users might still want to take a request parameter or a response header and extract the JSON schema from it. That seems like a very legitimate thing users might want to do, regardless of the OpenAPI 2.0 design decisions above.

It turns out supporting OpenAPI 2.0 request parameters and response headers might not require much work since the only changes are:

Note that I can submit a PR if you want.