From bbe034155b1c6ba6a06589b24b132c3b89946db0 Mon Sep 17 00:00:00 2001 From: Ross McDonald Date: Tue, 20 Feb 2018 10:33:16 -0600 Subject: [PATCH] Remove polymorphic objects article, since its pretty much the same things as object-inheritance. (#144) --- articles/modeling/polymorphic-objects.md | 44 ------------------------ 1 file changed, 44 deletions(-) delete mode 100644 articles/modeling/polymorphic-objects.md diff --git a/articles/modeling/polymorphic-objects.md b/articles/modeling/polymorphic-objects.md deleted file mode 100644 index cb20b92..0000000 --- a/articles/modeling/polymorphic-objects.md +++ /dev/null @@ -1,44 +0,0 @@ -# Polymorphic Objects - -## What - -- Resources in your API are polymorphic. They can be returned as XML or JSON and can have a flexible amount of fields. You can also have requests and responses in your API design that can be depicted by a number of alternative schemas. -- **Polymorphism** is the capacity to present the same interface for differing underlying forms. -- The **discriminator** keyword is used to designate the name of the property that decides which schema definition validates the structure of the model. - -## Why -- Polymorphism permits combining and extending model definitions. - -## Best Practices - - ->The discriminator property **must** be a mandatory or required field. When it is used, the value **must** be the name of the schema or any schema that inherits it. - -### Example - -``` -{ - definitions: - Vehicle: - type: object, - discriminator: brand - properties: - model: - type: string - color: - type: string - required: - model - - Sedan: # Sedan is used as the discriminator value - - allOf: - $ref: '#/definitions/Vehicle' - type: object - properties: - dateManufactured: - type: date - required: - dateManufactured -} -```