openapi-python-client 0.29.0__py3-none-any.whl → 0.29.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. openapi_python_client/__init__.py +26 -17
  2. openapi_python_client/cli.py +1 -2
  3. openapi_python_client/config.py +3 -1
  4. openapi_python_client/parser/bodies.py +8 -7
  5. openapi_python_client/parser/openapi.py +58 -48
  6. openapi_python_client/parser/properties/__init__.py +34 -33
  7. openapi_python_client/parser/properties/any.py +11 -10
  8. openapi_python_client/parser/properties/boolean.py +13 -13
  9. openapi_python_client/parser/properties/const.py +11 -10
  10. openapi_python_client/parser/properties/date.py +12 -11
  11. openapi_python_client/parser/properties/datetime.py +12 -11
  12. openapi_python_client/parser/properties/enum_property.py +23 -20
  13. openapi_python_client/parser/properties/file.py +11 -10
  14. openapi_python_client/parser/properties/float.py +13 -13
  15. openapi_python_client/parser/properties/int.py +11 -11
  16. openapi_python_client/parser/properties/list_property.py +22 -22
  17. openapi_python_client/parser/properties/literal_enum_property.py +20 -20
  18. openapi_python_client/parser/properties/merge_properties.py +9 -6
  19. openapi_python_client/parser/properties/model_property.py +34 -33
  20. openapi_python_client/parser/properties/none.py +11 -11
  21. openapi_python_client/parser/properties/protocol.py +42 -32
  22. openapi_python_client/parser/properties/schemas.py +30 -23
  23. openapi_python_client/parser/properties/string.py +10 -11
  24. openapi_python_client/parser/properties/union.py +24 -22
  25. openapi_python_client/parser/properties/uuid.py +11 -11
  26. openapi_python_client/parser/responses.py +30 -23
  27. openapi_python_client/schema/__init__.py +2 -1
  28. openapi_python_client/schema/openapi_schema_pydantic/callback.py +3 -1
  29. openapi_python_client/schema/openapi_schema_pydantic/components.py +10 -9
  30. openapi_python_client/schema/openapi_schema_pydantic/contact.py +5 -3
  31. openapi_python_client/schema/openapi_schema_pydantic/discriminator.py +4 -2
  32. openapi_python_client/schema/openapi_schema_pydantic/encoding.py +4 -3
  33. openapi_python_client/schema/openapi_schema_pydantic/example.py +5 -3
  34. openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py +4 -2
  35. openapi_python_client/schema/openapi_schema_pydantic/header.py +20 -6
  36. openapi_python_client/schema/openapi_schema_pydantic/info.py +5 -4
  37. openapi_python_client/schema/openapi_schema_pydantic/license.py +4 -2
  38. openapi_python_client/schema/openapi_schema_pydantic/link.py +5 -4
  39. openapi_python_client/schema/openapi_schema_pydantic/media_type.py +3 -2
  40. openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py +6 -4
  41. openapi_python_client/schema/openapi_schema_pydantic/open_api.py +5 -3
  42. openapi_python_client/schema/openapi_schema_pydantic/operation.py +6 -5
  43. openapi_python_client/schema/openapi_schema_pydantic/parameter.py +6 -5
  44. openapi_python_client/schema/openapi_schema_pydantic/path_item.py +5 -3
  45. openapi_python_client/schema/openapi_schema_pydantic/paths.py +2 -1
  46. openapi_python_client/schema/openapi_schema_pydantic/reference.py +3 -1
  47. openapi_python_client/schema/openapi_schema_pydantic/request_body.py +3 -2
  48. openapi_python_client/schema/openapi_schema_pydantic/response.py +5 -4
  49. openapi_python_client/schema/openapi_schema_pydantic/responses.py +2 -1
  50. openapi_python_client/schema/openapi_schema_pydantic/schema.py +7 -6
  51. openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py +3 -1
  52. openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py +8 -7
  53. openapi_python_client/schema/openapi_schema_pydantic/server.py +4 -3
  54. openapi_python_client/schema/openapi_schema_pydantic/server_variable.py +5 -3
  55. openapi_python_client/schema/openapi_schema_pydantic/tag.py +3 -2
  56. openapi_python_client/schema/openapi_schema_pydantic/xml.py +5 -3
  57. openapi_python_client/schema/ref.py +52 -0
  58. openapi_python_client/schema/untrusted_string.py +56 -0
  59. openapi_python_client/strings.py +245 -0
  60. openapi_python_client/templates/README.md.jinja +3 -3
  61. openapi_python_client/templates/client.py.jinja +5 -5
  62. openapi_python_client/templates/endpoint_macros.py.jinja +18 -18
  63. openapi_python_client/templates/endpoint_module.py.jinja +13 -13
  64. openapi_python_client/templates/helpers.jinja +3 -7
  65. openapi_python_client/templates/literal_enum.py.jinja +1 -1
  66. openapi_python_client/templates/model.py.jinja +18 -18
  67. openapi_python_client/templates/package_init.py.jinja +2 -2
  68. openapi_python_client/templates/property_templates/const_property.py.jinja +3 -3
  69. openapi_python_client/templates/property_templates/date_property.py.jinja +1 -1
  70. openapi_python_client/templates/property_templates/datetime_property.py.jinja +1 -1
  71. openapi_python_client/templates/property_templates/enum_property.py.jinja +1 -1
  72. openapi_python_client/templates/property_templates/file_property.py.jinja +1 -1
  73. openapi_python_client/templates/property_templates/list_property.py.jinja +3 -3
  74. openapi_python_client/templates/property_templates/literal_enum_property.py.jinja +2 -2
  75. openapi_python_client/templates/property_templates/model_property.py.jinja +1 -1
  76. openapi_python_client/templates/property_templates/property_macros.py.jinja +1 -1
  77. openapi_python_client/templates/property_templates/union_property.py.jinja +9 -9
  78. openapi_python_client/templates/property_templates/uuid_property.py.jinja +1 -1
  79. openapi_python_client/templates/pyproject_pdm.toml.jinja +2 -2
  80. openapi_python_client/templates/pyproject_poetry.toml.jinja +2 -2
  81. openapi_python_client/templates/pyproject_uv.toml.jinja +3 -3
  82. openapi_python_client/templates/setup.py.jinja +2 -2
  83. openapi_python_client/templates/str_enum.py.jinja +2 -2
  84. {openapi_python_client-0.29.0.dist-info → openapi_python_client-0.29.1.dist-info}/METADATA +4 -5
  85. openapi_python_client-0.29.1.dist-info/RECORD +115 -0
  86. {openapi_python_client-0.29.0.dist-info → openapi_python_client-0.29.1.dist-info}/WHEEL +1 -1
  87. openapi_python_client/utils.py +0 -122
  88. openapi_python_client-0.29.0.dist-info/RECORD +0 -113
  89. {openapi_python_client-0.29.0.dist-info → openapi_python_client-0.29.1.dist-info}/entry_points.txt +0 -0
  90. {openapi_python_client-0.29.0.dist-info → openapi_python_client-0.29.1.dist-info}/licenses/LICENSE +0 -0
