gabledata / recap

Work with your web service, database, and streaming schemas in a single format.
https://recap.build
MIT License
334 stars 24 forks source link

Handle "type" being an array of strings in JSON schema converter #423

Closed adrianisk closed 9 months ago

adrianisk commented 10 months ago

Summary

Fixes https://github.com/recap-build/recap/issues/412

Updates to handle the case where a type in JSON schema is an array of strings, like {"type": ["null", "string", "boolean", "number"]}. From the JSON schema docs

The type keyword may either be a string or an array:

If it's a string, it is the name of one of the basic types above. If it is an array, it must be an array of strings, where each string is the name of one of the basic types, and each element is unique.

Details

I added tests to make sure nullable/optional types are converted correctly, and that properties of an object that are both not required & a union with null ({"type": ["null", "string"]}) are not made "double nullable".

criccomini commented 10 months ago

@adrianisk checking in here

adrianisk commented 10 months ago

Heyo, wrapping up a project that needs to get done today, then I'll take a look at this!

Edit: or first thing tomorrow 😪

criccomini commented 9 months ago

@adrianisk I've merged your PR and made the remaining tweaks here:

https://github.com/recap-build/recap/pull/426

Note that my PR results in a subtle change to the way null JSON schema types are handled. See the PR for details.

criccomini commented 9 months ago

Released in 0.12.0:

https://pypi.org/project/recap-core/0.12.0/