-
-
Notifications
You must be signed in to change notification settings - Fork 268
Description
Hi!
According to the OpenAPI specification, when a discriminator.propertyName is specified, the property must be present in the schema's properties section (though it doesn't have to be required, as per OpenAPI 3.2.0). However, the linter does not detect this violation.
I've created a repository demo (see /spectral-issue folder).
Expected behavior
The linter should fail validation and report an error similar to: discriminator property 'petType' is not defined in schema properties. Probably need to add a validation rule for discriminator property existence in OpenAPI 3.x schemas.
Current behavior
Spectral passes without errors or warnings related to this issue, even though the discriminator references a non-existent property.
In-Repository Example
Pet:
type: object
properties:
name:
type: string
age:
type: integer
discriminator:
propertyName: petType # ERROR: petType not in propertiesAccording to the OpenAPI 3.1.2 specification:
The expectation now is that a property with name petType MUST be present in the response payload