|
||
---|---|---|
.. | ||
__init__.py | ||
callback.py | ||
components.py | ||
contact.py | ||
datatype.py | ||
discriminator.py | ||
encoding.py | ||
example.py | ||
external_documentation.py | ||
header.py | ||
info.py | ||
license.py | ||
link.py | ||
media_type.py | ||
oauth_flow.py | ||
oauth_flows.py | ||
open_api.py | ||
operation.py | ||
parameter.py | ||
path_item.py | ||
paths.py | ||
README.md | ||
reference.py | ||
request_body.py | ||
response.py | ||
responses.py | ||
schema.py | ||
security_requirement.py | ||
security_scheme.py | ||
server.py | ||
server_variable.py | ||
tag.py | ||
util.py | ||
xml.py |
OpenAPI v3.0 schema classes
Alias
Due to the reserved words in python and pydantic, the following fields are used with alias feature provided by pydantic:
Class | Field name in the class | Alias (as in OpenAPI spec) |
---|---|---|
Header* | param_in | in |
MediaType | media_type_schema | schema |
Parameter | param_in | in |
Parameter | param_schema | schema |
PathItem | ref | $ref |
Reference | ref | $ref |
SecurityScheme | security_scheme_in | in |
Schema | schema_format | format |
Schema | schema_not | not |
The "in" field in Header object is actually a constant (
{"in": "header"}
).
For convenience of object creation, the classes mentioned in above have configured
allow_population_by_field_name=True
(Pydantic V1) orpopulate_by_name=True
(Pydantic V2).Reference: Pydantic's Model Config
Non-pydantic schema types
Due to the constriants of python typing structure (not able to handle dynamic field names),
the following schema classes are actually just a typing of Dict
:
Schema Type | Implementation |
---|---|
Callback | Callback = Dict[str, PathItem] |
Paths | Paths = Dict[str, PathItem] |
Responses | Responses = Dict[str, Union[Response, Reference]] |
SecurityRequirement | SecurityRequirement = Dict[str, List[str]] |
On creating such schema instances, please use python's dict
type instead to instantiate.