django-bolt 0.1.0__cp310-abi3-win_amd64.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.

Potentially problematic release.


This version of django-bolt might be problematic. Click here for more details.

Files changed (128) hide show
  1. django_bolt/__init__.py +147 -0
  2. django_bolt/_core.pyd +0 -0
  3. django_bolt/admin/__init__.py +25 -0
  4. django_bolt/admin/admin_detection.py +179 -0
  5. django_bolt/admin/asgi_bridge.py +267 -0
  6. django_bolt/admin/routes.py +91 -0
  7. django_bolt/admin/static.py +155 -0
  8. django_bolt/admin/static_routes.py +111 -0
  9. django_bolt/api.py +1011 -0
  10. django_bolt/apps.py +7 -0
  11. django_bolt/async_collector.py +228 -0
  12. django_bolt/auth/README.md +464 -0
  13. django_bolt/auth/REVOCATION_EXAMPLE.md +391 -0
  14. django_bolt/auth/__init__.py +84 -0
  15. django_bolt/auth/backends.py +236 -0
  16. django_bolt/auth/guards.py +224 -0
  17. django_bolt/auth/jwt_utils.py +212 -0
  18. django_bolt/auth/revocation.py +286 -0
  19. django_bolt/auth/token.py +335 -0
  20. django_bolt/binding.py +363 -0
  21. django_bolt/bootstrap.py +77 -0
  22. django_bolt/cli.py +133 -0
  23. django_bolt/compression.py +104 -0
  24. django_bolt/decorators.py +159 -0
  25. django_bolt/dependencies.py +128 -0
  26. django_bolt/error_handlers.py +305 -0
  27. django_bolt/exceptions.py +294 -0
  28. django_bolt/health.py +129 -0
  29. django_bolt/logging/__init__.py +6 -0
  30. django_bolt/logging/config.py +357 -0
  31. django_bolt/logging/middleware.py +296 -0
  32. django_bolt/management/__init__.py +1 -0
  33. django_bolt/management/commands/__init__.py +0 -0
  34. django_bolt/management/commands/runbolt.py +427 -0
  35. django_bolt/middleware/__init__.py +32 -0
  36. django_bolt/middleware/compiler.py +131 -0
  37. django_bolt/middleware/middleware.py +247 -0
  38. django_bolt/openapi/__init__.py +23 -0
  39. django_bolt/openapi/config.py +196 -0
  40. django_bolt/openapi/plugins.py +439 -0
  41. django_bolt/openapi/routes.py +152 -0
  42. django_bolt/openapi/schema_generator.py +581 -0
  43. django_bolt/openapi/spec/__init__.py +68 -0
  44. django_bolt/openapi/spec/base.py +74 -0
  45. django_bolt/openapi/spec/callback.py +24 -0
  46. django_bolt/openapi/spec/components.py +72 -0
  47. django_bolt/openapi/spec/contact.py +21 -0
  48. django_bolt/openapi/spec/discriminator.py +25 -0
  49. django_bolt/openapi/spec/encoding.py +67 -0
  50. django_bolt/openapi/spec/enums.py +41 -0
  51. django_bolt/openapi/spec/example.py +36 -0
  52. django_bolt/openapi/spec/external_documentation.py +21 -0
  53. django_bolt/openapi/spec/header.py +132 -0
  54. django_bolt/openapi/spec/info.py +50 -0
  55. django_bolt/openapi/spec/license.py +28 -0
  56. django_bolt/openapi/spec/link.py +66 -0
  57. django_bolt/openapi/spec/media_type.py +51 -0
  58. django_bolt/openapi/spec/oauth_flow.py +36 -0
  59. django_bolt/openapi/spec/oauth_flows.py +28 -0
  60. django_bolt/openapi/spec/open_api.py +87 -0
  61. django_bolt/openapi/spec/operation.py +105 -0
  62. django_bolt/openapi/spec/parameter.py +147 -0
  63. django_bolt/openapi/spec/path_item.py +78 -0
  64. django_bolt/openapi/spec/paths.py +27 -0
  65. django_bolt/openapi/spec/reference.py +38 -0
  66. django_bolt/openapi/spec/request_body.py +38 -0
  67. django_bolt/openapi/spec/response.py +48 -0
  68. django_bolt/openapi/spec/responses.py +44 -0
  69. django_bolt/openapi/spec/schema.py +678 -0
  70. django_bolt/openapi/spec/security_requirement.py +28 -0
  71. django_bolt/openapi/spec/security_scheme.py +69 -0
  72. django_bolt/openapi/spec/server.py +34 -0
  73. django_bolt/openapi/spec/server_variable.py +32 -0
  74. django_bolt/openapi/spec/tag.py +32 -0
  75. django_bolt/openapi/spec/xml.py +44 -0
  76. django_bolt/pagination.py +669 -0
  77. django_bolt/param_functions.py +49 -0
  78. django_bolt/params.py +337 -0
  79. django_bolt/request_parsing.py +128 -0
  80. django_bolt/responses.py +214 -0
  81. django_bolt/router.py +48 -0
  82. django_bolt/serialization.py +193 -0
  83. django_bolt/status_codes.py +321 -0
  84. django_bolt/testing/__init__.py +10 -0
  85. django_bolt/testing/client.py +274 -0
  86. django_bolt/testing/helpers.py +93 -0
  87. django_bolt/tests/__init__.py +0 -0
  88. django_bolt/tests/admin_tests/__init__.py +1 -0
  89. django_bolt/tests/admin_tests/conftest.py +6 -0
  90. django_bolt/tests/admin_tests/test_admin_with_django.py +278 -0
  91. django_bolt/tests/admin_tests/urls.py +9 -0
  92. django_bolt/tests/cbv/__init__.py +0 -0
  93. django_bolt/tests/cbv/test_class_views.py +570 -0
  94. django_bolt/tests/cbv/test_class_views_django_orm.py +703 -0
  95. django_bolt/tests/cbv/test_class_views_features.py +1173 -0
  96. django_bolt/tests/cbv/test_class_views_with_client.py +622 -0
  97. django_bolt/tests/conftest.py +165 -0
  98. django_bolt/tests/test_action_decorator.py +399 -0
  99. django_bolt/tests/test_auth_secret_key.py +83 -0
  100. django_bolt/tests/test_decorator_syntax.py +159 -0
  101. django_bolt/tests/test_error_handling.py +481 -0
  102. django_bolt/tests/test_file_response.py +192 -0
  103. django_bolt/tests/test_global_cors.py +172 -0
  104. django_bolt/tests/test_guards_auth.py +441 -0
  105. django_bolt/tests/test_guards_integration.py +303 -0
  106. django_bolt/tests/test_health.py +283 -0
  107. django_bolt/tests/test_integration_validation.py +400 -0
  108. django_bolt/tests/test_json_validation.py +536 -0
  109. django_bolt/tests/test_jwt_auth.py +327 -0
  110. django_bolt/tests/test_jwt_token.py +458 -0
  111. django_bolt/tests/test_logging.py +837 -0
  112. django_bolt/tests/test_logging_merge.py +419 -0
  113. django_bolt/tests/test_middleware.py +492 -0
  114. django_bolt/tests/test_middleware_server.py +230 -0
  115. django_bolt/tests/test_model_viewset.py +323 -0
  116. django_bolt/tests/test_models.py +24 -0
  117. django_bolt/tests/test_pagination.py +1258 -0
  118. django_bolt/tests/test_parameter_validation.py +178 -0
  119. django_bolt/tests/test_syntax.py +626 -0
  120. django_bolt/tests/test_testing_utilities.py +163 -0
  121. django_bolt/tests/test_testing_utilities_simple.py +123 -0
  122. django_bolt/tests/test_viewset_unified.py +346 -0
  123. django_bolt/typing.py +273 -0
  124. django_bolt/views.py +1110 -0
  125. django_bolt-0.1.0.dist-info/METADATA +629 -0
  126. django_bolt-0.1.0.dist-info/RECORD +128 -0
  127. django_bolt-0.1.0.dist-info/WHEEL +4 -0
  128. django_bolt-0.1.0.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,74 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import asdict, dataclass, fields, is_dataclass
