openapi-python-client 0.28.4__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 (92) hide show
  1. openapi_python_client/__init__.py +26 -17
  2. openapi_python_client/cli.py +1 -2
  3. openapi_python_client/config.py +5 -3
  4. openapi_python_client/parser/bodies.py +14 -23
  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 +15 -14
  11. openapi_python_client/parser/properties/datetime.py +15 -14
  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/data_type.py +2 -2
  29. openapi_python_client/schema/openapi_schema_pydantic/callback.py +3 -1
  30. openapi_python_client/schema/openapi_schema_pydantic/components.py +10 -9
  31. openapi_python_client/schema/openapi_schema_pydantic/contact.py +5 -3
  32. openapi_python_client/schema/openapi_schema_pydantic/discriminator.py +4 -2
  33. openapi_python_client/schema/openapi_schema_pydantic/encoding.py +4 -3
  34. openapi_python_client/schema/openapi_schema_pydantic/example.py +5 -3
  35. openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py +4 -2
  36. openapi_python_client/schema/openapi_schema_pydantic/header.py +20 -6
  37. openapi_python_client/schema/openapi_schema_pydantic/info.py +5 -4
  38. openapi_python_client/schema/openapi_schema_pydantic/license.py +4 -2
  39. openapi_python_client/schema/openapi_schema_pydantic/link.py +5 -4
  40. openapi_python_client/schema/openapi_schema_pydantic/media_type.py +3 -2
  41. openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py +6 -4
  42. openapi_python_client/schema/openapi_schema_pydantic/open_api.py +5 -3
  43. openapi_python_client/schema/openapi_schema_pydantic/operation.py +6 -5
  44. openapi_python_client/schema/openapi_schema_pydantic/parameter.py +6 -5
  45. openapi_python_client/schema/openapi_schema_pydantic/path_item.py +5 -3
  46. openapi_python_client/schema/openapi_schema_pydantic/paths.py +2 -1
  47. openapi_python_client/schema/openapi_schema_pydantic/reference.py +3 -1
  48. openapi_python_client/schema/openapi_schema_pydantic/request_body.py +3 -2
  49. openapi_python_client/schema/openapi_schema_pydantic/response.py +5 -4
  50. openapi_python_client/schema/openapi_schema_pydantic/responses.py +2 -1
  51. openapi_python_client/schema/openapi_schema_pydantic/schema.py +7 -6
  52. openapi_python_client/schema/openapi_schema_pydantic/security_requirement.py +3 -1
  53. openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py +8 -7
  54. openapi_python_client/schema/openapi_schema_pydantic/server.py +4 -3
  55. openapi_python_client/schema/openapi_schema_pydantic/server_variable.py +5 -3
  56. openapi_python_client/schema/openapi_schema_pydantic/tag.py +3 -2
  57. openapi_python_client/schema/openapi_schema_pydantic/xml.py +5 -3
  58. openapi_python_client/schema/parameter_location.py +7 -22
  59. openapi_python_client/schema/ref.py +52 -0
  60. openapi_python_client/schema/untrusted_string.py +56 -0
  61. openapi_python_client/strings.py +245 -0
  62. openapi_python_client/templates/README.md.jinja +3 -3
  63. openapi_python_client/templates/client.py.jinja +5 -5
  64. openapi_python_client/templates/endpoint_macros.py.jinja +18 -18
  65. openapi_python_client/templates/endpoint_module.py.jinja +20 -14
  66. openapi_python_client/templates/helpers.jinja +3 -7
  67. openapi_python_client/templates/literal_enum.py.jinja +3 -3
  68. openapi_python_client/templates/model.py.jinja +18 -18
  69. openapi_python_client/templates/package_init.py.jinja +2 -2
  70. openapi_python_client/templates/property_templates/const_property.py.jinja +3 -3
  71. openapi_python_client/templates/property_templates/date_property.py.jinja +2 -2
  72. openapi_python_client/templates/property_templates/datetime_property.py.jinja +2 -2
  73. openapi_python_client/templates/property_templates/enum_property.py.jinja +1 -1
  74. openapi_python_client/templates/property_templates/file_property.py.jinja +1 -1
  75. openapi_python_client/templates/property_templates/list_property.py.jinja +3 -3
  76. openapi_python_client/templates/property_templates/literal_enum_property.py.jinja +2 -2
  77. openapi_python_client/templates/property_templates/model_property.py.jinja +1 -1
  78. openapi_python_client/templates/property_templates/property_macros.py.jinja +1 -1
  79. openapi_python_client/templates/property_templates/union_property.py.jinja +9 -9
  80. openapi_python_client/templates/property_templates/uuid_property.py.jinja +1 -1
  81. openapi_python_client/templates/pyproject_pdm.toml.jinja +4 -5
  82. openapi_python_client/templates/pyproject_poetry.toml.jinja +4 -5
  83. openapi_python_client/templates/pyproject_uv.toml.jinja +5 -6
  84. openapi_python_client/templates/setup.py.jinja +4 -4
  85. openapi_python_client/templates/str_enum.py.jinja +2 -2
  86. {openapi_python_client-0.28.4.dist-info → openapi_python_client-0.29.1.dist-info}/METADATA +6 -9
  87. openapi_python_client-0.29.1.dist-info/RECORD +115 -0
  88. {openapi_python_client-0.28.4.dist-info → openapi_python_client-0.29.1.dist-info}/WHEEL +1 -1
  89. openapi_python_client/utils.py +0 -122
  90. openapi_python_client-0.28.4.dist-info/RECORD +0 -113
  91. {openapi_python_client-0.28.4.dist-info → openapi_python_client-0.29.1.dist-info}/entry_points.txt +0 -0
  92. {openapi_python_client-0.28.4.dist-info → openapi_python_client-0.29.1.dist-info}/licenses/LICENSE +0 -0
