valid-parameter-example
Overview
This rule belongs to the openapi-v3-standards-linting
ruleset and states that:
The example value specified for the Parameter Object using either the example
property or examples
must be valid for the schema definition and encoding properties (if present) of that parameter.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Warning |
Message | Example does not conform to the parameter's schema or encoding definition. |
Code | OPENAPI3STANDARDS_L065 |
Type | Linting |
Rule System | Semantic |
Broad Category | Parameters |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi standards semantic linting examples example value parameter schema type encoding style explode |
Suggested Fixes
- Ensure that parameter example value conforms to the parameter schema definition.
- Check that no required properties are missing in the sample value.
- Check that types of all properties match those specified in the schema definition.
- Parameter encoding properties include style, explode, allowEmptyValue and allowReserved.
- If parameter level style, explode, allowEmptyValue, allowReserved are specified, ensure that the example is valid with respect to them.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameter-object
- 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
- https://docs.apimatic.io/rulesets/overview/