@@ -5,12 +5,13 @@ from typing import TypedDict
5
5
 
6
6
  from attrs import define
7
7
 
8
- from openapi_python_client import utils
8
+ from openapi_python_client import strings
9
9
  from openapi_python_client.parser.properties.schemas import get_reference_simple_name, parse_reference_path
10
10
 
11
11
  from .. import Config
12
12
  from .. import schema as oai
13
- from ..utils import PythonIdentifier
13
+ from ..schema.untrusted_string import UntrustedString
14
+ from ..strings import PythonIdentifier
14
15
  from .errors import ParseError, PropertyError
15
16
  from .properties import AnyProperty, Property, Schemas, property_from_data
16
17
 
@@ -60,22 +61,23 @@ class HTTPStatusPattern:
60
61
  self.range = code_range
61
62
 
62
63
  @staticmethod
63
- def parse(pattern: str) -> "HTTPStatusPattern | ParseError":
64
+ def parse(pattern: UntrustedString) -> "HTTPStatusPattern | ParseError":
64
65
  """Parse a status code pattern such as 2XX or 404"""
65
- if pattern == "default":
66
- return HTTPStatusPattern(pattern=pattern, code_range=None)
66
+ untrusted = pattern.get_untrusted_value()
67
+ if untrusted == "default":
68
+ return HTTPStatusPattern(pattern=untrusted, code_range=None)
67
69
 
