OpenAPIValidationError
The Cause
Section titled “The Cause”The OpenAPI document failed validation against the OpenAPI 3.x specification. This means the document structure or content does not conform to the OpenAPI standard and cannot be processed.
Common validation issues include:
- Missing required fields - Fields like
openapi,info, orpathsare missing - Invalid schema definitions - Schema objects don’t follow the JSON Schema specification
- Incorrect data types - Properties have values that don’t match their expected types
- Malformed references -
$refpointers are invalid or point to non-existent definitions - Invalid server definitions - Server objects are missing required properties
- Incorrect HTTP methods - Unsupported or misspelled HTTP methods in path definitions
Example of invalid OpenAPI:
# ❌ Invalid - missing required 'info' fieldopenapi: 3.1.0paths: /users: get: responses: '200': description: Success
# ✅ Valid - includes all required fieldsopenapi: 3.1.0info: title: My API version: 1.0.0paths: /users: get: responses: '200': description: SuccessThe Solution
Section titled “The Solution”Use the validation command
Section titled “Use the validation command”Thymian provides a validation command that shows detailed error messages:
thymian openapi:validate path/to/your/openapi.yamlThis will output the specific validation errors with line numbers and descriptions.
Review the OpenAPI specification
Section titled “Review the OpenAPI specification”Consult the OpenAPI specification to understand the required structure.