Convert a JSON Schema from one dialect to another. More...
Enumerations | |
| enum class | sourcemeta::blaze::ConvertTarget : std::uint8_t { ConvertTarget::Draft4 , ConvertTarget::Draft6 , ConvertTarget::Draft7 , ConvertTarget::Draft201909 , ConvertTarget::Draft202012 , ConvertTarget::OpenAPI31 , ConvertTarget::OpenAPI32 } |
Functions | |
| SOURCEMETA_BLAZE_CONVERT_EXPORT auto | sourcemeta::blaze::convert (sourcemeta::core::JSON &schema, const sourcemeta::core::SchemaWalker &walker, const sourcemeta::core::SchemaResolver &resolver, const ConvertTarget target, const std::string_view default_dialect="", const std::string_view default_id="") -> void |
Convert a JSON Schema from one dialect to another.
This functionality is included as follows:
| class sourcemeta::blaze::ConvertUnsupportedDialectError |
An error that represents a dialect the conversion cannot move a schema from
| class sourcemeta::blaze::ConvertUnsupportedMetaschemaError |
An error that represents a meta-schema that the conversion cannot move
| class sourcemeta::blaze::ConvertInvalidReferenceError |
An error that represents a schema reference that does not point to a schema
| class sourcemeta::blaze::ConvertBrokenReferenceError |
An error that represents a broken schema reference after conversion
|
strong |
| SOURCEMETA_BLAZE_CONVERT_EXPORT auto sourcemeta::blaze::convert | ( | sourcemeta::core::JSON & | schema, |
| const sourcemeta::core::SchemaWalker & | walker, | ||
| const sourcemeta::core::SchemaResolver & | resolver, | ||
| const ConvertTarget | target, | ||
| const std::string_view | default_dialect = "", | ||
| const std::string_view | default_id = "" )->void |
Convert the given schema, in place, to the given dialect. Only upgrades are supported, so a schema already on that dialect or a newer one is left as is. A document that describes itself or that carries the meta-schema something in it declares raises ConvertUnsupportedMetaschemaError. The dialects this conversion walks through are the official JSON Schema ones up to 2020-12, and then the OpenAPI 3.1 and OpenAPI 3.2 Schema Object dialects, each of which is 2020-12 plus a vocabulary of its own. A document that sits on any other dialect raises ConvertUnsupportedDialectError whatever the requested target is, as this conversion has no rules for moving a schema off such a dialect and will not convert the document around one either. Note that a document whose dialect cannot be resolved or framed at all fails before any of those apply, propagating the error that resolution or framing raised rather than one of this module's, so a caller that must not fault on hostile input catches more than the Convert*Error family. Conversion mutates in place and does not roll back, so a document that raises part way through is left half converted. For example: