Skip to content

Commit ec1a8bc

Browse files
committed
updated vendored openapi_schema_pydantic / correct oai false negative
validation
1 parent 0f58cfd commit ec1a8bc

32 files changed

+239
-167
lines changed

openapi_python_client/schema/openapi_schema_pydantic/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Everything in this directory (including the rest of this file after this paragraph) is a vendored copy of [openapi-schem-pydantic](https://github.com/kuimono/openapi-schema-pydantic) and is licensed under the LICENSE file in this directory.
22

3+
Included vendored version is the [following](https://github.com/kuimono/openapi-schema-pydantic/commit/0836b429086917feeb973de3367a7ac4c2b3a665)
4+
Small patches has been applied to it.
5+
36
## Alias
47

58
Due to the reserved words in python and pydantic,

openapi_python_client/schema/openapi_schema_pydantic/__init__.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,34 @@
3838
"XML",
3939
]
4040

41-
from .components import Components
42-
from .contact import Contact
43-
from .discriminator import Discriminator
44-
from .encoding import Encoding
45-
from .example import Example
46-
from .external_documentation import ExternalDocumentation
47-
from .header import Header
41+
42+
from .open_api import OpenAPI
4843
from .info import Info
44+
from .contact import Contact
4945
from .license import License
50-
from .link import Link
51-
from .media_type import MediaType
52-
from .oauth_flow import OAuthFlow
53-
from .oauth_flows import OAuthFlows
54-
from .open_api import OpenAPI
46+
from .server import Server
47+
from .server_variable import ServerVariable
48+
from .components import Components
49+
from .paths import Paths
50+
from .path_item import PathItem
5551
from .operation import Operation
52+
from .external_documentation import ExternalDocumentation
5653
from .parameter import Parameter
57-
from .path_item import PathItem
58-
from .paths import Paths
59-
from .reference import Reference
6054
from .request_body import RequestBody
61-
from .response import Response
55+
from .media_type import MediaType
56+
from .encoding import Encoding
6257
from .responses import Responses
63-
from .schema import Schema
64-
from .security_requirement import SecurityRequirement
65-
from .security_scheme import SecurityScheme
66-
from .server import Server
67-
from .server_variable import ServerVariable
58+
from .response import Response
59+
from .callback import Callback
60+
from .example import Example
61+
from .link import Link
62+
from .header import Header
6863
from .tag import Tag
64+
from .reference import Reference
65+
from .schema import Schema
66+
from .discriminator import Discriminator
6967
from .xml import XML
68+
from .security_scheme import SecurityScheme
69+
from .oauth_flows import OAuthFlows
70+
from .oauth_flow import OAuthFlow
71+
from .security_requirement import SecurityRequirement
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Dict
2+
3+
4+
Callback = Dict[str, "PathItem"]
5+
"""
6+
A map of possible out-of band callbacks related to the parent operation.
7+
Each value in the map is a [Path Item Object](#pathItemObject)
8+
that describes a set of requests that may be initiated by the API provider and the expected responses.
9+
The key value used to identify the path item object is an expression, evaluated at runtime,
10+
that identifies a URL to use for the callback operation.
11+
"""
12+
13+
"""Patterned Fields"""
14+
15+
# {expression}: 'PathItem' = ...
16+
"""
17+
A Path Item Object used to define a callback request and expected responses.
18+
19+
A [complete example](../examples/v3.0/callback-example.yaml) is available.
20+
"""

openapi_python_client/schema/openapi_schema_pydantic/components.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from typing import Dict, Optional, Union
22

3-
from pydantic import BaseModel
3+
from pydantic import BaseModel, Extra
44

5+
from .callback import Callback
56
from .example import Example
67
from .header import Header
78
from .link import Link
@@ -44,7 +45,11 @@ class Components(BaseModel):
4445
links: Optional[Dict[str, Union[Link, Reference]]] = None
4546
"""An object to hold reusable [Link Objects](#linkObject)."""
4647

48+
callbacks: Optional[Dict[str, Union[Callback, Reference]]] = None
49+
"""An object to hold reusable [Callback Objects](#callbackObject)."""
50+
4751
class Config:
52+
extra = Extra.forbid
4853
schema_extra = {
4954
"examples": [
5055
{

openapi_python_client/schema/openapi_schema_pydantic/contact.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22

3-
from pydantic import AnyUrl, BaseModel
3+
from pydantic import AnyUrl, BaseModel, Extra
44

55

66
class Contact(BaseModel):
@@ -26,6 +26,7 @@ class Contact(BaseModel):
2626
"""
2727

2828
class Config:
29+
extra = Extra.forbid
2930
schema_extra = {
3031
"examples": [
3132
{"name": "API Support", "url": "http://www.example.com/support", "email": "[email protected]"}

openapi_python_client/schema/openapi_schema_pydantic/discriminator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Dict, Optional
22

3-
from pydantic import BaseModel
3+
from pydantic import BaseModel, Extra
44

55

66
class Discriminator(BaseModel):
@@ -14,7 +14,7 @@ class Discriminator(BaseModel):
1414
When using the discriminator, _inline_ schemas will not be considered.
1515
"""
1616

17-
propertyName: str
17+
propertyName: str = ...
1818
"""
1919
**REQUIRED**. The name of the property in the payload that will hold the discriminator value.
2020
"""
@@ -25,6 +25,7 @@ class Discriminator(BaseModel):
2525
"""
2626

2727
class Config:
28+
extra = Extra.forbid
2829
schema_extra = {
2930
"examples": [
3031
{

openapi_python_client/schema/openapi_schema_pydantic/encoding.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Dict, Optional
1+
from typing import Dict, Optional, Union
22

3-
from pydantic import BaseModel
3+
from pydantic import BaseModel, Extra
44

55
from .reference import Reference
66

@@ -12,28 +12,28 @@ class Encoding(BaseModel):
1212
"""
1313
The Content-Type for encoding a specific property.
1414
Default value depends on the property type:
15-
15+
1616
- for `string` with `format` being `binary` – `application/octet-stream`;
1717
- for other primitive types – `text/plain`;
1818
- for `object` - `application/json`;
1919
- for `array` – the default is defined based on the inner type.
20-
20+
2121
The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`),
2222
or a comma-separated list of the two types.
2323
"""
2424

25-
headers: Optional[Dict[str, Reference]] = None
25+
headers: Optional[Dict[str, Union["Header", Reference]]] = None
2626
"""
2727
A map allowing additional information to be provided as headers, for example `Content-Disposition`.
28-
28+
2929
`Content-Type` is described separately and SHALL be ignored in this section.
3030
This property SHALL be ignored if the request body media type is not a `multipart`.
3131
"""
3232

3333
style: Optional[str] = None
3434
"""
3535
Describes how a specific property value will be serialized depending on its type.
36-
36+
3737
See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property.
3838
The behavior follows the same values as `query` parameters, including default values.
3939
This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
@@ -43,7 +43,7 @@ class Encoding(BaseModel):
4343
"""
4444
When this is true, property values of type `array` or `object` generate separate parameters
4545
for each value of the array, or key-value-pair of the map.
46-
46+
4747
For other types of properties this property has no effect.
4848
When [`style`](#encodingStyle) is `form`, the default value is `true`.
4949
For all other styles, the default value is `false`.
@@ -60,6 +60,7 @@ class Encoding(BaseModel):
6060
"""
6161

6262
class Config:
63+
extra = Extra.forbid
6364
schema_extra = {
6465
"examples": [
6566
{

openapi_python_client/schema/openapi_schema_pydantic/example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, Optional
22

3-
from pydantic import BaseModel
3+
from pydantic import BaseModel, Extra
44

55

66
class Example(BaseModel):
@@ -28,11 +28,12 @@ class Example(BaseModel):
2828
"""
2929
A URL that points to the literal example.
3030
This provides the capability to reference examples that cannot easily be included in JSON or YAML documents.
31-
31+
3232
The `value` field and `externalValue` field are mutually exclusive.
3333
"""
3434

3535
class Config:
36+
extra = Extra.forbid
3637
schema_extra = {
3738
"examples": [
3839
{"summary": "A foo example", "value": {"foo": "bar"}},

openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
22

3-
from pydantic import AnyUrl, BaseModel
3+
from pydantic import AnyUrl, BaseModel, Extra
44

55

66
class ExternalDocumentation(BaseModel):
@@ -12,11 +12,12 @@ class ExternalDocumentation(BaseModel):
1212
[CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
1313
"""
1414

15-
url: AnyUrl
15+
url: AnyUrl = ...
1616
"""
1717
**REQUIRED**. The URL for the target documentation.
1818
Value MUST be in the format of a URL.
1919
"""
2020

2121
class Config:
22+
extra = Extra.forbid
2223
schema_extra = {"examples": [{"description": "Find more info here", "url": "https://example.com"}]}

openapi_python_client/schema/openapi_schema_pydantic/header.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic import Field
1+
from pydantic import Extra, Field
22

33
from ..parameter_location import ParameterLocation
44
from .parameter import Parameter
@@ -18,6 +18,7 @@ class Header(Parameter):
1818
param_in = Field(default=ParameterLocation.HEADER, const=True, alias="in")
1919

2020
class Config:
21+
extra = Extra.forbid
2122
allow_population_by_field_name = True
2223
schema_extra = {
2324
"examples": [

0 commit comments

Comments
 (0)