68
- if pattern.endswith("XX") and pattern[0].isdigit():
69
- first_digit = int(pattern[0])
70
- return HTTPStatusPattern(pattern=pattern, code_range=(first_digit * 100, first_digit * 100 + 99))
70
+ if len(untrusted) == 3 and untrusted.endswith("XX") and untrusted[0].isdigit():
71
+ first_digit = int(untrusted[0])
72
+ return HTTPStatusPattern(pattern=untrusted, code_range=(first_digit * 100, first_digit * 100 + 99))
71
73
 
72
74
  try:
73
- code = int(pattern)
74
- return HTTPStatusPattern(pattern=pattern, code_range=(code, code))
75
+ code = int(untrusted)
76
+ return HTTPStatusPattern(pattern=untrusted, code_range=(code, code))
75
77
  except ValueError:
76
78
  return ParseError(
77
79
  detail=(
78
- f"Invalid response status code pattern: {pattern}, response will be omitted from generated client"
80
+ f"Invalid response status code pattern: {untrusted}, response will be omitted from generated client"
79
81
  )
80
82
  )
81
83
 
@@ -129,7 +131,7 @@ class Response:
129
131
 
130
132
 
131
133
  def _source_by_content_type(content_type: str, config: Config) -> _ResponseSource | None:
132
- parsed_content_type = utils.get_content_type(content_type, config)
134
+ parsed_content_type = strings.get_content_type(content_type, config)
133
135
  if parsed_content_type is None:
134
136
  return None
135
137
 
@@ -150,7 +152,7 @@ def _source_by_content_type(content_type: str, config: Config) -> _ResponseSourc
150
152
  def empty_response(
151
153
  *,
152
154
  status_code: HTTPStatusPattern,
153
- response_name: str,
155
+ response_name: UntrustedString,
154
156
  config: Config,
155
157
  data: oai.Response | oai.Reference,
156
158
  ) -> Response:
@@ -175,23 +177,25 @@ def response_from_data( # noqa: PLR0911
175
177
  status_code: HTTPStatusPattern,
176
178
  data: oai.Response | oai.Reference,
177
179
  schemas: Schemas,
178
- responses: dict[str, oai.Response | oai.Reference],
180
+ responses: dict[UntrustedString, oai.Response | oai.Reference],
179
181
  parent_name: str,
180
182
  config: Config,
181
183
  ) -> tuple[Response | ParseError, Schemas]:
182
184
  """Generate a Response from the OpenAPI dictionary representation of it"""
183
185
 
184
- response_name = f"response_{status_code.pattern}"
186
+ response_name = UntrustedString(f"response_{status_code.pattern}")
185
187
  if isinstance(data, oai.Reference):
186
188
  ref_path = parse_reference_path(data.ref)
187
- if isinstance(ref_path, ParseError):
189
+ if isinstance(ref_path, ParseError): # pragma: no cover
188
190
  return ref_path, schemas
189
- if not ref_path.startswith("/components/responses/"):
190
- return ParseError(data=data, detail=f"$ref to {data.ref} not allowed in responses"), schemas
191
+ if not ref_path.startswith("/components/responses/"): # pragma: no cover
192
+ return ParseError(
193
+ data=data, detail=f"$ref to {data.ref.get_untrusted_value()} not allowed in responses"
194
+ ), schemas
191
195
  resp_data = responses.get(get_reference_simple_name(ref_path), None)
192
- if not resp_data:
193
- return ParseError(data=data, detail=f"Could not find reference: {data.ref}"), schemas
194
- if not isinstance(resp_data, oai.Response):
196
+ if not resp_data: # pragma: no cover
197
+ return ParseError(data=data, detail=f"Could not find reference: {data.ref.get_untrusted_value()}"), schemas
198
+ if not isinstance(resp_data, oai.Response): # pragma: no cover
195
199
  return ParseError(data=data, detail="Top-level $ref inside components/responses is not supported"), schemas
196
200
  data = resp_data
197
201
 
@@ -208,13 +212,16 @@ def response_from_data( # noqa: PLR0911
208
212
  )
209
213
 
210
214
  for content_type, media_type in content.items():
211
- source = _source_by_content_type(content_type, config)
215
+ source = _source_by_content_type(content_type.get_untrusted_value(), config)
212
216
  if source is not None:
213
217
  schema_data = media_type.media_type_schema
214
218
  break
215
219
  else:
