at-least-one-property-in-schema-required-list
Overview
This rule belongs to the openapi-v3-standards-validation ruleset and states that:
If property required is specified in the Schema Object of an OpenAPI 3.0.x document, it must be a list containing at least one schema property name that needs to be marked as mandatory.
| Property | Value |
|---|---|
| Enabled | Yes |
| Maximum Severity | Error |
| Message | List of required properties of Schema Object is empty. |
| Code | OPENAPI3STANDARDS_V334 |
| Type | Validation |
| Rule System | Semantic |
| Broad Category | Schemas |
| Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
| Tags | openapi3 openapi standards semantic validation required properties property name object json schema validation json schema |
Suggested Fixes
- If you do not intend to mark any property as required, remove the
requiredproperty from the Schema Object as by default all properties are considered optional. - If you want to specify the
requiredproperty, it must contain at least one entry. - The list of items in the
requiredproperty need to be names of the properties defined inside thepropertiesproperty of the Schema Object. The name of the property in the list must match exactly with the name of the schema property. Names are compared in a case-sensitive manner.
For More Information
- https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00#section-5.15
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schema-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-specification
- https://docs.apimatic.io/rulesets/overview/