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,51 @@
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 .encoding import Encoding
10
+ from .example import Example
11
+ from .reference import Reference
12
+ from .schema import Schema
13
+
14
+ __all__ = ("OpenAPIMediaType",)
15
+
16
+
17
+ @dataclass
18
+ class OpenAPIMediaType(BaseSchemaObject):
19
+ """Each Media Type Object provides schema and examples for the media type identified by its key."""
20
+
21
+ schema: Reference | Schema | None = None
22
+ """The schema defining the content of the request, response, or parameter."""
23
+
24
+ example: Any | None = None
25
+ """Example of the media type.
26
+
27
+ The example object SHOULD be in the correct format as specified by the media type.
28
+
29
+ The ``example`` field is mutually exclusive of the ``examples`` field.
30
+
31
+ Furthermore, if referencing a ``schema`` which contains an example, the ``example`` value SHALL _override_ the
32
+ example provided by the schema.
33
+ """
34
+
35
+ examples: dict[str, Example | Reference] | None = None
36
+ """Examples of the media type.
37
+
38
+ Each example object SHOULD match the media type and specified schema if present.
39
+
40
+ The ``examples`` field is mutually exclusive of the ``example`` field.
41
+
42
+ Furthermore, if referencing a ``schema`` which contains an example, the ``examples`` value SHALL _override_ the
43
+ example provided by the schema.
44
+ """
45
+
46
+ encoding: dict[str, Encoding] | None = None
47
+ """A map between a property name and its encoding information.
48
+
49
+ The key, being the property name, MUST exist in the schema as a property. The encoding object SHALL only apply to
50
+ ``requestBody`` objects when the media type is ``multipart`` or ``application/x-www-form-urlencoded``.
51
+ """
@@ -0,0 +1,36 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from .base import BaseSchemaObject
6
+
7
+ __all__ = ("OAuthFlow",)
8
+
9
+
10
+ @dataclass
11
+ class OAuthFlow(BaseSchemaObject):
12
+ """Configuration details for a supported OAuth Flow."""
13
+
14
+ authorization_url: str | None = None
15
+ """
16
+ **REQUIRED** for ``oauth2`` ("implicit", "authorizationCode"). The authorization URL to be used for this flow. This
17
+ MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
18
+ """
19
+
20
+ token_url: str | None = None
21
+ """
22
+ **REQUIRED** for ``oauth2`` ("password", "clientCredentials", "authorizationCode"). The token URL to be used for
23
+ this flow. This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
24
+ """
25
+
26
+ refresh_url: str | None = None
27
+ """The URL to be used for obtaining refresh tokens.
28
+
29
+ This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
30
+ """
31
+
32
+ scopes: dict[str, str] | None = None
33
+ """
34
+ **REQUIRED** for ``oauth2``. The available scopes for the OAuth2 security scheme. A map between the scope name and a
35
+ short description for it the map MAY be empty.
36
+ """
@@ -0,0 +1,28 @@
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 .oauth_flow import OAuthFlow
10
+
11
+ __all__ = ("OAuthFlows",)
12
+
13
+
14
+ @dataclass
15
+ class OAuthFlows(BaseSchemaObject):
16
+ """Allows configuration of the supported OAuth Flows."""
17
+
18
+ implicit: OAuthFlow | None = None
19
+ """Configuration for the OAuth Implicit flow."""
20
+
21
+ password: OAuthFlow | None = None
22
+ """Configuration for the OAuth Resource Owner Password flow."""
23
+
24
+ client_credentials: OAuthFlow | None = None
25
+ """Configuration for the OAuth Client Credentials flow. Previously called ``application`` in OpenAPI 2.0."""
26
+
27
+ authorization_code: OAuthFlow | None = None
28
+ """Configuration for the OAuth Authorization Code flow. Previously called ``accessCode`` in OpenAPI 2.0."""
@@ -0,0 +1,87 @@
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
+ from .components import Components
8
+ from .server import Server
9
+
10
+ if TYPE_CHECKING:
11
+ from .external_documentation import ExternalDocumentation
12
+ from .info import Info
13
+ from .path_item import PathItem
14
+ from .paths import Paths
15
+ from .reference import Reference
16
+ from .security_requirement import SecurityRequirement
17
+ from .tag import Tag
18
+
19
+ __all__ = ("OpenAPI",)
20
+
21
+
22
+ @dataclass
23
+ class OpenAPI(BaseSchemaObject):
24
+ """Root OpenAPI document."""
25
+
26
+ info: Info
27
+ """
28
+ **REQUIRED**. Provides metadata about the API. The metadata MAY be used by tooling as required.
29
+ """
30
+
31
+ openapi: str = "3.1.0"
32
+ """
33
+ **REQUIRED**. This string MUST be the
34
+ `version number <https://spec.openapis.org/oas/v3.1.0#versions>`_ of the OpenAPI Specification that the OpenAPI
35
+ document uses. The ``openapi`` field SHOULD be used by tooling to interpret the OpenAPI document. This is *not*
36
+ related to the API `info.version <https://spec.openapis.org/oas/v3.1.0#infoVersion>`_ string.
37
+ """
38
+
39
+ json_schema_dialect: str | None = None
40
+ """The default value for the ``$schema`` keyword within
41
+ `Schema Objects <https://spec.openapis.org/oas/v3.1.0#schemaObject>`_ contained within this OAS document.
42
+
43
+ This MUST be in the form of a URI.
44
+ """
45
+
46
+ servers: list[Server] = field(default_factory=lambda x: [Server(url="/")]) # type: ignore[misc, arg-type]
47
+ """An array of Server Objects, which provide connectivity information to a target server.
48
+
49
+ If the ``servers`` property is not provided, or is an empty array, the default value would be a
50
+ `Server Object <https://spec.openapis.org/oas/v3.1.0#serverObject>`_ with a
51
+ `url <https://spec.openapis.org/oas/v3.1.0#serverUrl>`_ value of ``/``.
52
+ """
53
+
54
+ paths: Paths | None = None
55
+ """The available paths and operations for the API."""
56
+
57
+ webhooks: dict[str, PathItem | Reference] | None = None
58
+ """The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement.
59
+
60
+ Closely related to the ``callbacks`` feature, this section describes requests initiated other than by an API call,
61
+ for example by an out of band registration. The key name is a unique string to refer to each webhook, while the
62
+ (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the
63
+ expected responses. An
64
+ `example <https://github.com/OAI/OpenAPI-Specification/blob/main/examples/v3.1/webhook-example.yaml>`_ is available.
65
+ """
66
+
67
+ components: Components = field(default_factory=Components)
68
+ """An element to hold various schemas for the document."""
69
+
70
+ security: list[SecurityRequirement] | None = None
71
+ """A declaration of which security mechanisms can be used across the API.
72
+
73
+ The list of values includes alternative security requirement objects that can be used. Only one of the security
74
+ requirement objects need to be satisfied to authorize a request. Individual operations can override this definition.
75
+ To make security optional, an empty security requirement ( ``{}`` ) can be included in the array.
76
+ """
77
+
78
+ tags: list[Tag] | None = None
79
+ """A list of tags used by the document with additional metadata.
80
+
81
+ The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the
82
+ `Operation Object <https://spec.openapis.org/oas/v3.1.0#operationObject>`_ must be declared. The tags that are not
83
+ declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique.
84
+ """
85
+
86
+ external_docs: ExternalDocumentation | None = None
87
+ """Additional external documentation."""
@@ -0,0 +1,105 @@
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 .callback import Callback
10
+ from .external_documentation import ExternalDocumentation
11
+ from .parameter import Parameter
12
+ from .reference import Reference
13
+ from .request_body import RequestBody
14
+ from .responses import Responses
15
+ from .security_requirement import SecurityRequirement
16
+ from .server import Server
17
+
18
+ __all__ = ("Operation",)
19
+
20
+
21
+ @dataclass
22
+ class Operation(BaseSchemaObject):
23
+ """Describes a single API operation on a path."""
24
+
25
+ tags: list[str] | None = None
26
+ """A list of tags for API documentation control.
27
+
28
+ Tags can be used for logical grouping of operations by resources or any other qualifier.
29
+ """
30
+
31
+ summary: str | None = None
32
+ """A short summary of what the operation does."""
33
+
34
+ description: str | None = None
35
+ """A verbose explanation of the operation behavior.
36
+
37
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
38
+ """
39
+
40
+ external_docs: ExternalDocumentation | None = None
41
+ """Additional external documentation for this operation."""
42
+
43
+ operation_id: str | None = None
44
+ """Unique string used to identify the operation.
45
+
46
+ The id MUST be unique among all operations described in the API. The operationId value is **case-sensitive**. Tools
47
+ and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow
48
+ common programming naming conventions.
49
+ """
50
+
51
+ parameters: list[Parameter | Reference] | None = None
52
+ """A list of parameters that are applicable for this operation.
53
+
54
+ If a parameter is already defined at the `Path Item <https://spec.openapis.org/oas/v3.1.0#pathItemParameters>`_,
55
+ the new definition will override it but can never remove it. The list MUST NOT include duplicated parameters. A
56
+ unique parameter is defined by a combination of a `name <https://spec.openapis.org/oas/v3.1.0#parameterName>`_ and
57
+ `location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_. The list can use the
58
+ `Reference Object <https://spec.openapis.org/oas/v3.1.0#referenceObject>`_ to link to parameters that are defined at
59
+ the `OpenAPI Object's components/parameters <https://spec.openapis.org/oas/v3.1.0#componentsParameters>`_.
60
+ """
61
+
62
+ request_body: RequestBody | Reference | None = None
63
+ """The request body applicable for this operation.
64
+
65
+ The ``requestBody`` is fully supported in HTTP methods where the HTTP 1.1 specification
66
+ :rfc:`7231` has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague (such
67
+ as `GET <https://tools.ietf.org/html/rfc7231#section-4.3.1>`_,
68
+ `HEAD <https://tools.ietf.org/html/rfc7231#section-4.3.2>`_ and
69
+ `DELETE <https://tools.ietf.org/html/rfc7231#section-4.3.5>`_, ``requestBody`` is permitted but does not have
70
+ well-defined semantics and SHOULD be avoided if possible.
71
+ """
72
+
73
+ responses: Responses | None = None
74
+ """The list of possible responses as they are returned from executing this operation."""
75
+
76
+ callbacks: dict[str, Callback | Reference] | None = None
77
+ """A map of possible out-of band callbacks related to the parent operation.
78
+
79
+ The key is a unique identifier for the Callback Object. Each value in the map is a
80
+ `Callback Object <https://spec.openapis.org/oas/v3.1.0#callbackObject>`_ that describes a request that may be
81
+ initiated by the API provider and the expected responses.
82
+ """
83
+
84
+ deprecated: bool = False
85
+ """Declares this operation to be deprecated.
86
+
87
+ Consumers SHOULD refrain from usage of the declared operation. Default value is ``False``.
88
+ """
89
+
90
+ security: list[SecurityRequirement] | None = None
91
+ """A declaration of which security mechanisms can be used for this operation.
92
+
93
+ The list of values includes alternative security requirement objects that can be used. Only one of the security
94
+ requirement objects need to be satisfied to authorize a request. To make security optional, an empty security
95
+ requirement (``{}``) can be included in the array. This definition overrides any declared top-level
96
+ `security <https://spec.openapis.org/oas/v3.1.0#oasSecurity>`_. To remove a top-level security declaration, an empty
97
+ array can be used.
98
+ """
99
+
100
+ servers: list[Server] | None = None
101
+ """An alternative ``server`` array to service this operation.
102
+
103
+ If an alternative ``server`` object is specified at the Path Item Object or Root level, it will be overridden by
104
+ this value.
105
+ """
@@ -0,0 +1,147 @@
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 collections.abc import Mapping
10
+
11
+ from .example import Example
12
+ from .media_type import OpenAPIMediaType
13
+ from .reference import Reference
14
+ from .schema import Schema
15
+
16
+ __all__ = ("Parameter",)
17
+
18
+
19
+ @dataclass
20
+ class Parameter(BaseSchemaObject):
21
+ """Describes a single operation parameter.
22
+
23
+ A unique parameter is defined by a combination of a `name <https://spec.openapis.org/oas/v3.1.0#parameterName>`_ and
24
+ `location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_.
25
+ """
26
+
27
+ name: str
28
+ """
29
+ **REQUIRED**. The name of the parameter.
30
+ Parameter names are *case sensitive*.
31
+
32
+ - If `in <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ is ``"path"``, the ``name`` field MUST correspond to a
33
+ template expression occurring within the `path <https://spec.openapis.org/oas/v3.1.0#pathsPath>`_ field in the
34
+ `Paths Object <https://spec.openapis.org/oas/v3.1.0#pathsObject>`_. See
35
+ `Path Templating <https://spec.openapis.org/oas/v3.1.0#pathTemplating>`_ for further information.
36
+ - If `in <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ is ``"header"`` and the ``name`` field is
37
+ ``"Accept"``, ``"Content-Type"`` or ``"Authorization"``, the parameter definition SHALL be ignored.
38
+ - For all other cases, the ``name`` corresponds to the parameter name used by the
39
+ `in <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ property.
40
+ """
41
+
42
+ param_in: str
43
+ """
44
+ **REQUIRED**. The location of the parameter. Possible values are
45
+ ``"query"``, ``"header"``, ``"path"`` or ``"cookie"``.
46
+ """
47
+
48
+ schema: Schema | Reference | None = None
49
+ """The schema defining the type used for the parameter."""
50
+
51
+ description: str | None = None
52
+ """A brief description of the parameter. This could contain examples of
53
+ use.
54
+
55
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
56
+ """
57
+
58
+ required: bool = False
59
+ """Determines whether this parameter is mandatory.
60
+
61
+ If the `parameter location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ is ``"path"``, this property is
62
+ **REQUIRED** and its value MUST be ``True``. Otherwise, the property MAY be included and its default value is
63
+ ``False``.
64
+ """
65
+
66
+ deprecated: bool = False
67
+ """Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
68
+
69
+ Default value is ``False``.
70
+ """
71
+
72
+ allow_empty_value: bool = False
73
+ """Sets the ability to pass empty-valued parameters. This is valid only for ``query`` parameters and allows sending
74
+ a parameter with an empty value. Default value is ``False``. If
75
+ `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is used, and if behavior is ``n/a`` (cannot be
76
+ serialized), the value of ``allowEmptyValue`` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is
77
+ likely to be removed in a later revision.
78
+
79
+ The rules for serialization of the parameter are specified in one of two ways. For simpler scenarios, a
80
+ `schema <https://spec.openapis.org/oas/v3.1.0#parameterSchema>`_ and
81
+ `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ can describe the structure and syntax of the
82
+ parameter.
83
+ """
84
+
85
+ style: str | None = None
86
+ """Describes how the parameter value will be serialized depending on the ype of the parameter value. Default values
87
+ (based on value of ``in``):
88
+
89
+ - for ``query`` - ``form``
90
+ - for ``path`` - ``simple``
91
+ - for ``header`` - ``simple``
92
+ - for ``cookie`` - ``form``
93
+ """
94
+
95
+ explode: bool | None = None
96
+ """When this is true, parameter values of type ``array`` or ``object`` generate separate parameters for each value
97
+ of the array or key-value pair of the map.
98
+
99
+ For other types of parameters this property has no effect. When
100
+ `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is ``form``, the default value is ``True``. For all
101
+ other styles, the default value is ``False``.
102
+ """
103
+
104
+ allow_reserved: bool = False
105
+ """Determines whether the parameter value SHOULD allow reserved characters, as defined by.
106
+
107
+ :rfc:`3986` ``:/?#[]@!$&'()*+,;=`` to be included without percent-encoding.
108
+
109
+ This property only applies to parameters with an ``in`` value of ``query``. The default value is ``False``.
110
+ """
111
+
112
+ example: Any | None = None
113
+ """Example of the parameter's potential value.
114
+
115
+ The example SHOULD match the specified schema and encoding properties if present. The ``example`` field is mutually
116
+ exclusive of the ``examples`` field. Furthermore, if referencing a ``schema`` that contains an example, the
117
+ ``example`` value SHALL _override_ the example provided by the schema. To represent examples of media types that
118
+ cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where
119
+ necessary.
120
+ """
121
+
122
+ examples: Mapping[str, Example | Reference] | None = None
123
+ """Examples of the parameter's potential value. Each example SHOULD contain a value in the correct format as
124
+ specified in the parameter encoding. The ``examples`` field is mutually exclusive of the ``example`` field.
125
+ Furthermore, if referencing a ``schema`` that contains an example, the ``examples`` value SHALL _override_ the
126
+ example provided by the schema.
127
+
128
+ For more complex scenarios, the `content <https://spec.openapis.org/oas/v3.1.0#parameterContent>`_ property can
129
+ define the media type and schema of the parameter. A parameter MUST contain either a ``schema`` property, or a
130
+ ``content`` property, but not both. When ``example`` or ``examples`` are provided in conjunction with the
131
+ ``schema`` object, the example MUST follow the prescribed serialization strategy for the parameter.
132
+ """
133
+
134
+ content: dict[str, OpenAPIMediaType] | None = None
135
+ """A map containing the representations for the parameter.
136
+
137
+ The key is the media type and the value describes it. The map MUST only contain one entry.
138
+ """
139
+
140
+ @property
141
+ def _exclude_fields(self) -> set[str]:
142
+ exclude = set()
143
+ if self.param_in != "query":
144
+ # these are only allowed in query params
145
+ exclude.update({"allow_empty_value", "allow_reserved"})
146
+
147
+ return exclude
@@ -0,0 +1,78 @@
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 .operation import Operation
10
+ from .parameter import Parameter
11
+ from .reference import Reference
12
+ from .server import Server
13
+
14
+ __all__ = ("PathItem",)
15
+
16
+
17
+ @dataclass
18
+ class PathItem(BaseSchemaObject):
19
+ """Describes the operations available on a single path.
20
+
21
+ A Path Item MAY be empty, due to `ACL constraints <https://spec.openapis.org/oas/v3.1.0#securityFiltering>`_. The
22
+ path itself is still exposed to the documentation viewer, but they will not know which operations and parameters are
23
+ available.
24
+ """
25
+
26
+ ref: str | None = None
27
+ """Allows for an external definition of this path item. The referenced structure MUST be in the format of a
28
+ `Path Item Object <https://spec.openapis.org/oas/v3.1.0#pathItemObject>`.
29
+
30
+ In case a Path Item Object field appears both in the defined object and the referenced object, the behavior is
31
+ undefined. See the rules for resolving
32
+ `Relative References <https://spec.openapis.org/oas/v3.1.0#relativeReferencesURI>`_.
33
+ """
34
+
35
+ summary: str | None = None
36
+ """An optional, string summary, intended to apply to all operations in this path."""
37
+
38
+ description: str | None = None
39
+ """An optional, string description, intended to apply to all operations in this path.
40
+
41
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
42
+ """
43
+
44
+ get: Operation | None = None
45
+ """A definition of a GET operation on this path."""
46
+
47
+ put: Operation | None = None
48
+ """A definition of a PUT operation on this path."""
49
+
50
+ post: Operation | None = None
51
+ """A definition of a POST operation on this path."""
52
+
53
+ delete: Operation | None = None
54
+ """A definition of a DELETE operation on this path."""
55
+
56
+ options: Operation | None = None
57
+ """A definition of a OPTIONS operation on this path."""
58
+
59
+ head: Operation | None = None
60
+ """A definition of a HEAD operation on this path."""
61
+
62
+ patch: Operation | None = None
63
+ """A definition of a PATCH operation on this path."""
64
+
65
+ trace: Operation | None = None
66
+ """A definition of a TRACE operation on this path."""
67
+
68
+ servers: list[Server] | None = None
69
+ """An alternative ``server`` array to service all operations in this path."""
70
+
71
+ parameters: list[Parameter | Reference] | None = None
72
+ """A list of parameters that are applicable for all the operations described under this path. These parameters can
73
+ be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters.
74
+ A unique parameter is defined by a combination of a `name <https://spec.openapis.org/oas/v3.1.0#parameterName>`_ and
75
+ `location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_. The list can use the
76
+ `Reference Object <https://spec.openapis.org/oas/v3.1.0#referenceObject>`_ to link to parameters that are defined at
77
+ the `OpenAPI Object's components/parameters <https://spec.openapis.org/oas/v3.1.0#componentsParameters>`_.
78
+ """
@@ -0,0 +1,27 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING:
6
+ from .path_item import PathItem
7
+
8
+ Paths = dict[str, "PathItem"]
9
+ """Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the.
10
+
11
+ `Server Object <https://spec.openapis.org/oas/v3.1.0#serverObject>`_ in order to construct the full URL.
12
+
13
+ The Paths MAY be empty, due to
14
+ `Access Control List (ACL) constraints <https://spec.openapis.org/oas/v3.1.0#securityFiltering>`_.
15
+
16
+ Patterned Fields
17
+
18
+ /{path}: PathItem
19
+
20
+ A relative path to an individual endpoint. The field name MUST begin with a forward slash (``/``). The path is
21
+ **appended** (no relative URL resolution) to the expanded URL from the
22
+ `Server Object <https://spec.openapis.org/oas/v3.1.0#serverObject>`_ 's ``url`` field in order to construct the full
23
+ URL. `Path templating <https://spec.openapis.org/oas/v3.1.0#pathTemplating>`_ is allowed. When matching URLs, concrete
24
+ (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but
25
+ different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to
26
+ decide which one to use.
27
+ """
@@ -0,0 +1,38 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+
5
+ from .base import BaseSchemaObject
6
+
7
+ __all__ = ("Reference",)
8
+
9
+
10
+ @dataclass
11
+ class Reference(BaseSchemaObject):
12
+ """A simple object to allow referencing other components in the OpenAPI document, internally and externally.
13
+
14
+ The ``$ref`` string value contains a URI `RFC3986 <https://tools.ietf.org/html/rfc3986>`_ , which identifies the
15
+ location of the value being referenced.
16
+
17
+ See the rules for resolving `Relative References <https://spec.openapis.org/oas/v3.1.0#relativeReferencesURI>`_.
18
+ """
19
+
20
+ ref: str
21
+ """**REQUIRED**. The reference identifier. This MUST be in the form of a URI."""
22
+
23
+ summary: str | None = None
24
+ """A short summary which by default SHOULD override that of the referenced component.
25
+
26
+ If the referenced object-type does not allow a ``summary`` field, then this field has no effect.
27
+ """
28
+
29
+ description: str | None = None
30
+ """A description which by default SHOULD override that of the referenced component.
31
+
32
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation. If the referenced
33
+ object-type does not allow a ``description`` field, then this field has no effect.
34
+ """
35
+
36
+ @property
37
+ def value(self) -> str:
38
+ return self.ref.split("/")[-1]
@@ -0,0 +1,38 @@
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 .media_type import OpenAPIMediaType
10
+
11
+ __all__ = ("RequestBody",)
12
+
13
+
14
+ @dataclass
15
+ class RequestBody(BaseSchemaObject):
16
+ """Describes a single request body."""
17
+
18
+ content: dict[str, OpenAPIMediaType]
19
+ """
20
+ **REQUIRED**. The content of the request body.
21
+ The key is a media type or `media type range <https://tools.ietf.org/html/rfc7231#appendix-D>`_ and the value
22
+ describes it.
23
+
24
+ For requests that match multiple keys, only the most specific key is applicable. e.g. ``text/plain`` overrides
25
+ ``text/*``
26
+ """
27
+
28
+ description: str | None = None
29
+ """A brief description of the request body. This could contain examples of use.
30
+
31
+ `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
32
+ """
33
+
34
+ required: bool = False
35
+ """Determines if the request body is required in the request.
36
+
37
+ Defaults to ``False``.
38
+ """