You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Includes an example. This intentionally does not explain how
dynamic referencing works, as there are better resources available
in both the spec and (more readably) the official JSON Schema blog.
Copy file name to clipboardExpand all lines: versions/3.2.0.md
+114
Original file line number
Diff line number
Diff line change
@@ -2398,6 +2398,15 @@ There are two ways to define the value of a discriminator for an inheriting inst
2398
2398
- Override the schema name by overriding the property with a new value. If a new value exists, this takes precedence over the schema name.
2399
2399
As such, inline schema definitions, which do not have a given id, *cannot* be used in polymorphism.
2400
2400
2401
+
###### Generic (Template) Data Structures
2402
+
2403
+
Implementations MAY support defining generic or template data structures using JSON Schema's dynamic referencing feature:
2404
+
2405
+
* `$dynamicAnchor` identifies a set of possible schemas (including a default placeholder schema) to which a `$dynamicRef` can resolve
2406
+
* `$dynamicRef` resolves to the first matching `$dynamicAnchor` encountered on its path from the schema entry point to the reference, as described in the JSON Schema specification
2407
+
2408
+
An example is included in the "Schema Object Examples" section below, and further information can be found on the Learn OpenAPI site's ["Dynamic References"](https://learn.openapis.org/referencing/dynamic.html) page.
2409
+
2401
2410
###### XML Modeling
2402
2411
2403
2412
The [xml](#schemaXml) property allows extra definitions when translating the JSON definition to XML.
When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the document of an alternative schema based on the value associated with it.
0 commit comments