flask-openapi 4.3.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 (53) hide show
  1. flask_openapi/__init__.py +44 -0
  2. flask_openapi/__version__.py +5 -0
  3. flask_openapi/blueprint.py +201 -0
  4. flask_openapi/commands.py +38 -0
  5. flask_openapi/models/__init__.py +91 -0
  6. flask_openapi/models/callback.py +18 -0
  7. flask_openapi/models/components.py +37 -0
  8. flask_openapi/models/contact.py +17 -0
  9. flask_openapi/models/data_type.py +18 -0
  10. flask_openapi/models/discriminator.py +16 -0
  11. flask_openapi/models/encoding.py +27 -0
  12. flask_openapi/models/example.py +19 -0
  13. flask_openapi/models/external_documentation.py +16 -0
  14. flask_openapi/models/file.py +27 -0
  15. flask_openapi/models/header.py +17 -0
  16. flask_openapi/models/info.py +24 -0
  17. flask_openapi/models/license.py +17 -0
  18. flask_openapi/models/link.py +23 -0
  19. flask_openapi/models/media_type.py +24 -0
  20. flask_openapi/models/oauth_flow.py +18 -0
  21. flask_openapi/models/oauth_flows.py +20 -0
  22. flask_openapi/models/operation.py +36 -0
  23. flask_openapi/models/parameter.py +34 -0
  24. flask_openapi/models/parameter_in_type.py +13 -0
  25. flask_openapi/models/path_item.py +36 -0
  26. flask_openapi/models/paths.py +9 -0
  27. flask_openapi/models/reference.py +14 -0
  28. flask_openapi/models/request_body.py +19 -0
  29. flask_openapi/models/response.py +23 -0
  30. flask_openapi/models/responses.py +11 -0
  31. flask_openapi/models/schema.py +59 -0
  32. flask_openapi/models/security_requirement.py +8 -0
  33. flask_openapi/models/security_scheme.py +25 -0
  34. flask_openapi/models/security_scheme_in_type.py +12 -0
  35. flask_openapi/models/server.py +19 -0
  36. flask_openapi/models/server_variable.py +17 -0
  37. flask_openapi/models/style_values.py +14 -0
  38. flask_openapi/models/tag.py +15 -0
  39. flask_openapi/models/validation_error.py +24 -0
  40. flask_openapi/models/xml.py +19 -0
  41. flask_openapi/openapi.py +449 -0
  42. flask_openapi/plugins.py +17 -0
  43. flask_openapi/py.typed +0 -0
  44. flask_openapi/request.py +250 -0
  45. flask_openapi/scaffold.py +547 -0
  46. flask_openapi/templates.py +113 -0
  47. flask_openapi/types.py +27 -0
  48. flask_openapi/utils.py +633 -0
  49. flask_openapi/view.py +230 -0
  50. flask_openapi-4.3.1.dist-info/METADATA +258 -0
  51. flask_openapi-4.3.1.dist-info/RECORD +53 -0
  52. flask_openapi-4.3.1.dist-info/WHEEL +4 -0
  53. flask_openapi-4.3.1.dist-info/licenses/LICENSE.rst +21 -0
