edit Composition and Inheritance
MODIFY
versions/3.0.md
versions/3.0.md
@@ -2511,15 +2511,15 @@ This object can be extended with [Specification Extensions](#specificationExtens
###### <a name="schemaComposition"></a>Composition and Inheritance (Polymorphism)
The OpenAPI Specification allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition.
-`allOf` takes in an array of object definitions that are validated *independently* but together compose a single object.
+`allOf` takes an array of object definitions that are validated *independently* but together compose a single object.
While composition offers model extensibility, it does not imply a hierarchy between the models.
-To support polymorphism, OpenAPI Specification adds the support of the `discriminator` field.
-When used, the `discriminator` will be the name of the property used to decide which schema definition is used to validate the structure of the model.
+To support polymorphism, the OpenAPI Specification adds the `discriminator` field.
+When used, the `discriminator` will be the name of the property that decides which schema definition validates the structure of the model.
As such, the `discriminator` field MUST be a required field.
There are are two ways to define the value of a discriminator for an inheriting instance.
-- Use the schema's name.
-- Override the schema's name by overriding the property with a new value. If exists, this takes precedence over the schema's name.
+- Use the schema name.
+- Override the schema name by overriding the property with a new value. If a new value exists, this takes precedence over the schema name.
As such, inline schema definitions, which do not have a given id, *cannot* be used in polymorphism.
###### XML Modeling

edit Composition and Inheritance