@@ -4,13 +4,13 @@ from collections.abc import Iterator
4
4
  from itertools import chain
5
5
  from typing import Any, ClassVar, cast
6
6
 
7
- from attr import define, evolve
7
+ from attr import define, evolve, field
8
8
 
9
- from ... import Config
9
+ from ... import Config, strings
10
10
  from ... import schema as oai
11
- from ...utils import PythonIdentifier
11
+ from ...strings import PythonIdentifier
12
12
  from ..errors import ParseError, PropertyError
13
- from .protocol import PropertyProtocol, Value
13
+ from .protocol import PropertyProtocol, Value, convert_example
14
14
  from .schemas import Schemas
15
15
 
16
16
 
@@ -18,12 +18,12 @@ from .schemas import Schemas
18
18
  class UnionProperty(PropertyProtocol):
19
19
  """A property representing a Union (anyOf) of other properties"""
20
20
 
21
- name: str
21
+ name: oai.UntrustedString
22
22
  required: bool
23
23
  default: Value | None
24
24
  python_name: PythonIdentifier
25
- description: str | None
26
- example: str | None
25
+ description: oai.UntrustedString | None
26
+ example: oai.UntrustedString | None = field(converter=convert_example)
27
27
  inner_properties: list[PropertyProtocol]
28
28
  template: ClassVar[str] = "union_property.py.jinja"
29
29
 
@@ -32,7 +32,7 @@ class UnionProperty(PropertyProtocol):
32
32
  cls,
33
33
  *,
34
34
  data: oai.Schema,
35
- name: str,
35
+ name: oai.UntrustedString,
36
36
  required: bool,
37
37
  schemas: Schemas,
38
38
  parent_name: str,
@@ -70,12 +70,12 @@ class UnionProperty(PropertyProtocol):
70
70
  and sub_prop_data.title is not None
71
71
  and sub_prop_data.title != data.title
72
72
  ):
73
- subscript = sub_prop_data.title
73
+ subscript = sub_prop_data.title.get_untrusted_value()
74
74
  else:
75
75
  subscript = f"type_{i}"
76
76
 
77
77
  sub_prop, schemas = property_from_data(
78
- name=f"{name}_{subscript}",
78
+ name=oai.UntrustedString(f"{name.get_untrusted_value()}_{subscript}"),
79
79
  required=True,
80
80
  data=sub_prop_data,
81
81
  schemas=schemas,
@@ -120,7 +120,7 @@ class UnionProperty(PropertyProtocol):
120
120
  prop = evolve(prop, default=default_or_error)
121
121
  return prop, schemas
122
122
 
123
- def convert_value(self, value: Any) -> Value | None | PropertyError:
123
+ def convert_value(self, value: Any) -> Value | PropertyError | None:
124
124
  if value is None or isinstance(value, Value):
125
125
  return None
126
126
  value_or_error: Value | PropertyError | None = PropertyError(
@@ -132,7 +132,7 @@ class UnionProperty(PropertyProtocol):
132
132
  return value_or_error
133
133
  return value_or_error
134
134
 
135
- def _get_inner_type_strings(self, json: bool) -> set[str]:
135
+ def _get_inner_type_strings(self, json: bool) -> set[strings.PythonCode]:
136
136
  return {
137
137
  p.get_type_string(
138
138
  no_optional=True,
@@ -142,18 +142,19 @@ class UnionProperty(PropertyProtocol):
142
142
  }
143
143
 
144
144
  @staticmethod
145
- def _get_type_string_from_inner_type_strings(inner_types: set[str]) -> str:
145
+ def _get_type_string_from_inner_type_strings(inner_types: set[strings.PythonCode]) -> strings.PythonCode:
146
146
  if len(inner_types) == 1:
147
147
  return inner_types.pop()
148
- return " | ".join(sorted(inner_types, key=lambda x: x.lower()))
148
+ joined = " | ".join(sorted((t.as_unembedded_code() for t in inner_types), key=str.lower))
149
+ return strings.PythonCode(joined)
149
150
 
150
- def get_base_type_string(self) -> str:
151
+ def get_base_type_string(self) -> strings.PythonCode:
151
152
  return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=False))
152
153
 
153
- def get_base_json_type_string(self) -> str:
154
+ def get_base_json_type_string(self) -> strings.PythonCode:
154
155
  return self._get_type_string_from_inner_type_strings(self._get_inner_type_strings(json=True))
155
156
 
156
- def get_type_strings_in_union(self, *, no_optional: bool = False, json: bool) -> set[str]:
157
+ def get_type_strings_in_union(self, *, no_optional: bool = False, json: bool) -> set[strings.PythonCode]:
157
158
  """
158
159
  Get the set of all the types that should appear within the `Union` representing this property.
159
160
 
@@ -164,22 +165,22 @@ class UnionProperty(PropertyProtocol):
164
165
  json: If True, this returns the JSON types, not the Python types, of this property.
165
166
 
166
167
  Returns:
167
- A set of strings containing the types that should appear within `Union`.
168
+ A set of code snippets containing the types that should appear within `Union`.
168
169
  """
169
170
  type_strings = self._get_inner_type_strings(json=json)
170
171
  if no_optional:
171
172
  return type_strings
172
173
  if not self.required:
173
- type_strings.add("Unset")
174
+ type_strings.add(strings.PythonCode("Unset"))
174
175
  return type_strings
175
176
 
176
177
  def get_type_string(
177
178
  self,
178
179
  no_optional: bool = False,
179
180
  json: bool = False,
180
- ) -> str:
181
+ ) -> strings.PythonCode:
181
182
  """
182
- Get a string representation of type that should be used when declaring this property.
183
+ Get a Python code representation of type that should be used when declaring this property.
183
184
  This implementation differs slightly from `Property.get_type_string` in order to collapse
184
185
  nested union types.
185
186
  """
