mikunn / openapi-schema-to-json-schema

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

Feature/formats #13

Closed ehmicky closed 6 years ago

ehmicky commented 6 years ago

This PR aims at converting the formats defined only by OpenAPI but not in JSON schema v4, into something that is valid JSON schema v4.

All JSON schema v4 formats are left as is. Custom formats are also left as is. However the following OpenAPI-only formats are converted by adding extra keywords:

I respected the following principles of JSON schema v4:

I added unit tests.

I also removed the format keyword from non-format related unit tests, as this makes tests inter-dependent. Indeed when working on this feature, some unit tests were failing even though they were related to another feature.

mikunn commented 6 years ago

This is good stuff, thanks!

We will probably need to make the base64 pattern a bit more strict before the next release or alternatively provide an option for a custom pattern.

Also, conversion related functions start to appear all over the place, so it's probably a good time to start modularising things a bit.

I will take a look on both of these.