updates
This commit is contained in:
parent
8352f8f233
commit
a58843c566
5 changed files with 104 additions and 0 deletions
|
@ -136,3 +136,4 @@ could comprehend what it means to have dignity of self.
|
|||
|
||||
* Resources
|
||||
- [[https://slaafws.org/][Fellowship-Wide Services]]
|
||||
- [[https://slaadvi.org/][S.L.A.A. Greater Delaware Valley Intergroup]]
|
||||
|
|
24
20210225144943-openapi_core_exceptions.org
Normal file
24
20210225144943-openapi_core_exceptions.org
Normal file
|
@ -0,0 +1,24 @@
|
|||
#+title: OpenAPI Core Exceptions
|
||||
|
||||
Diagram of the exceptions in the [[file:20210226114112-openapi_core.org][OpenAPI Core]] library.
|
||||
|
||||
#+begin_src dot :file openapi-core-exceptions.svg
|
||||
digraph {
|
||||
# openapi-core/openapi_core/casting/schemas/exceptions.py
|
||||
OpenAPIError -> CastError
|
||||
# openapi-core/openapi_core/deserializing/exceptions.py
|
||||
OpenAPIError -> DeserializeError
|
||||
# openapi-core/openapi_core/deserializing/parameters/exceptions.py
|
||||
DeserializeError -> EmptyParameterValue
|
||||
# openapi-core/openapi_core/unmarshalling/schemas/exceptions.py
|
||||
OpenAPIError -> UnmarshalError
|
||||
UnmarshalError -> ValidateError
|
||||
UnmarshalError -> UnmarshallerError
|
||||
ValidateError -> InvalidSchemaValue
|
||||
UnmarshallerError -> InvalidSchemaFormatValue
|
||||
UnmarshallerError -> FormatterNotFoundError
|
||||
}
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
[[file:openapi-core-exceptions.svg]]
|
74
20210226111129-validating_data_against_a_schema_object.org
Normal file
74
20210226111129-validating_data_against_a_schema_object.org
Normal file
|
@ -0,0 +1,74 @@
|
|||
#+title: Validating data against a schema object
|
||||
#+roam_tags: openapi-core
|
||||
|
||||
How to use [[file:20210226114112-openapi_core.org][OpenAPI Core]]
|
||||
|
||||
#+begin_src python :results code :exports both
|
||||
from openapi_core import create_spec
|
||||
from openapi_core.unmarshalling.schemas.factories import SchemaUnmarshallersFactory
|
||||
|
||||
spec = create_spec({
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.0.0",
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"resource": {
|
||||
"type": "object",
|
||||
"properties": {"name": {"type": "string"}},
|
||||
"required": ["name"],
|
||||
},
|
||||
},
|
||||
"securitySchemes": {
|
||||
"basicAuth": {
|
||||
"type": "http",
|
||||
"scheme": "bearer",
|
||||
}
|
||||
},
|
||||
},
|
||||
"security": [{"basicAuth": []}],
|
||||
"paths": {
|
||||
"/resource": {
|
||||
"post": {
|
||||
"requestBody": {
|
||||
"required": True,
|
||||
"content": {
|
||||
"application/vnd.example.resource+json": {
|
||||
"schema": {"$ref": "#/components/schemas/resource"},
|
||||
}
|
||||
},
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Success",
|
||||
"content": {
|
||||
"application/vnd.example.resource+json": {
|
||||
"schema": {"$ref": "#/components/schemas/resource"},
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
data = {
|
||||
"badname": "Name",
|
||||
}
|
||||
|
||||
factory = SchemaUnmarshallersFactory()
|
||||
unmarshaller = factory.create(spec.components.schemas.get("resource"))
|
||||
|
||||
try:
|
||||
return unmarshaller(data)
|
||||
except Exception as e:
|
||||
return str(e)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
#+begin_src python
|
||||
Value {'badname': 'Name'} not valid for schema of type SchemaType.OBJECT: (<ValidationError: "'name' is a required property">,)
|
||||
#+end_src
|
4
20210226114112-openapi_core.org
Normal file
4
20210226114112-openapi_core.org
Normal file
|
@ -0,0 +1,4 @@
|
|||
#+title: OpenAPI Core
|
||||
|
||||
A Python library for validating requests and responses against OpenAPI 3
|
||||
specifications.
|
|
@ -8,3 +8,4 @@ A collection of entry points to various interests and ideas.
|
|||
- [[file:20210219114633-digital_audio_processing.org][Digital Audio Processing]]
|
||||
- [[file:20200716214603-taking_better_notes.org][Taking better notes]]
|
||||
- [[file:20200721011317-the_phoenix_inquisitor.org][The Phoenix Inquisitor]]
|
||||
- [[file:20210226114112-openapi_core.org][OpenAPI Core]]
|
||||
|
|
Loading…
Reference in a new issue