File: README.md

package info (click to toggle)
openapi-pydantic 0.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 744 kB
  • sloc: python: 4,392; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 1,717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# OpenAPI v3.1 schema classes

## Alias

Due to the reserved words in python and pydantic,
the following fields are used with [alias](https://pydantic-docs.helpmanual.io/usage/schema/#field-customisation) feature provided by pydantic:

| Class | Field name in the class | Alias (as in OpenAPI spec) |
| ----- | ----------------------- | -------------------------- |
| Header[*](#header_param_in) | 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 |
| Schema | schema_if | if |
| Schema | schema_else | else |

> <a name="header_param_in"></a>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) or `populate_by_name=True` (Pydantic V2).
>
> Reference: [Pydantic's Model Config](https://pydantic-docs.helpmanual.io/usage/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.