| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Data.OpenApi.Migration
Description
Value-layer helpers that rewrite a raw, already-parsed OpenAPI 3.0
Value into a 3.1-shaped Value, which then decodes
into the 3.1-only Schema types.
Under the project's "Strategy A" the 3.1 Haskell types deliberately cannot
represent 3.0-only constructs (there is no nullable field, exclusive bounds
are numeric, and tuple items arrays are gone). So a user holding a 3.0
document must rewrite the parsed JSON before decoding it — that is what these
helpers do. They are intentionally deprecated to flag that 3.0 input is
transitional.
Synopsis
- migrate30To31 :: Value -> Value
- migrate30NullableValue :: Value -> Value
- migrate30ExclusiveBoundsValue :: Value -> Value
- migrate30ItemsArrayValue :: Value -> Value
- migrate30SchemaValue :: Value -> Value
Documentation
migrate30To31 :: Value -> Value Source #
Deprecated: 3.0 input support is transitional; remove once all inputs are 3.1.
Recursively rewrite a whole 3.0 document Value into 3.1 shape, applying the
schema rewrites to every nested object (so schemas inside properties,
prefixItems, $defs, allOf, request/response bodies, … are all migrated).
Applying the per-object rewrite to every object is safe because each rewrite is
a no-op on objects lacking its trigger keys.
migrate30NullableValue :: Value -> Value Source #
Deprecated: 3.0 input support is transitional; remove once all inputs are 3.1.
Rewrite a decoded 3.0 schema JSON object's nullable keyword into a 3.1
type array. nullable:true removes the nullable key and adds "null" to the
type key ("string" becomes ["string","null"]; ["string"] becomes
["string","null"]; absent type becomes ["null"]). nullable:false just
removes the nullable key.
migrate30ExclusiveBoundsValue :: Value -> Value Source #
Deprecated: 3.0 input support is transitional; remove once all inputs are 3.1.
Rewrite 3.0 boolean exclusive bounds into 3.1 numeric ones.
{"maximum":100,"exclusiveMaximum":true} becomes {"exclusiveMaximum":100}
(the maximum is dropped); {"maximum":100,"exclusiveMaximum":false} becomes
{"maximum":100}. Symmetric for minimum/exclusiveMinimum. An already-numeric
exclusive bound is left unchanged.
migrate30ItemsArrayValue :: Value -> Value Source #
Deprecated: 3.0 input support is transitional; remove once all inputs are 3.1.
Rewrite a 3.0 tuple items array into 3.1 prefixItems + items:false.
{"items":[a,b]} becomes {"prefixItems":[a,b],"items":false}. Fires only when
items is a JSON array; an object or boolean items is left unchanged.
migrate30SchemaValue :: Value -> Value Source #
Deprecated: 3.0 input support is transitional; remove once all inputs are 3.1.
Apply all single-object 3.0->3.1 rewrites to one schema object. The three rewrites operate on disjoint keys, so their order does not matter.