Skip to content

Feature/formats #13

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

Merged
merged 3 commits into from
Jul 28, 2018
Merged

Feature/formats #13

merged 3 commits into from
Jul 28, 2018

Conversation

ehmicky
Copy link
Contributor

@ehmicky ehmicky commented May 16, 2018

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:

  • int32, int64, float, double: add related minimum and maximum keywords
  • byte: add pattern keyword to match base64. We are using standard base64, not base64url, as this is what is intended
  • password and binary: left as is since they are just semantic/UI hints

I respected the following principles of JSON schema v4:

  • any format value is valid (i.e. custom formats are possible)
  • keywords for a specific type (including a specific format) might appear even if the type is different

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
Copy link
Owner

mikunn commented Jul 28, 2018

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.

@mikunn mikunn merged commit 88b2c19 into mikunn:master Jul 28, 2018
@ehmicky ehmicky deleted the feature/formats branch July 29, 2018 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants