-
-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Description
I am working on using openapi-core to validate Kubernetes resource definitions as described here:
So far what I have figured out is validating these with a request validator, but I'd like to bypass creating a request if possible because of all the extra steps. Is there a better pattern that I can use to just validate against the schema and avoid the mock request creation?
template_validator = openapi_core.shortcuts.RequestValidator(
openapi_core.shortcuts.create_spec({
"openapi": "3.0.0",
"info": { "title": "", "version": "0.1" },
"paths": {
"/claimTemplate": {
"post": {
"requestBody": {
"required": True,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClaimTemplate"
}
}
}
},
"responses": {}
}
}
},
"components": {
"schemas": {
"ClaimTemplate": openAPIV3Schema
}
}
})
)
validation_result = template_validator.validate(
openapi_core.wrappers.mock.MockRequest(
'http://example.com', 'post', '/claimTemplate',
path_pattern='/claimTemplate',
data=json.dumps(template)
)
)
validation_result.raise_for_errors()
Metadata
Metadata
Assignees
Labels
No labels