non-primitive-one-of-schemas-in-polymorphism
Overview
This rule belongs to the openapi-v3-apimatic-linting ruleset and states that:
It is not allowed to define the schemas with primitive types in oneOf list when discriminator property is defined alongside oneOf. This refers to polymorphism which is the ability of a schema to represent different types or subtypes in the presence of discriminator.
| Property | Value |
|---|---|
| Enabled | Yes |
| Maximum Severity | Error |
| Message | Schema with primitive type found in oneOf list which is not allowed in polymorphism. |
| Code | OPENAPI3APIMATIC_L700 |
| Type | Linting |
| Rule System | Semantic |
| Broad Category | OpenAPI Schemas |
| Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
| Tags | openapi3 openapi apimatic semantic linting primitive type oneof schema polymorphism discriminator |
Suggested Fixes
- Identify the schemas defined in
oneOflist. - Check the type definition of the schema and ensure it is not a primitive type (such as string, number, boolean, etc.).
- Modify the schema's type to be an object type.
- Ensure that the object type includes the necessary properties for representing the polymorphic structure.
- Remove the
discriminatorproperty.