|
| 1 | +# JSON schema with 3.1 |
| 2 | + |
| 3 | +Temporary document to be removed with the merge of support for OpenAPI 3.1 |
| 4 | + |
| 5 | +Things have got complex with schemas in OpenAPI 3.1 |
| 6 | + |
| 7 | +How things might work: |
| 8 | + |
| 9 | +- when a schema factory is created, it determines whether the dialect is suported |
| 10 | +- it then creates a factory based on the dialect |
| 11 | +- if there is a reference in it this is resolved |
| 12 | +- there could be complexities in the resolving process because of the id field - does it become relative to this? |
| 13 | +- skip dynamicAnchor and dynamicRef for now - they are quite complex: https://stackoverflow.com/questions/69728686/explanation-of-dynamicref-dynamicanchor-in-json-schema-as-opposed-to-ref-and |
| 14 | +- lets allow extra properties for schema since it's complex |
| 15 | +- there's all the $defs stuff but this might just work as being a type of reference - presumably not used in OpenAPI anyway really |
| 16 | + |
| 17 | +So how might we start: |
| 18 | + |
| 19 | +- Perhaps add a class method to Schema which can identify which Schema factory is used: a OAS 3.1 one, an optionally referenced OAS 3.0 one, or non optional reference (if such a need exists), based on context. Error if given an unexpected dialect |
| 20 | +- Learn whether you have to care about $id for resolving |
| 21 | +- Create a node factory for OAS 3.1 Schema: |
| 22 | + - allow arbitrary fields perhaps? Probably not needed, just a pain to keep up with JsonSchema |
| 23 | + - load a merged reference |
| 24 | + - perhaps have context support a merge concept for source location |
| 25 | +- Think about dealing with recursive defined as "#" |
| 26 | + |
| 27 | +Dealing with the new JSON Schema approach for OpenAPI 3.1. |
| 28 | + |
| 29 | +There is some meta fields: |
| 30 | + |
| 31 | +$ref |
| 32 | +$dynamicRef |
| 33 | +$defs |
| 34 | +$schema |
| 35 | +$id |
| 36 | +$comment |
| 37 | +$anchor |
| 38 | +$dynamicAnchor |
| 39 | + |
| 40 | +Then a ton of fields: |
| 41 | + |
| 42 | +type: string |
| 43 | +enum: array |
| 44 | +const: any type |
| 45 | +multipleOf: number |
| 46 | +maximum: number |
| 47 | +exclusiveMaximum: number |
| 48 | +minimum: number |
| 49 | +exclusiveMinimum: number |
| 50 | +maxLength: integer >= 0 |
| 51 | +minLength: integer >= 0 |
| 52 | +pattern: string |
| 53 | +maxItems: integer >= 0 |
| 54 | +minItems: integer >= 0 |
| 55 | +uniqueItems: boolean |
| 56 | +maxContains: integer >= 0 |
| 57 | +minContains: integer >= 0 |
| 58 | +maxProperties: integer >= 0 |
| 59 | +minProperties: integer >= 0 |
| 60 | +required: array, strings, unique |
| 61 | +dependentRequired: something complex |
| 62 | +contentEncoding: string |
| 63 | +contentMediaType: string / media type |
| 64 | +contentSchema: schema |
| 65 | +title: string |
| 66 | +description: string |
| 67 | +default: any |
| 68 | +deprecated: boolean (default false) |
| 69 | +readOnly: boolean (default false) |
| 70 | +writeOnly: boolean (default false) |
| 71 | +examples: array |
| 72 | + |
| 73 | + |
| 74 | +allOf - non empty array of schemas |
| 75 | +anyOf - non empty array of schemas |
| 76 | +oneOf - non empty array of schemas |
| 77 | +not - schema |
| 78 | + |
| 79 | +if - single schema |
| 80 | +then - single schema |
| 81 | +else - single schema |
| 82 | + |
| 83 | +prefixItems: schema |
| 84 | +items: schema |
| 85 | +contains: schema |
| 86 | + |
| 87 | +properties: object, each value json schema |
| 88 | +patternProperties: object each value JSON schema |
| 89 | +additionalProperties: single json schema |
| 90 | + |
| 91 | +unevaluatedItems - single schema |
| 92 | +unevaluatedProperties: single schema |
0 commit comments