@@ -212,5 +213,6 @@ class UnionProperty(PropertyProtocol):
212
213
 
213
214
  for inner_prop in self.inner_properties:
214
215
  if evolve(cast(Property, inner_prop), required=self.required).validate_location(location) is not None:
215
- return ParseError(detail=f"{self.get_type_string()} is not allowed in {location}")
216
+ type_string = self.get_type_string().as_unembedded_code()
217
+ return ParseError(detail=f"{type_string} is not allowed in {location}")
216
218
  return None
@@ -3,24 +3,24 @@ from __future__ import annotations
3
3
  from typing import Any, ClassVar
4
4
  from uuid import UUID
5
5
 
6
- from attr import define
6
+ from attr import define, field
7
7
 
8
8
  from ... import schema as oai
9
- from ...utils import PythonIdentifier
9
+ from ...strings import PythonCode, PythonIdentifier
10
10
  from ..errors import PropertyError
11
- from .protocol import PropertyProtocol, Value
11
+ from .protocol import PropertyProtocol, Value, convert_example
12
12
 
13
13
 
14
14
  @define
15
15
  class UuidProperty(PropertyProtocol):
16
16
  """A property of type uuid.UUID"""
17
17
 
18
- name: str
18
+ name: oai.UntrustedString
19
19
  required: bool
20
20
  default: Value | None
21
21
  python_name: PythonIdentifier
22
- description: str | None
23
- example: str | None
22
+ description: oai.UntrustedString | None
23
+ example: oai.UntrustedString | None = field(converter=convert_example)
24
24
 
25
25
  _type_string: ClassVar[str] = "UUID"
26
26
  _json_type_string: ClassVar[str] = "str"
@@ -35,12 +35,12 @@ class UuidProperty(PropertyProtocol):
35
35
  @classmethod
36
36
  def build(
37
37
  cls,
38
- name: str,
38
+ name: oai.UntrustedString,
39
39
  required: bool,
40
40
  default: Any,
41
41
  python_name: PythonIdentifier,
42
- description: str | None,
43
- example: str | None,
42
+ description: oai.UntrustedString | None,
43
+ example: Any,
44
44
  ) -> UuidProperty | PropertyError:
45
45
  checked_default = cls.convert_value(default)
46
46
  if isinstance(checked_default, PropertyError):
@@ -56,7 +56,7 @@ class UuidProperty(PropertyProtocol):
56
56
  )
57
57
 
58
58
  @classmethod
59
- def convert_value(cls, value: Any) -> Value | None | PropertyError:
59
+ def convert_value(cls, value: Any) -> Value | PropertyError | None:
60
60
  if value is None or isinstance(value, Value):
61
61
  return value
62
62
  if isinstance(value, str):
@@ -64,7 +64,7 @@ class UuidProperty(PropertyProtocol):
64
64
  UUID(value)
65
65
  except ValueError:
66
66
  return PropertyError(f"Invalid UUID value: {value}")
67
- return Value(python_code=f"UUID('{value}')", raw_value=value)
67
+ return Value(python_code=PythonCode(f"UUID('{value}')"), raw_value=value)
68
68
  return PropertyError(f"Invalid UUID value: {value}")
69
69
 
70
70
  def get_imports(self, *, prefix: str) -> set[str]:
@@ -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,7 +1,7 @@
1
- from enum import Enum
1
+ from enum import StrEnum
2
2
 
3
3
 
4
- class DataType(str, Enum):
4
+ class DataType(StrEnum):
5
5
  """The data type of a schema is defined by the type keyword
6
6
 
7
7
  References:
@@ -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={