OpenAPI Schema Required No Default (Edit)

Required properties should not have default values. If a property is required, the client must provide it explicitly. Having a default on a required property creates confusion about whether the client needs to send it.

OpenAPISchemaRequiredDefaults

Rule Definition

openapi-schema-required-no-default-error.yaml
{"openapi-schema-required-no-default-error":{"description":"Required properties should not have default values. If a property is required, the client must provide it explicitly. Having a default on a required property creates confusion about whether the client needs to send it.","message":"Required properties MUST NOT have default values.","given":"$..[?(@.required)]..properties[?(@.default)]","severity":"error","then":{"field":"default","function":"falsy"}}}

Back to All of the Rules