valid-media-type-example
Overview
This rule belongs to the openapi-v3-standards-linting
ruleset and states that:
The example value provided for a Media Type Object using either the example
property or examples
must be in a correct format with respect to the media type and valid for the specified schema definition (if present).
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Warning |
Message | Example does not conform to the specified media type format or its schema definition. |
Code | OPENAPI3STANDARDS_L080 |
Type | Linting |
Rule System | Semantic |
Broad Category | Media Types |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi standards semantic linting examples example value media type schema |
Suggested Fixes
- Ensure that the example value format matches the expected format based on the current media type.
- Ensure that media type example value conforms to the media type's 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.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-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#media-type-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/