216
220
  return (
217
- ParseError(data=data, detail=f"Unsupported content_type {content}"),
221
+ ParseError(
222
+ data=data,
223
+ detail=f"Unsupported content_type {', '.join(key.get_untrusted_value() for key in content)}",
224
+ ),
218
225
  schemas,
219
226
  )
220
227
 
@@ -4,7 +4,6 @@ __all__ = [
4
4
  "OpenAPI",
5
5
  "Operation",
6
6
  "Parameter",
7
- "Parameter",
8
7
  "ParameterLocation",
9
8
  "PathItem",
10
9
  "Reference",
@@ -12,6 +11,7 @@ __all__ = [
12
11
  "Response",
13
12
  "Responses",
14
13
  "Schema",
14
+ "UntrustedString",
15
15
  ]
16
16
 
17
17
 
@@ -29,3 +29,4 @@ from .openapi_schema_pydantic import (
29
29
  Schema,
30
30
  )
31
31
  from .parameter_location import ParameterLocation
32
+ from .untrusted_string import UntrustedString
@@ -1,11 +1,13 @@
1
1
  from typing import TYPE_CHECKING
2
2
 
3
+ from ..untrusted_string import UntrustedString
4
+
3
5
  if TYPE_CHECKING: # pragma: no cover
4
6
  from .path_item import PathItem
5
7
  else:
6
8
  PathItem = "PathItem"
7
9
 
8
- Callback = dict[str, PathItem]
10
+ Callback = dict[UntrustedString, PathItem]
9
11
  """
10
12
  A map of possible out-of band callbacks related to the parent operation.
11
13
  Each value in the map is a [Path Item Object](#pathItemObject)
@@ -1,5 +1,6 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from ..untrusted_string import UntrustedString
3
4
  from .callback import Callback
4
5
  from .example import Example
5
6
  from .header import Header
@@ -23,15 +24,15 @@ class Components(BaseModel):
23
24
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject
24
25
  """
25
26
 
26
- schemas: dict[str, ReferenceOr[Schema]] | None = None
27
- responses: dict[str, ReferenceOr[Response]] | None = None
28
- parameters: dict[str, ReferenceOr[Parameter]] | None = None
29
- examples: dict[str, ReferenceOr[Example]] | None = None
30
- requestBodies: dict[str, ReferenceOr[RequestBody]] | None = None
31
- headers: dict[str, ReferenceOr[Header]] | None = None
32
- securitySchemes: dict[str, ReferenceOr[SecurityScheme]] | None = None
33
- links: dict[str, ReferenceOr[Link]] | None = None
34
- callbacks: dict[str, ReferenceOr[Callback]] | None = None
27
+ schemas: dict[UntrustedString, ReferenceOr[Schema]] | None = None
28
+ responses: dict[UntrustedString, ReferenceOr[Response]] | None = None
29
+ parameters: dict[UntrustedString, ReferenceOr[Parameter]] | None = None
30
+ examples: dict[UntrustedString, ReferenceOr[Example]] | None = None
31
+ requestBodies: dict[UntrustedString, ReferenceOr[RequestBody]] | None = None
32
+ headers: dict[UntrustedString, ReferenceOr[Header]] | None = None
33
+ securitySchemes: dict[UntrustedString, ReferenceOr[SecurityScheme]] | None = None
34
+ links: dict[UntrustedString, ReferenceOr[Link]] | None = None
35
+ callbacks: dict[UntrustedString, ReferenceOr[Callback]] | None = None
35
36
  model_config = ConfigDict(
36
37
  # `Callback` contains an unresolvable forward reference, will rebuild in `__init__.py`:
37
38
  defer_build=True,
@@ -1,5 +1,7 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from openapi_python_client.schema.untrusted_string import UntrustedString
4
+
3
5
 
4
6
  class Contact(BaseModel):
5
7
  """
@@ -9,9 +11,9 @@ class Contact(BaseModel):
9
11
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#contactObject
10
12
  """
11
13
 
12
- name: str | None = None
13
- url: str | None = None
14
- email: str | None = None
14
+ name: UntrustedString | None = None
15
+ url: UntrustedString | None = None
16
+ email: UntrustedString | None = None
15
17
  model_config = ConfigDict(
16
18
  extra="allow",
17
19
  json_schema_extra={
@@ -1,5 +1,7 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from ..untrusted_string import UntrustedString
4
+
3
5
 
4
6
  class Discriminator(BaseModel):
5
7
  """
@@ -16,8 +18,8 @@ class Discriminator(BaseModel):
16
18
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminatorObject
17
19
  """
18
20
 
19
- propertyName: str
20
- mapping: dict[str, str] | None = None
21
+ propertyName: UntrustedString
22
+ mapping: dict[UntrustedString, UntrustedString] | None = None
21
23
  model_config = ConfigDict(
22
24
  extra="allow",
23
25
  json_schema_extra={
@@ -2,6 +2,7 @@ from typing import TYPE_CHECKING
2
2
 
3
3
  from pydantic import BaseModel, ConfigDict
4
4
 
5
+ from ..untrusted_string import UntrustedString
5
6
  from .reference import ReferenceOr
6
7
 
7
8
  if TYPE_CHECKING: # pragma: no cover
@@ -16,9 +17,9 @@ class Encoding(BaseModel):
16
17
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#encodingObject
17
18
  """
18
19
 
19
- contentType: str | None = None
20
- headers: dict[str, ReferenceOr["Header"]] | None = None
21
- style: str | None = None
20
+ contentType: UntrustedString | None = None
21
+ headers: dict[UntrustedString, ReferenceOr["Header"]] | None = None
22
+ style: UntrustedString | None = None
22
23
  explode: bool = False
23
24
  allowReserved: bool = False
24
25
  model_config = ConfigDict(
@@ -2,6 +2,8 @@ from typing import Any
2
2
 
3
3
  from pydantic import BaseModel, ConfigDict
4
4
 
5
+ from ..untrusted_string import UntrustedString
6
+
5
7
 
6
8
  class Example(BaseModel):
7
9
  """Examples added to parameters / components to help clarify usage.
@@ -11,10 +13,10 @@ class Example(BaseModel):
11
13
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject
12
14
  """
13
15
 
14
- summary: str | None = None
15
- description: str | None = None
16
+ summary: UntrustedString | None = None
17
+ description: UntrustedString | None = None
16
18
  value: Any | None = None
17
- externalValue: str | None = None
19
+ externalValue: UntrustedString | None = None
18
20
  model_config = ConfigDict(
19
21
  extra="allow",
20
22
  json_schema_extra={
@@ -1,5 +1,7 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from openapi_python_client.schema.untrusted_string import UntrustedString
4
+
3
5
 
4
6
  class ExternalDocumentation(BaseModel):
5
7
  """Allows referencing an external resource for extended documentation.
@@ -8,8 +10,8 @@ class ExternalDocumentation(BaseModel):
8
10
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#externalDocumentationObject
9
11
  """
10
12
 
11
- description: str | None = None
12
- url: str
13
+ description: UntrustedString | None = None
14
+ url: UntrustedString
13
15
  model_config = ConfigDict(
14
16
  extra="allow",
15
17
  json_schema_extra={"examples": [{"description": "Find more info here", "url": "https://example.com"}]},
@@ -1,10 +1,15 @@
1
- from pydantic import ConfigDict, Field
1
+ from typing import Any
2
2
 
3
- from ..parameter_location import ParameterLocation
4
- from .parameter import Parameter
3
+ from pydantic import BaseModel, ConfigDict, Field
5
4
 
5
+ from ..untrusted_string import UntrustedString
6
+ from .example import Example
7
+ from .media_type import MediaType
8
+ from .reference import ReferenceOr
9
+ from .schema import Schema
6
10
 
7
- class Header(Parameter):
11
+
12
+ class Header(BaseModel):
8
13
  """
9
14
  The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes:
10
15
 
@@ -18,8 +23,17 @@ class Header(Parameter):
18
23
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#headerObject
19
24
  """
20
25
 
21
- name: str = Field(default="")
22
- param_in: ParameterLocation = Field(default=ParameterLocation.HEADER, alias="in")
26
+ description: UntrustedString | None = None
27
+ required: bool = False
28
+ deprecated: bool = False
29
+ allowEmptyValue: bool = False
30
+ style: UntrustedString | None = None
31
+ explode: bool = False
32
+ allowReserved: bool = False
33
+ param_schema: ReferenceOr[Schema] | None = Field(default=None, alias="schema")
34
+ example: Any | None = None
35
+ examples: dict[UntrustedString, ReferenceOr[Example]] | None = None
36
+ content: dict[UntrustedString, MediaType] | None = None
23
37
  model_config = ConfigDict(
24
38
  # `Parameter` is not build yet, will rebuild in `__init__.py`:
25
39
  defer_build=True,
@@ -1,5 +1,6 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from ..untrusted_string import UntrustedString
3
4
  from .contact import Contact
4
5
  from .license import License
5
6
 
@@ -15,12 +16,12 @@ class Info(BaseModel):
15
16
  -https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#infoObject
16
17
  """
17
18
 
18
- title: str
19
- description: str | None = None
20
- termsOfService: str | None = None
19
+ title: UntrustedString
20
+ description: UntrustedString | None = None
21
+ termsOfService: UntrustedString | None = None
21
22
  contact: Contact | None = None
22
23
  license: License | None = None
23
- version: str
24
+ version: UntrustedString
24
25
  model_config = ConfigDict(
25
26
  extra="allow",
26
27
  json_schema_extra={
@@ -1,5 +1,7 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from ..untrusted_string import UntrustedString
4
+
3
5
 
4
6
  class License(BaseModel):
5
7
  """
@@ -9,8 +11,8 @@ class License(BaseModel):
9
11
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#licenseObject
10
12
  """
11
13
 
12
- name: str
13
- url: str | None = None
14
+ name: UntrustedString
15
+ url: UntrustedString | None = None
14
16
  model_config = ConfigDict(
15
17
  extra="allow",
16
18
  json_schema_extra={
@@ -2,6 +2,7 @@ from typing import Any
2
2
 
3
3
  from pydantic import BaseModel, ConfigDict
4
4
 
5
+ from ..untrusted_string import UntrustedString
5
6
  from .server import Server
6
7
 
7
8
 
@@ -23,11 +24,11 @@ class Link(BaseModel):
23
24
  - https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#linkObject
24
25
  """
25
26
 
26
- operationRef: str | None = None
27
- operationId: str | None = None
28
- parameters: dict[str, Any] | None = None
27
+ operationRef: UntrustedString | None = None
28
+ operationId: UntrustedString | None = None
29
+ parameters: dict[UntrustedString, Any] | None = None
29
30
  requestBody: Any | None = None
30
- description: str | None = None
31
+ description: UntrustedString | None = None
31
32
  server: Server | None = None
32
33
  model_config = ConfigDict(
33
34
  extra="allow",
@@ -2,6 +2,7 @@ from typing import Any
2
2
 
3
3
  from pydantic import BaseModel, ConfigDict, Field
4
4
 
5
+ from ..untrusted_string import UntrustedString
5
6
  from .encoding import Encoding
6
7
  from .example import Example
7
8
  from .reference import ReferenceOr
@@ -18,8 +19,8 @@ class MediaType(BaseModel):
18
19
 
19
20
  media_type_schema: ReferenceOr[Schema] | None = Field(default=None, alias="schema")
20
21
  example: Any | None = None
21
- examples: dict[str, ReferenceOr[Example]] | None = None
22
- encoding: dict[str, Encoding] | None = None
22
+ examples: dict[UntrustedString, ReferenceOr[Example]] | None = None
23
+ encoding: dict[UntrustedString, Encoding] | None = None
23
24
  model_config = ConfigDict(
24
25
  # `Encoding` is not build yet, will rebuild in `__init__.py`:
25
26
  defer_build=True,
@@ -1,5 +1,7 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from ..untrusted_string import UntrustedString
4
+
3
5
 
4
6
  class OAuthFlow(BaseModel):
5
7
  """
@@ -10,10 +12,10 @@ class OAuthFlow(BaseModel):
10
12
  - https://swagger.io/docs/specification/authentication/oauth2/
11
13
  """
12
14
 
13
- authorizationUrl: str | None = None
14
- tokenUrl: str | None = None
15
- refreshUrl: str | None = None
16
- scopes: dict[str, str]
15
+ authorizationUrl: UntrustedString | None = None
16
+ tokenUrl: UntrustedString | None = None
17
+ refreshUrl: UntrustedString | None = None
18
+ scopes: dict[UntrustedString, UntrustedString]
17
19
  model_config = ConfigDict(
18
20
  extra="allow",
19
21
  json_schema_extra={
@@ -1,5 +1,6 @@
1
1
  from pydantic import BaseModel, ConfigDict, field_validator
2
2
 
3
+ from ..untrusted_string import UntrustedString
3
4
  from .components import Components
4
5
  from .external_documentation import ExternalDocumentation
5
6
  from .info import Info
@@ -26,7 +27,7 @@ class OpenAPI(BaseModel):
26
27
  security: list[SecurityRequirement] | None = None
27
28
  tags: list[Tag] | None = None
28
29
  externalDocs: ExternalDocumentation | None = None
29
- openapi: str
30
+ openapi: UntrustedString
30
31
  model_config = ConfigDict(
31
32
  # `Components` is not build yet, will rebuild in `__init__.py`:
32
33
  defer_build=True,
@@ -35,8 +36,9 @@ class OpenAPI(BaseModel):
35
36
 
36
37
  @field_validator("openapi")
37
38
  @classmethod
38
- def check_openapi_version(cls, value: str) -> str:
39
+ def check_openapi_version(cls, untrusted: UntrustedString) -> UntrustedString:
39
40
  """Validates that the declared OpenAPI version is a supported one"""
41
+ value = untrusted.get_untrusted_value()
40
42
  parts = value.split(".")
41
43
  if len(parts) != NUM_SEMVER_PARTS:
42
44
  raise ValueError(f"Invalid OpenAPI version {value}")
@@ -44,4 +46,4 @@ class OpenAPI(BaseModel):
44
46
  raise ValueError(f"Only OpenAPI versions 3.* are supported, got {value}")
45
47
  if int(parts[1]) > 1:
46
48
  raise ValueError(f"Only OpenAPI versions 3.1.* are supported, got {value}")
47
- return value
49
+ return untrusted
@@ -1,5 +1,6 @@
1
1
  from pydantic import BaseModel, ConfigDict, Field
2
2
 
3
+ from ..untrusted_string import UntrustedString
3
4
  from .callback import Callback
4
5
  from .external_documentation import ExternalDocumentation
5
6
  from .parameter import Parameter
@@ -18,15 +19,15 @@ class Operation(BaseModel):
18
19
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operationObject
19
20
  """
20
21
 
21
- tags: list[str] | None = None
22
- summary: str | None = None
23
- description: str | None = None
22
+ tags: list[UntrustedString] | None = None
23
+ summary: UntrustedString | None = None
24
+ description: UntrustedString | None = None
24
25
  externalDocs: ExternalDocumentation | None = None
25
- operationId: str | None = None
26
+ operationId: UntrustedString | None = None
26
27
  parameters: list[ReferenceOr[Parameter]] | None = None
27
28
  request_body: ReferenceOr[RequestBody] | None = Field(None, alias="requestBody")
28
29
  responses: Responses
29
- callbacks: dict[str, Callback] | None = None
30
+ callbacks: dict[UntrustedString, Callback] | None = None
30
31
 
31
32
  deprecated: bool = False
32
33
  security: list[SecurityRequirement] | None = None
@@ -3,6 +3,7 @@ from typing import Any
3
3
  from pydantic import BaseModel, ConfigDict, Field
4
4
 
5
5
  from ..parameter_location import ParameterLocation
6
+ from ..untrusted_string import UntrustedString
6
7
  from .example import Example
7
8
  from .media_type import MediaType
8
9
  from .reference import ReferenceOr
@@ -21,19 +22,19 @@ class Parameter(BaseModel):
21
22
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject
22
23
  """
23
24
 
24
- name: str
25
+ name: UntrustedString
25
26
  param_in: ParameterLocation = Field(alias="in")
26
- description: str | None = None
27
+ description: UntrustedString | None = None
27
28
  required: bool = False
28
29
  deprecated: bool = False
29
30
  allowEmptyValue: bool = False
30
- style: str | None = None
31
+ style: UntrustedString | None = None
31
32
  explode: bool = False
32
33
  allowReserved: bool = False
33
34
  param_schema: ReferenceOr[Schema] | None = Field(default=None, alias="schema")
34
35
  example: Any | None = None
35
- examples: dict[str, ReferenceOr[Example]] | None = None
36
- content: dict[str, MediaType] | None = None
36
+ examples: dict[UntrustedString, ReferenceOr[Example]] | None = None
37
+ content: dict[UntrustedString, MediaType] | None = None
37
38
  model_config = ConfigDict(
38
39
  # `MediaType` is not build yet, will rebuild in `__init__.py`:
39
40
  defer_build=True,
@@ -2,6 +2,8 @@ from typing import TYPE_CHECKING
2
2
 
3
3
  from pydantic import BaseModel, ConfigDict, Field
4
4
 
5
+ from ..ref import Ref
6
+ from ..untrusted_string import UntrustedString
5
7
  from .parameter import Parameter
6
8
  from .reference import ReferenceOr
7
9
  from .server import Server
@@ -22,9 +24,9 @@ class PathItem(BaseModel):
22
24
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#pathItemObject
23
25
  """
24
26
 
25
- ref: str | None = Field(default=None, alias="$ref")
26
- summary: str | None = None
27
- description: str | None = None
27
+ ref: Ref | None = Field(default=None, alias="$ref")
28
+ summary: UntrustedString | None = None
29
+ description: UntrustedString | None = None
28
30
  get: "Operation | None" = None
29
31
  put: "Operation | None" = None
30
32
  post: "Operation | None" = None
@@ -1,6 +1,7 @@
1
+ from ..untrusted_string import UntrustedString
1
2
  from .path_item import PathItem
2
3
 
3
- Paths = dict[str, PathItem]
4
+ Paths = dict[UntrustedString, PathItem]
4
5
  """
5
6
  Holds the relative paths to the individual endpoints and their operations.
6
7
  The path is appended to the URL from the [`Server Object`](#serverObject) in order to construct the full URL.
@@ -2,6 +2,8 @@ from typing import Annotated, Any, Literal, TypeAlias, TypeVar
2
2
 
3
3
  from pydantic import BaseModel, ConfigDict, Discriminator, Field, Tag
4
4
 
5
+ from openapi_python_client.schema.ref import Ref
6
+
5
7
 
6
8
  class Reference(BaseModel):
7
9
  """
@@ -18,7 +20,7 @@ class Reference(BaseModel):
18
20
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#referenceObject
19
21
  """
20
22
 
21
- ref: str = Field(alias="$ref")
23
+ ref: Ref = Field(alias="$ref")
22
24
  model_config = ConfigDict(
23
25
  extra="allow",
24
26
  populate_by_name=True,
@@ -1,5 +1,6 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from ..untrusted_string import UntrustedString
3
4
  from .media_type import MediaType
4
5
 
5
6
 
@@ -11,8 +12,8 @@ class RequestBody(BaseModel):
11
12
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#requestBodyObject
12
13
  """
13
14
 
14
- description: str | None = None
15
- content: dict[str, MediaType]
15
+ description: UntrustedString | None = None
16
+ content: dict[UntrustedString, MediaType]
16
17
  required: bool = False
17
18
  model_config = ConfigDict(
18
19
  # `MediaType` is not build yet, will rebuild in `__init__.py`:
@@ -1,5 +1,6 @@
1
1
  from pydantic import BaseModel, ConfigDict
2
2
 
3
+ from ..untrusted_string import UntrustedString
3
4
  from .header import Header
4
5
  from .link import Link
5
6
  from .media_type import MediaType
@@ -16,10 +17,10 @@ class Response(BaseModel):
16
17
  - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responseObject
17
18
  """
18
19
 
19
- description: str
20
- headers: dict[str, ReferenceOr[Header]] | None = None
21
- content: dict[str, MediaType] | None = None
22
- links: dict[str, ReferenceOr[Link]] | None = None
20
+ description: UntrustedString
21
+ headers: dict[UntrustedString, ReferenceOr[Header]] | None = None
22
+ content: dict[UntrustedString, MediaType] | None = None
23
+ links: dict[UntrustedString, ReferenceOr[Link]] | None = None
23
24
  model_config = ConfigDict(
24
25
  # `MediaType` is not build yet, will rebuild in `__init__.py`:
25
26
  defer_build=True,
@@ -1,7 +1,8 @@
1
+ from ..untrusted_string import UntrustedString
1
2
  from .reference import ReferenceOr
2
3
  from .response import Response
3
4
 
4
- Responses = dict[str, ReferenceOr[Response]]
5
+ Responses = dict[UntrustedString, ReferenceOr[Response]]
5
6
  """
6
7
  A container for the expected responses of an operation.
7
8
  The container maps a HTTP response code to the expected response.