4
+ from enum import Enum
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ if TYPE_CHECKING:
8
+ from collections.abc import Iterator
9
+ from dataclasses import Field
10
+
11
+ __all__ = ("BaseSchemaObject",)
12
+
13
+
14
+ def _normalize_key(key: str) -> str:
15
+ if key.endswith("_in"):
16
+ return "in"
17
+ if key.startswith("schema_"):
18
+ return key.split("_")[1]
19
+ if "_" in key:
20
+ components = key.split("_")
21
+ return components[0] + "".join(component.title() for component in components[1:])
22
+ return "$ref" if key == "ref" else key
23
+
24
+
25
+ def _normalize_value(value: Any) -> Any:
26
+ if isinstance(value, BaseSchemaObject):
27
+ return value.to_schema()
28
+ if is_dataclass(value):
29
+ return {
30
+ _normalize_value(k): _normalize_value(v)
31
+ for k, v in asdict(value).items() # type: ignore[call-overload]
32
+ if v is not None
33
+ }
34
+ if isinstance(value, dict):
35
+ return {_normalize_value(k): _normalize_value(v) for k, v in value.items() if v is not None}
36
+ if isinstance(value, list):
37
+ return [_normalize_value(v) for v in value]
38
+ return value.value if isinstance(value, Enum) else value
39
+
40
+
41
+ @dataclass
42
+ class BaseSchemaObject:
43
+ """Base class for schema spec objects"""
44
+
45
+ @property
46
+ def _exclude_fields(self) -> set[str]:
47
+ return set()
48
+
49
+ def _iter_fields(self) -> Iterator[Field[Any]]:
50
+ yield from fields(self)
51
+
52
+ def to_schema(self) -> dict[str, Any]:
53
+ """Transform the spec dataclass object into a string keyed dictionary. This method traverses all nested values
54
+ recursively.
55
+ """
56
+ result: dict[str, Any] = {}
57
+ exclude = self._exclude_fields
58
+
59
+ for field in self._iter_fields():
60
+ if field.name in exclude:
61
+ continue
62
+ value = _normalize_value(getattr(self, field.name, None))
63
+
64
+ if value is not None:
65
+ if "alias" in field.metadata:
66
+ if not isinstance(field.metadata["alias"], str):
67
+ raise TypeError('metadata["alias"] must be a str')
68
+ key = field.metadata["alias"]
69
+ else:
70
+ key = _normalize_key(field.name)
71
+
72
+ result[key] = value
73
+
74
+ return result
@@ -0,0 +1,24 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Union
4
+
5
+ if TYPE_CHECKING:
6
+ from .path_item import PathItem
7
+ from .reference import Reference
8
+
9
+
10
+ Callback = dict[str, Union["PathItem", "Reference"]]
11
+ """A map of possible out-of band callbacks related to the parent operation. Each value in the map is a
12
+ `Path Item Object <https://spec.openapis.org/oas/v3.1.0#pathItemObject>`_ that describes a set of requests that may be
13
+ initiated by the API provider and the expected responses. The key value used to identify the path item object is an
14
+ expression, evaluated at runtime, that identifies a URL to use for the callback operation.
15
+
16
+ Patterned Fields
17
+
18
+ {expression}: 'PathItem' = ...
19
+
20
+ A Path Item Object used to define a callback request and expected responses.
21
+
22
+ A `complete example <https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.1/webhook-example.yaml>`_ is
23
+ available.
24
+ """
@@ -0,0 +1,72 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import TYPE_CHECKING
5
+
6
+ from .base import BaseSchemaObject
7
+
8
+ __all__ = ("Components",)
9
+
10
+
11
+ if TYPE_CHECKING:
12
+ from .callback import Callback
13
+ from .example import Example
14
+ from .header import OpenAPIHeader
15
+ from .link import Link
16
+ from .parameter import Parameter
17
+ from .path_item import PathItem
18
+ from .reference import Reference
19
+ from .request_body import RequestBody
20
+ from .response import OpenAPIResponse
21
+ from .schema import Schema
22
+ from .security_scheme import SecurityScheme
23
+
24
+
25
+ @dataclass
26
+ class Components(BaseSchemaObject):
27
+ """Holds a set of reusable objects for different aspects of the OAS.
28
+
29
+ All objects defined within the components object will have no effect
30
+ on the API unless they are explicitly referenced from properties
31
+ outside the components object.
32
+ """
33
+
34
+ schemas: dict[str, Schema] = field(default_factory=dict)
35
+ """An object to hold reusable
36
+ `Schema Objects <https://spec.openapis.org/oas/v3.1.0#schemaObject>`_"""
37
+
38
+ responses: dict[str, OpenAPIResponse | Reference] | None = None
39
+ """An object to hold reusable
40
+ `Response Objects <https://spec.openapis.org/oas/v3.1.0#responseObject>`_"""
41
+
42
+ parameters: dict[str, Parameter | Reference] | None = None
43
+ """An object to hold reusable
44
+ `Parameter Objects <https://spec.openapis.org/oas/v3.1.0#parameterObject>`_"""
45
+
46
+ examples: dict[str, Example | Reference] | None = None
47
+ """An object to hold reusable
48
+ `Example Objects <https://spec.openapis.org/oas/v3.1.0#exampleObject>`_"""
49
+
50
+ request_bodies: dict[str, RequestBody | Reference] | None = None
51
+ """An object to hold reusable
52
+ `Request Body Objects <https://spec.openapis.org/oas/v3.1.0#requestBodyObject>`_"""
53
+
54
+ headers: dict[str, OpenAPIHeader | Reference] | None = None
55
+ """An object to hold reusable
56
+ `Header Objects <https://spec.openapis.org/oas/v3.1.0#headerObject>`_"""
57
+
58
+ security_schemes: dict[str, SecurityScheme | Reference] | None = None
59
+ """An object to hold reusable
60
+ `Security Scheme Objects <https://spec.openapis.org/oas/v3.1.0#securitySchemeObject>`_"""
61
+
62
+ links: dict[str, Link | Reference] | None = None
63
+ """An object to hold reusable
64
+ `Link Objects <https://spec.openapis.org/oas/v3.1.0#linkObject>`_"""
65
+
66
+ callbacks: dict[str, Callback | Reference] | None = None
67
+ """An object to hold reusable
68
+ `Callback Objects <https://spec.openapis.org/oas/v3.1.0#callbackObject>`_"""
69
+
70
+ path_items: dict[str, PathItem | Reference] | None = None
71
+ """An object to hold reusable
72
+ `Path Item Object <https://spec.openapis.org/oas/v3.1.0#pathItemObject>`_"""
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from .base import BaseSchemaObject
6
+
7
+ __all__ = ("Contact",)
8
+
9
+
10
+ @dataclass
11
+ class Contact(BaseSchemaObject):
12
+ """Contact information for the exposed API."""
13
+
14
+ name: str | None = None
15
+ """The identifying name of the contact person/organization."""
16
+
17
+ url: str | None = None
18
+ """The URL pointing to the contact information. MUST be in the form of a URL."""
19
+
20
+ email: str | None = None
21
+ """The email address of the contact person/organization. MUST be in the form of an email address."""
@@ -0,0 +1,25 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from .base import BaseSchemaObject
6
+
7
+ __all__ = ("Discriminator",)
8
+
9
+
10
+ @dataclass(unsafe_hash=True)
11
+ class Discriminator(BaseSchemaObject):
12
+ """When request bodies or response payloads may be one of a number of different schemas, a ``discriminator``
13
+ object can be used to aid in serialization, deserialization, and validation.
14
+
15
+ The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an
16
+ alternative schema based on the value associated with it.
17
+
18
+ When using the discriminator, _inline_ schemas will not be considered.
19
+ """
20
+
21
+ property_name: str
22
+ """**REQUIRED**. The name of the property in the payload that will hold the discriminator value."""
23
+
24
+ mapping: dict[str, str] | None = None
25
+ """An object to hold mappings between payload values and schema names or references."""
@@ -0,0 +1,67 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import TYPE_CHECKING
5
+
6
+ from .base import BaseSchemaObject
7
+
8
+ if TYPE_CHECKING:
9
+ from .header import OpenAPIHeader
10
+ from .reference import Reference
11
+
12
+ __all__ = ("Encoding",)
13
+
14
+
15
+ @dataclass
16
+ class Encoding(BaseSchemaObject):
17
+ """A single encoding definition applied to a single schema property."""
18
+
19
+ content_type: str | None = None
20
+ """The Content-Type for encoding a specific property. Default value depends n the property type:
21
+
22
+ - for ``object``: ``application/json``
23
+ - for ``array``: the default is defined based on the inner type
24
+ - for all other cases the default is ``application/octet-stream``.
25
+
26
+ The value can be a specific media type (e.g. ``application/json``), a wildcard media type (e.g. ``image/*``), or a
27
+ comma-separated list of the two types.
28
+ """
29
+
30
+ headers: dict[str, OpenAPIHeader | Reference] | None = None
31
+ """A map allowing additional information to be provided as headers, for example ``Content-Disposition``.
32
+
33
+ ``Content-Type`` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the
34
+ request body media type is not a ``multipart``.
35
+ """
36
+
37
+ style: str | None = None
38
+ """Describes how a specific property value will be serialized depending on its type.
39
+
40
+ See `Parameter Object <https://spec.openapis.org/oas/v3.1.0#parameterObject>`_ for details on the
41
+ `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ property. The behavior follows the same values as
42
+ ``query`` parameters, including default values. This property SHALL be ignored if the request body media type is not
43
+ ``application/x-www-form-urlencoded`` or ``multipart/form-data``. If a value is explicitly defined, then the value
44
+ of `contentType <https://spec.openapis.org/oas/v3.1.0#encodingContentType>`_ (implicit or explicit) SHALL be
45
+ ignored.
46
+ """
47
+
48
+ explode: bool = False
49
+ """When this is true, property values of type ``array`` or ``object`` generate separate parameters for each value of
50
+ the array, or key-value-pair of the map.
51
+
52
+ For other types of properties this property has no effect. When
53
+ `style <https://spec.openapis.org/oas/v3.1.0#encodingStyle>`_ is ``form``, the default value is ``True``. For all
54
+ other styles, the default value is ``False``. This property SHALL be ignored if the request body media type is not
55
+ ``application/x-www-form-urlencoded`` or ``multipart/form-data``. If a value is explicitly defined, then the value
56
+ of `contentType <https://spec.openapis.org/oas/v3.1.0#encodingContentType>`_ (implicit or explicit) SHALL be
57
+ ignored.
58
+ """
59
+
60
+ allow_reserved: bool = False
61
+ """Determines whether the parameter value SHOULD allow reserved characters, as defined by :rfc:`3986`
62
+ (``:/?#[]@!$&'()*+,;=``) to be included without percent-encoding.
63
+
64
+ This property SHALL be ignored if the request body media type s not ``application/x-www-form-urlencoded`` or
65
+ ``multipart/form-data``. If a value is explicitly defined, then the value of
66
+ `contentType <https://spec.openapis.org/oas/v3.1.0#encodingContentType>`_ (implicit or explicit) SHALL be ignored.
67
+ """
@@ -0,0 +1,41 @@
1
+ from enum import Enum
2
+
3
+ __all__ = ("OpenAPIFormat", "OpenAPIType")
4
+
5
+
6
+ class OpenAPIFormat(str, Enum):
7
+ """Formats extracted from: https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#page-13"""
8
+
9
+ DATE = "date"
10
+ DATE_TIME = "date-time"
11
+ TIME = "time"
12
+ DURATION = "duration"
13
+ URL = "url"
14
+ EMAIL = "email"
15
+ IDN_EMAIL = "idn-email"
16
+ HOST_NAME = "hostname"
17
+ IDN_HOST_NAME = "idn-hostname"
18
+ IPV4 = "ipv4"
19
+ IPV6 = "ipv6"
20
+ URI = "uri"
21
+ URI_REFERENCE = "uri-reference"
22
+ URI_TEMPLATE = "uri-template"
23
+ JSON_POINTER = "json-pointer"
24
+ RELATIVE_JSON_POINTER = "relative-json-pointer"
25
+ IRI = "iri-reference"
26
+ IRI_REFERENCE = "iri-reference" # noqa: PIE796
27
+ UUID = "uuid"
28
+ REGEX = "regex"
29
+ BINARY = "binary"
30
+
31
+
32
+ class OpenAPIType(str, Enum):
33
+ """An OopenAPI type."""
34
+
35
+ ARRAY = "array"
36
+ BOOLEAN = "boolean"
37
+ INTEGER = "integer"
38
+ NULL = "null"
39
+ NUMBER = "number"
40
+ OBJECT = "object"
41
+ STRING = "string"
@@ -0,0 +1,36 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any
5
+
6
+ from .base import BaseSchemaObject
7
+
8
+
9
+ @dataclass
10
+ class Example(BaseSchemaObject):
11
+ id: str | None = None
12
+ """Optional ID for the example. When provided, this will be used as the key in the OpenAPI specification."""
13
+
14
+ summary: str | None = None
15
+ """Short description for the example."""
16
+
17
+ description: str | None = None
18
+ """Long description for the example.
19
+
20
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
21
+ """
22
+
23
+ value: Any | None = None
24
+ """Embedded literal example.
25
+
26
+ The ``value`` field and ``externalValue`` field are mutually exclusive. To represent examples of media types that
27
+ cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary.
28
+ """
29
+
30
+ external_value: str | None = None
31
+ """A URL that points to the literal example. This provides the capability to reference examples that cannot easily
32
+ be included in JSON or YAML documents.
33
+
34
+ The ``value`` field and ``externalValue`` field are mutually exclusive. See the rules for resolving
35
+ `Relative References <https://spec.openapis.org/oas/v3.1.0#relativeReferencesURI>`_.
36
+ """
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from .base import BaseSchemaObject
6
+
7
+ __all__ = ("ExternalDocumentation",)
8
+
9
+
10
+ @dataclass
11
+ class ExternalDocumentation(BaseSchemaObject):
12
+ """Allows referencing an external resource for extended documentation."""
13
+
14
+ url: str
15
+ """**REQUIRED**. The URL for the target documentation. Value MUST be in the form of a URL."""
16
+
17
+ description: str | None = None
18
+ """A short description of the target documentation.
19
+
20
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
21
+ """
@@ -0,0 +1,132 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import TYPE_CHECKING, Any, Literal
5
+
6
+ from .base import BaseSchemaObject
7
+
8
+ if TYPE_CHECKING:
9
+ from .example import Example
10
+ from .media_type import OpenAPIMediaType
11
+ from .reference import Reference
12
+ from .schema import Schema
13
+
14
+ __all__ = ("OpenAPIHeader",)
15
+
16
+
17
+ @dataclass
18
+ class OpenAPIHeader(BaseSchemaObject):
19
+ """The Header Object follows the structure of the [Parameter
20
+ Object](https://spec.openapis.org/oas/v3.1.0#parameterObject) with the
21
+ following changes:
22
+
23
+ 1. ``name`` MUST NOT be specified, it is given in the corresponding ``headers`` map.
24
+ 2. ``in`` MUST NOT be specified, it is implicitly in ``header``.
25
+ 3. All traits that are affected by the location MUST be applicable to a location of ``header``
26
+ (for example, `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__).
27
+ """
28
+
29
+ schema: Schema | Reference | None = None
30
+ """The schema defining the type used for the parameter."""
31
+
32
+ name: Literal[""] = ""
33
+ """MUST NOT be specified, it is given in the corresponding ``headers`` map."""
34
+
35
+ param_in: Literal["header"] = "header"
36
+ """MUST NOT be specified, it is implicitly in ``header``."""
37
+
38
+ description: str | None = None
39
+ """A brief description of the parameter. This could contain examples of
40
+ use.
41
+
42
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
43
+ """
44
+
45
+ required: bool = False
46
+ """Determines whether this parameter is mandatory.
47
+
48
+ If the `parameter location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ is ``"path"``, this property is
49
+ **REQUIRED** and its value MUST be ``True``. Otherwise, the property MAY be included and its default value is
50
+ ``False``.
51
+ """
52
+
53
+ deprecated: bool = False
54
+ """Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is ``False``."""
55
+
56
+ allow_empty_value: bool = None # type: ignore[assignment]
57
+ """Sets the ability to pass empty-valued parameters. This is valid only for ``query`` parameters and allows sending
58
+ a parameter with an empty value. Default value is ``False``. If
59
+ `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is used, and if behavior is ``n/a`` (cannot be
60
+ serialized), the value of ``allowEmptyValue`` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is
61
+ likely to be removed in a later revision.
62
+
63
+ The rules for serialization of the parameter are specified in one of two ways.For simpler scenarios, a
64
+ `schema <https://spec.openapis.org/oas/v3.1.0#parameterSchema>`_ and
65
+ `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ can describe the structure and syntax of the
66
+ parameter.
67
+ """
68
+
69
+ style: str | None = None
70
+ """Describes how the parameter value will be serialized depending on the
71
+ type of the parameter value. Default values (based on value of ``in``):
72
+
73
+ - for ``query`` - ``form``;
74
+ - for ``path`` - ``simple``;
75
+ - for ``header`` - ``simple``;
76
+ - for ``cookie`` - ``form``.
77
+ """
78
+
79
+ explode: bool | None = None
80
+ """When this is true, parameter values of type ``array`` or ``object`` generate separate parameters for each value
81
+ of the array or key-value pair of the map.
82
+
83
+ For other types of parameters this property has no effect.When
84
+ `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is ``form``, the default value is ``True``. For all
85
+ other styles, the default value is ``False``.
86
+ """
87
+
88
+ allow_reserved: bool = None # type: ignore[assignment]
89
+ """Determines whether the parameter value SHOULD allow reserved characters, as defined by. :rfc:`3986`
90
+ (``:/?#[]@!$&'()*+,;=``) to be included without percent-encoding.
91
+
92
+ This property only applies to parameters with an ``in`` value of ``query``. The default value is ``False``.
93
+ """
94
+
95
+ example: Any | None = None
96
+ """Example of the parameter's potential value.
97
+
98
+ The example SHOULD match the specified schema and encoding properties if present. The ``example`` field is mutually
99
+ exclusive of the ``examples`` field. Furthermore, if referencing a ``schema`` that contains an example, the
100
+ ``example`` value SHALL _override_ the example provided by the schema. To represent examples of media types that
101
+ cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where
102
+ necessary.
103
+ """
104
+
105
+ examples: dict[str, Example | Reference] | None = None
106
+ """Examples of the parameter's potential value. Each example SHOULD contain a value in the correct format as
107
+ specified in the parameter encoding. The ``examples`` field is mutually exclusive of the ``example`` field.
108
+ Furthermore, if referencing a ``schema`` that contains an example, the ``examples`` value SHALL _override_ the
109
+ example provided by the schema.
110
+
111
+ For more complex scenarios, the `content <https://spec.openapis.org/oas/v3.1.0#parameterContent>`_ property can
112
+ define the media type and schema of the parameter. A parameter MUST contain either a ``schema`` property, or a
113
+ ``content`` property, but not both. When ``example`` or ``examples`` are provided in conjunction with the ``schema``
114
+ object, the example MUST follow the prescribed serialization strategy for the parameter.
115
+ """
116
+
117
+ content: dict[str, OpenAPIMediaType] | None = None
118
+ """A map containing the representations for the parameter.
119
+
120
+ The key is the media type and the value describes it. The map MUST only contain one entry.
121
+ """
122
+
123
+ @property
124
+ def _exclude_fields(self) -> set[str]:
125
+ return {"name", "param_in", "allow_reserved", "allow_empty_value"}
126
+
127
+ def __post_init__(self) -> None:
128
+ if self.allow_reserved is None:
129
+ self.allow_reserved = False # type: ignore[unreachable]
130
+
131
+ if self.allow_empty_value is None:
132
+ self.allow_empty_value = False # type: ignore[unreachable]
@@ -0,0 +1,50 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import TYPE_CHECKING
5
+
6
+ from .base import BaseSchemaObject
7
+
8
+ if TYPE_CHECKING:
9
+ from .contact import Contact
10
+ from .license import License
11
+
12
+ __all__ = ("Info",)
13
+
14
+
15
+ @dataclass
16
+ class Info(BaseSchemaObject):
17
+ """The object provides metadata about the API.
18
+
19
+ The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools
20
+ for convenience.
21
+ """
22
+
23
+ title: str
24
+ """
25
+ **REQUIRED**. The title of the API.
26
+ """
27
+
28
+ version: str
29
+ """
30
+ **REQUIRED**. The version of the OpenAPI document which is distinct from the
31
+ `OpenAPI Specification version <https://spec.openapis.org/oas/v3.1.0#oasVersion>`_ or the API implementation version
32
+ """
33
+
34
+ summary: str | None = None
35
+ """A short summary of the API."""
36
+
37
+ description: str | None = None
38
+ """A description of the API.
39
+
40
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
41
+ """
42
+
43
+ terms_of_service: str | None = None
44
+ """A URL to the Terms of Service for the API. MUST be in the form of a URL."""
45
+
46
+ contact: Contact | None = None
47
+ """The contact information for the exposed API."""
48
+
49
+ license: License | None = None
50
+ """The license information for the exposed API."""
@@ -0,0 +1,28 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from .base import BaseSchemaObject
6
+
7
+ __all__ = ("License",)
8
+
9
+
10
+ @dataclass
11
+ class License(BaseSchemaObject):
12
+ """License information for the exposed API."""
13
+
14
+ name: str
15
+ """**REQUIRED**. The license name used for the API."""
16
+
17
+ identifier: str | None = None
18
+ """An
19
+ `SPDX <https://spdx.github.io/spdx-spec/v2.3/SPDX-license-list/#a1-licenses-with-short-identifiers>`_ license expression for the API.
20
+
21
+ The ``identifier`` field is mutually exclusive of the ``url`` field.
22
+ """
23
+
24
+ url: str | None = None
25
+ """A URL to the license used for the API.
26
+
27
+ This MUST be in the form of a URL. The ``url`` field is mutually exclusive of the ``identifier`` field.
28
+ """
@@ -0,0 +1,66 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ from .base import BaseSchemaObject
7
+
8
+ if TYPE_CHECKING:
9
+ from .server import Server
10
+
11
+ __all__ = ("Link",)
12
+
13
+
14
+ @dataclass
15
+ class Link(BaseSchemaObject):
16
+ """The ``Link object`` represents a possible design-time link for a response. The presence of a link does not
17
+ guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal
18
+ mechanism between responses and other operations.
19
+
20
+ Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require
21
+ link information in the runtime response.
22
+
23
+ For computing links, and providing instructions to execute them, a
24
+ `runtime expression <https://spec.openapis.org/oas/v3.1.0#runtimeExpression>`_ is used for accessing values in an
25
+ operation and using them as parameters while invoking the linked operation.
26
+ """
27
+
28
+ operation_ref: str | None = None
29
+ """A relative or absolute URI reference to an OAS operation.
30
+
31
+ This field is mutually exclusive of the ``operationId`` field, and MUST point to an
32
+ `Operation Object <https://spec.openapis.org/oas/v3.1.0#operationObject>`_. Relative ``operationRef`` values MAY be
33
+ used to locate an existing `Operation Object <https://spec.openapis.org/oas/v3.1.0#operationObject>`_ in the OpenAPI
34
+ definition. See the rules for resolving
35
+ `Relative References <https://spec.openapis.org/oas/v3.1.0#relativeReferencesURI>`_
36
+ """
37
+
38
+ operation_id: str | None = None
39
+ """The name of an _existing_, resolvable OAS operation, as defined with a unique ``operationId``.
40
+
41
+ This field is mutually exclusive of the ``operationRef`` field.
42
+ """
43
+
44
+ parameters: dict[str, Any] | None = None
45
+ """A map representing parameters to pass to an operation as specified with ``operationId`` or identified via
46
+ ``operationRef``. The key is the parameter name to be used, whereas the value can be a constant or an expression to
47
+ be evaluated and passed to the linked operation.
48
+
49
+ The parameter name can be qualified using the
50
+ `parameter location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ ``[{in}.]{name}`` for operations that use
51
+ the same parameter name in different locations (e.g. path.id).
52
+ """
53
+
54
+ request_body: Any | None = None
55
+ """A literal value or
56
+ `{expression} <https://spec.openapis.org/oas/v3.1.0#runtimeExpression>`_ to use as a request body when calling the
57
+ target operation."""
58
+
59
+ description: str | None = None
60
+ """A description of the link.
61
+
62
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
63
+ """
64
+
65
+ server: Server | None = None
66
+ """A server object to be used by the target operation."""