@@ -0,0 +1,44 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2021/4/30 10:14
4
+
5
+ from .__version__ import __version__
6
+ from .blueprint import APIBlueprint
7
+ from .models import (
8
+ XML,
9
+ APISpec,
10
+ Components,
11
+ Contact,
12
+ Discriminator,
13
+ Encoding,
14
+ Example,
15
+ ExternalDocumentation,
16
+ FileStorage,
17
+ Header,
18
+ Info,
19
+ License,
20
+ Link,
21
+ MediaType,
22
+ OAuthConfig,
23
+ OAuthFlow,
24
+ OAuthFlows,
25
+ Operation,
26
+ Parameter,
27
+ ParameterInType,
28
+ PathItem,
29
+ RawModel,
30
+ Reference,
31
+ RequestBody,
32
+ Response,
33
+ Schema,
34
+ SecurityScheme,
35
+ Server,
36
+ ServerVariable,
37
+ StyleValues,
38
+ Tag,
39
+ UnprocessableEntity,
40
+ ValidationErrorModel,
41
+ )
42
+ from .openapi import OpenAPI
43
+ from .request import validate_request
44
+ from .view import APIView
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2022/4/30 9:20
4
+
5
+ __version__ = "4.3.1"
@@ -0,0 +1,201 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2022/4/1 16:54
4
+ import inspect
5
+ from typing import Any, Callable
6
+
7
+ from flask import Blueprint
8
+
9
+ from .models import ExternalDocumentation, Server, Tag
10
+ from .scaffold import APIScaffold
11
+ from .types import ParametersTuple, ResponseDict
12
+ from .utils import (
13
+ HTTPMethod,
14
+ convert_responses_key_to_string,
15
+ get_operation,
16
+ get_operation_id_for_path,
17
+ get_responses,
18
+ parse_and_store_tags,
19
+ parse_method,
20
+ parse_parameters,
21
+ parse_rule,
22
+ )
23
+
24
+
25
+ class APIBlueprint(APIScaffold, Blueprint):
26
+ def __init__(
27
+ self,
28
+ name: str,
29
+ import_name: str,
30
+ *,
31
+ abp_tags: list[Tag] | None = None,
32
+ abp_security: list[dict[str, list[str]]] | None = None,
33
+ abp_responses: ResponseDict | None = None,
34
+ doc_ui: bool = True,
35
+ operation_id_callback: Callable = get_operation_id_for_path,
36
+ validate_response: bool | None = None,
37
+ **kwargs: Any,
38
+ ) -> None:
39
+ """
40
+ Based on Flask Blueprint
41
+
42
+ Args:
43
+ name: The name of the blueprint. It Will be prepared to each endpoint name.
44
+ import_name: The name of the blueprint package, usually ``__name__``.
45
+ This helps locate the ``root_path`` for the blueprint.
46
+ abp_tags: APIBlueprint tags for every API.
47
+ abp_security: APIBlueprint security for every API.
48
+ abp_responses: API responses should be either a subclass of BaseModel, a dictionary, or None.
49
+ doc_ui: Enable OpenAPI document UI (Swagger UI, Redoc, and Rapidoc). Defaults to True.
50
+ operation_id_callback: Callback function for custom operation_id generation.
51
+ Receives name (str), path (str) and method (str) parameters.
52
+ Defaults to `get_operation_id_for_path` from utils
53
+ validate_response: Verify the response body.
54
+ **kwargs: Flask Blueprint kwargs
55
+ """
56
+ super(APIBlueprint, self).__init__(name, import_name, **kwargs)
57
+
58
+ # Initialize instance variables
59
+ self.paths: dict = dict()
60
+ self.components_schemas: dict = dict()
61
+ self.tags: list[Tag] = []
62
+ self.tag_names: list[str] = []
63
+
64
+ # Set values from arguments or default values
65
+ self.abp_tags = abp_tags or []
66
+ self.abp_security = abp_security or []
67
+
68
+ # Convert key to string
69
+ self.abp_responses = convert_responses_key_to_string(abp_responses or {})
70
+
71
+ self.doc_ui = doc_ui
72
+
73
+ # Set the operation ID callback function
74
+ self.operation_id_callback: Callable = operation_id_callback
75
+
76
+ # Verify the response body
77
+ self.validate_response = validate_response
78
+
79
+ def register_api(self, api: "APIBlueprint") -> None:
80
+ """Register a nested APIBlueprint"""
81
+
82
+ # Check if the APIBlueprint is being registered on itself
83
+ if api is self:
84
+ raise ValueError("Cannot register a api blueprint on itself")
85
+
86
+ # Merge tags from the nested APIBlueprint
87
+ for tag in api.tags:
88
+ if tag.name not in self.tag_names:
89
+ self.tags.append(tag)
90
+
91
+ # Merge paths from the nested APIBlueprint
92
+ for path_url, path_item in api.paths.items():
93
+ # Parse rule: merge url_prefix and format rule from /pet/<petId> to /pet/{petId}
94
+ uri = parse_rule(path_url, url_prefix=self.url_prefix)
95
+
96
+ self.paths[uri] = path_item
97
+
98
+ # Merge component schemas from the nested APIBlueprint
99
+ self.components_schemas.update(api.components_schemas)
100
+
101
+ # Register the nested APIBlueprint as a blueprint
102
+ self.register_blueprint(api)
103
+
104
+ def _add_url_rule(
105
+ self,
106
+ rule,
107
+ endpoint=None,
108
+ view_func=None,
109
+ provide_automatic_options=None,
110
+ **options,
111
+ ) -> None:
112
+ self.add_url_rule(rule, endpoint, view_func, provide_automatic_options, **options)
113
+
114
+ def _collect_openapi_info(
115
+ self,
116
+ rule: str,
117
+ func: Callable,
118
+ *,
119
+ tags: list[Tag] | None = None,
120
+ summary: str | None = None,
121
+ description: str | None = None,
122
+ external_docs: ExternalDocumentation | None = None,
123
+ operation_id: str | None = None,
124
+ responses: ResponseDict | None = None,
125
+ deprecated: bool | None = None,
126
+ security: list[dict[str, list[Any]]] | None = None,
127
+ servers: list[Server] | None = None,
128
+ openapi_extensions: dict[str, Any] | None = None,
129
+ doc_ui: bool = True,
130
+ method: str = HTTPMethod.GET,
131
+ ) -> ParametersTuple:
132
+ """
133
+ Collects OpenAPI specification information for Flask routes and view functions.
134
+
135
+ Args:
136
+ rule: Flask route
137
+ func: Flask view_func
138
+ tags: Adds metadata to a single tag.
139
+ summary: A short summary of what the operation does.
140
+ description: A verbose explanation of the operation behavior.
141
+ external_docs: Additional external documentation for this operation.
142
+ operation_id: Unique string used to identify the operation.
143
+ responses: API responses should be either a subclass of BaseModel, a dictionary, or None.
144
+ deprecated: Declares this operation to be deprecated.
145
+ security: A declaration of which security mechanisms can be used for this operation.
146
+ servers: An alternative server array to service this operation.
147
+ openapi_extensions: Allows extensions to the OpenAPI Schema.
148
+ doc_ui: Declares this operation to be shown. Default to True.
149
+ """
150
+ if self.doc_ui is True and doc_ui is True:
151
+ # Convert key to string
152
+ new_responses = convert_responses_key_to_string(responses or {})
153
+
154
+ # Global response: combine API responses
155
+ combine_responses = {**self.abp_responses, **new_responses}
156
+
157
+ # Create operation
158
+ operation = get_operation(
159
+ func, summary=summary, description=description, openapi_extensions=openapi_extensions
160
+ )
161
+
162
+ # Set external docs
163
+ if external_docs:
164
+ operation.externalDocs = external_docs
165
+
166
+ # Unique string used to identify the operation.
167
+ operation_id_kwargs = {"name": func.__name__, "path": rule, "method": method}
168
+ if "bp_name" in list(inspect.signature(self.operation_id_callback).parameters.keys()):
169
+ operation_id_kwargs["bp_name"] = self.name
170
+ operation.operationId = operation_id or self.operation_id_callback(**operation_id_kwargs)
171
+
172
+ # Only set `deprecated` if True, otherwise leave it as None
173
+ if deprecated is not None:
174
+ operation.deprecated = deprecated
175
+
176
+ # Add security
177
+ _security = (security or []) + self.abp_security or None
178
+ if _security:
179
+ operation.security = _security
180
+
181
+ # Add servers
182
+ if servers:
183
+ operation.servers = servers
184
+
185
+ # Store tags
186
+ tags = (tags or []) + self.abp_tags
187
+ parse_and_store_tags(tags, self.tags, self.tag_names, operation)
188
+
189
+ # Parse response
190
+ get_responses(combine_responses, self.components_schemas, operation)
191
+
192
+ # Parse rule: merge url_prefix and format rule from /pet/<petId> to /pet/{petId}
193
+ uri = parse_rule(rule, url_prefix=self.url_prefix)
194
+
195
+ # Parse method
196
+ parse_method(uri, method, self.paths, operation)
197
+
198
+ # Parse parameters
199
+ return parse_parameters(func, components_schemas=self.components_schemas, operation=operation)
200
+ else:
201
+ return parse_parameters(func, doc_ui=False)
@@ -0,0 +1,38 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2022/4/16 14:21
4
+ import json
5
+
6
+ from flask import current_app
7
+ from flask.cli import click, with_appcontext
8
+
9
+
10
+ @click.command(name="openapi")
11
+ @click.option("--output", "-o", type=click.Path(), help="The output file path.")
12
+ @click.option("--format", "-f", "_format", type=click.Choice(["json", "yaml"]), help="The output file format.")
13
+ @click.option("--indent", "-i", type=int, help="The indentation for JSON dumps.")
14
+ @with_appcontext
15
+ def openapi_command(output, _format, indent):
16
+ """Export the OpenAPI Specification to console or a file"""
17
+
18
+ # Check if the current app has an api_doc attribute
19
+ if hasattr(current_app, "api_doc"):
20
+ obj = current_app.api_doc
21
+
22
+ # Generate the OpenAPI Specification based on the specified format
23
+ if _format == "yaml":
24
+ try:
25
+ import yaml # type: ignore
26
+ except ImportError: # pragma: no cover
27
+ raise ImportError("pyyaml must be installed.")
28
+ openapi = yaml.safe_dump(obj, allow_unicode=True)
29
+ else:
30
+ openapi = json.dumps(obj, indent=indent, ensure_ascii=False)
31
+
32
+ # Save the OpenAPI Specification to a file if the output path is provided
33
+ if output:
34
+ with open(output, "w", encoding="utf8") as f:
35
+ f.write(openapi)
36
+ click.echo(f"Saved to {output}.")
37
+ else:
38
+ click.echo(openapi)
@@ -0,0 +1,91 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2021/4/28 10:58
4
+ """
5
+ OpenAPI v3.1.0 schema types, created according to the specification:
6
+ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md
7
+
8
+ The type orders are according to the contents of the specification:
9
+ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#table-of-contents
10
+ """
11
+
12
+ from flask import Request
13
+ from pydantic import BaseModel
14
+
15
+ from .callback import Callback
16
+ from .components import Components
17
+ from .contact import Contact
18
+ from .discriminator import Discriminator
19
+ from .encoding import Encoding
20
+ from .example import Example
21
+ from .external_documentation import ExternalDocumentation
22
+ from .file import FileStorage
23
+ from .header import Header
24
+ from .info import Info
25
+ from .license import License
26
+ from .link import Link
27
+ from .media_type import MediaType
28
+ from .oauth_flow import OAuthFlow
29
+ from .oauth_flows import OAuthFlows
30
+ from .operation import Operation
31
+ from .parameter import Parameter
32
+ from .parameter_in_type import ParameterInType
33
+ from .path_item import PathItem
34
+ from .paths import Paths
35
+ from .reference import Reference
36
+ from .request_body import RequestBody
37
+ from .response import Response
38
+ from .responses import Responses
39
+ from .schema import Schema
40
+ from .security_requirement import SecurityRequirement
41
+ from .security_scheme import SecurityScheme
42
+ from .server import Server
43
+ from .server_variable import ServerVariable
44
+ from .style_values import StyleValues
45
+ from .tag import Tag
46
+ from .validation_error import UnprocessableEntity, ValidationErrorModel
47
+ from .xml import XML
48
+
49
+ OPENAPI3_REF_PREFIX = "#/components/schemas"
50
+ OPENAPI3_REF_TEMPLATE = OPENAPI3_REF_PREFIX + "/{model}"
51
+
52
+
53
+ class APISpec(BaseModel):
54
+ """https://spec.openapis.org/oas/v3.1.0#openapi-object"""
55
+
56
+ openapi: str
57
+ info: Info
58
+ servers: list[Server] | None = None
59
+ paths: Paths
60
+ components: Components | None = None
61
+ security: list[SecurityRequirement] | None = None
62
+ tags: list[Tag] | None = None
63
+ externalDocs: ExternalDocumentation | None = None
64
+ webhooks: dict[str, PathItem | Reference] | None = None
65
+
66
+ model_config = {"extra": "allow"}
67
+
68
+
69
+ class OAuthConfig(BaseModel):
70
+ """
71
+ https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/oauth2.md#oauth-20-configuration
72
+ """
73
+
74
+ clientId: str | None = None
75
+ clientSecret: str | None = None
76
+ realm: str | None = None
77
+ appName: str | None = None
78
+ scopeSeparator: str | None = None
79
+ scopes: str | None = None
80
+ additionalQueryStringParams: dict[str, str] | None = None
81
+ useBasicAuthenticationWithAccessCodeGrant: bool | None = False
82
+ usePkceWithAuthorizationCodeGrant: bool | None = False
83
+
84
+
85
+ class RawModel(Request):
86
+ mimetypes: list[str] = ["application/json"]
87
+
88
+
89
+ Encoding.model_rebuild()
90
+ Operation.model_rebuild()
91
+ PathItem.model_rebuild()
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:35
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING: # pragma: no cover
7
+ from .path_item import PathItem
8
+ else:
9
+ PathItem = "PathItem"
10
+
11
+ """
12
+ A map of possible out-of band callbacks related to the parent operation.
13
+ Each value in the map is a [Path Item Object](#pathItemObject)
14
+ that describes a set of requests that may be initiated by the API provider and the expected responses.
15
+ The key value used to identify the path item object is an expression, evaluated at runtime,
16
+ that identifies a URL to use for the callback operation.
17
+ """
18
+ Callback = dict[str, PathItem]
@@ -0,0 +1,37 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:36
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+ from .callback import Callback
9
+ from .example import Example
10
+ from .header import Header
11
+ from .link import Link
12
+ from .parameter import Parameter
13
+ from .path_item import PathItem
14
+ from .reference import Reference
15
+ from .request_body import RequestBody
16
+ from .response import Response
17
+ from .schema import Schema
18
+ from .security_scheme import SecurityScheme
19
+
20
+
21
+ class Components(BaseModel):
22
+ """
23
+ https://spec.openapis.org/oas/v3.1.0#components-object
24
+ """
25
+
26
+ schemas: dict[str, Reference | Schema] | None = Field(None)
27
+ responses: dict[str, Response | Reference] | None = None
28
+ parameters: dict[str, Parameter | Reference] | None = None
29
+ examples: dict[str, Example | Reference] | None = None
30
+ requestBodies: dict[str, RequestBody | Reference] | None = None
31
+ headers: dict[str, Header | Reference] | None = None
32
+ securitySchemes: dict[str, SecurityScheme | dict[str, Any]] | None = None
33
+ links: dict[str, Link | Reference] | None = None
34
+ callbacks: dict[str, Callback | Reference] | None = None
35
+ pathItems: dict[str, PathItem | Reference] | None = None
36
+
37
+ model_config = {"extra": "allow"}
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:37
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class Contact(BaseModel):
9
+ """
10
+ https://spec.openapis.org/oas/v3.1.0#contact-object
11
+ """
12
+
13
+ name: str | None = None
14
+ url: str | None = None
15
+ email: str | None = None
16
+
17
+ model_config = {"extra": "allow"}
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:38
4
+ from enum import Enum
5
+
6
+
7
+ class DataType(str, Enum):
8
+ """
9
+ https://spec.openapis.org/oas/v3.1.0#data-types
10
+ """
11
+
12
+ STRING = "string"
13
+ NUMBER = "number"
14
+ INTEGER = "integer"
15
+ BOOLEAN = "boolean"
16
+ ARRAY = "array"
17
+ OBJECT = "object"
18
+ NUll = "null"
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:41
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class Discriminator(BaseModel):
9
+ """
10
+ https://spec.openapis.org/oas/v3.1.0#discriminator-object
11
+ """
12
+
13
+ propertyName: str
14
+ mapping: dict[str, str] | None = None
15
+
16
+ model_config = {"extra": "allow"}
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:41
4
+ from typing import TYPE_CHECKING, Union
5
+
6
+ from pydantic import BaseModel
7
+
8
+ from .reference import Reference
9
+
10
+ if TYPE_CHECKING: # pragma: no cover
11
+ from .header import Header
12
+ else:
13
+ Header = "Header"
14
+
15
+
16
+ class Encoding(BaseModel):
17
+ """
18
+ https://spec.openapis.org/oas/v3.1.0#encoding-object
19
+ """
20
+
21
+ contentType: str | None = None
22
+ headers: dict[str, Union[Header, Reference]] | None = None
23
+ style: str | None = None
24
+ explode: bool | None = None
25
+ allowReserved: bool = False
26
+
27
+ model_config = {"extra": "allow"}
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:42
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel
7
+
8
+
9
+ class Example(BaseModel):
10
+ """
11
+ https://spec.openapis.org/oas/v3.1.0#example-object
12
+ """
13
+
14
+ summary: str | None = None
15
+ description: str | None = None
16
+ value: Any | None = None
17
+ externalValue: str | None = None
18
+
19
+ model_config = {"extra": "allow"}
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:43
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class ExternalDocumentation(BaseModel):
9
+ """
10
+ https://spec.openapis.org/oas/v3.1.0#external-documentation-object
11
+ """
12
+
13
+ description: str | None = None
14
+ url: str
15
+
16
+ model_config = {"extra": "allow"}
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2021/5/11 16:17
4
+ from typing import Any
5
+
6
+ from pydantic.json_schema import JsonSchemaValue
7
+ from pydantic_core import core_schema
8
+ from werkzeug.datastructures import FileStorage as _FileStorage
9
+
10
+
11
+ class FileStorage(_FileStorage):
12
+ """
13
+ An uploaded file included as part of the request data.
14
+ """
15
+
16
+ @classmethod
17
+ def __get_pydantic_json_schema__(cls, *_args: Any, **_kwargs: Any) -> JsonSchemaValue:
18
+ field_schema = {"format": "binary", "type": "string"}
19
+ return field_schema
20
+
21
+ @classmethod
22
+ def __get_pydantic_core_schema__(cls, *_args: Any, **_kwargs: Any) -> core_schema.CoreSchema:
23
+ return core_schema.with_info_plain_validator_function(cls.validate)
24
+
25
+ @classmethod
26
+ def validate(cls, value: _FileStorage, *_args: Any, **_kwargs: Any) -> _FileStorage:
27
+ return value
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:44
4
+
5
+ from .parameter import Parameter
6
+ from .parameter_in_type import ParameterInType
7
+
8
+
9
+ class Header(Parameter):
10
+ """
11
+ https://spec.openapis.org/oas/v3.1.0#header-object
12
+ """
13
+
14
+ name: str | None = None # type:ignore
15
+ param_in: ParameterInType | None = None # type:ignore
16
+
17
+ model_config = {"extra": "allow"}
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2021/4/28 10:58
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from .contact import Contact
8
+ from .license import License
9
+
10
+
11
+ class Info(BaseModel):
12
+ """
13
+ https://spec.openapis.org/oas/v3.1.0#info-object
14
+ """
15
+
16
+ title: str
17
+ summary: str | None = None
18
+ description: str | None = None
19
+ termsOfService: str | None = None
20
+ contact: Contact | None = None
21
+ license: License | None = None
22
+ version: str
23
+
24
+ model_config = {"extra": "allow"}
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:45
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class License(BaseModel):
9
+ """
10
+ https://spec.openapis.org/oas/v3.1.0#license-object
11
+ """
12
+
13
+ name: str
14
+ identifier: str | None = None
15
+ url: str | None = None
16
+
17
+ model_config = {"extra": "allow"}
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:45
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel
7
+
8
+ from .server import Server
9
+
10
+
11
+ class Link(BaseModel):
12
+ """
13
+ https://spec.openapis.org/oas/v3.1.0#link-object
14
+ """
15
+
16
+ operationRef: str | None = None
17
+ operationId: str | None = None
18
+ parameters: dict[str, Any] | None = None
19
+ requestBody: Any | None = None
20
+ description: str | None = None
21
+ server: Server | None = None
22
+
23
+ model_config = {"extra": "allow"}