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,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:46
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+ from .encoding import Encoding
9
+ from .example import Example
10
+ from .reference import Reference
11
+ from .schema import Schema
12
+
13
+
14
+ class MediaType(BaseModel):
15
+ """
16
+ https://spec.openapis.org/oas/v3.1.0#media-type-object
17
+ """
18
+
19
+ media_type_schema: Reference | Schema | None = Field(default=None, alias="schema")
20
+ example: Any | None = None
21
+ examples: dict[str, Example | Reference] | None = None
22
+ encoding: dict[str, Encoding] | None = None
23
+
24
+ model_config = {"extra": "allow", "populate_by_name": True}
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:47
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class OAuthFlow(BaseModel):
9
+ """
10
+ https://spec.openapis.org/oas/v3.1.0#oauth-flow-object
11
+ """
12
+
13
+ authorizationUrl: str | None = None
14
+ tokenUrl: str | None = None
15
+ refreshUrl: str | None = None
16
+ scopes: dict[str, str]
17
+
18
+ model_config = {"extra": "allow"}
@@ -0,0 +1,20 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:47
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from .oauth_flow import OAuthFlow
8
+
9
+
10
+ class OAuthFlows(BaseModel):
11
+ """
12
+ https://spec.openapis.org/oas/v3.1.0#oauth-flows-object
13
+ """
14
+
15
+ implicit: OAuthFlow | None = None
16
+ password: OAuthFlow | None = None
17
+ clientCredentials: OAuthFlow | None = None
18
+ authorizationCode: OAuthFlow | None = None
19
+
20
+ model_config = {"extra": "allow"}
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:48
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from .callback import Callback
8
+ from .external_documentation import ExternalDocumentation
9
+ from .parameter import Parameter
10
+ from .reference import Reference
11
+ from .request_body import RequestBody
12
+ from .response import Response
13
+ from .security_requirement import SecurityRequirement
14
+ from .server import Server
15
+
16
+
17
+ class Operation(BaseModel):
18
+ """
19
+ https://spec.openapis.org/oas/v3.1.0#operation-object
20
+ """
21
+
22
+ tags: list[str] | None = None
23
+ summary: str | None = None
24
+ description: str | None = None
25
+ externalDocs: ExternalDocumentation | None = None
26
+ operationId: str | None = None
27
+ parameters: list[Parameter] | None = None
28
+ requestBody: RequestBody | Reference | None = None
29
+ responses: dict[str, Response] | None = None
30
+ callbacks: dict[str, Callback] | None = None
31
+
32
+ deprecated: bool | None = False
33
+ security: list[SecurityRequirement] | None = None
34
+ servers: list[Server] | None = None
35
+
36
+ model_config = {"extra": "allow"}
@@ -0,0 +1,34 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:49
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+ from .example import Example
9
+ from .media_type import MediaType
10
+ from .parameter_in_type import ParameterInType
11
+ from .reference import Reference
12
+ from .schema import Schema
13
+
14
+
15
+ class Parameter(BaseModel):
16
+ """
17
+ https://spec.openapis.org/oas/v3.1.0#parameter-object
18
+ """
19
+
20
+ name: str
21
+ param_in: ParameterInType = Field(alias="in")
22
+ description: str | None = None
23
+ required: bool | None = None
24
+ deprecated: bool | None = None
25
+ allowEmptyValue: bool | None = None
26
+ style: str | None = None
27
+ explode: bool | None = None
28
+ allowReserved: bool | None = None
29
+ param_schema: Reference | Schema | None = Field(default=None, alias="schema")
30
+ example: Any | None = None
31
+ examples: dict[str, Example | Reference] | None = None
32
+ content: dict[str, MediaType] | None = None
33
+
34
+ model_config = {"extra": "allow", "populate_by_name": True}
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:49
4
+ from enum import Enum
5
+
6
+
7
+ class ParameterInType(str, Enum):
8
+ """The place Parameters can be put when calling an Endpoint"""
9
+
10
+ QUERY = "query"
11
+ PATH = "path"
12
+ HEADER = "header"
13
+ COOKIE = "cookie"
@@ -0,0 +1,36 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:50
4
+ import typing
5
+ from typing import Optional
6
+
7
+ from pydantic import BaseModel, Field
8
+
9
+ from .parameter import Parameter
10
+ from .reference import Reference
11
+ from .server import Server
12
+
13
+ if typing.TYPE_CHECKING: # pragma: no cover
14
+ from .operation import Operation
15
+
16
+
17
+ class PathItem(BaseModel):
18
+ """
19
+ https://spec.openapis.org/oas/v3.1.0#path-item-object
20
+ """
21
+
22
+ ref: str | None = Field(default=None, alias="$ref")
23
+ summary: str | None = None
24
+ description: str | None = None
25
+ get: Optional["Operation"] = None
26
+ put: Optional["Operation"] = None
27
+ post: Optional["Operation"] = None
28
+ delete: Optional["Operation"] = None
29
+ options: Optional["Operation"] = None
30
+ head: Optional["Operation"] = None
31
+ patch: Optional["Operation"] = None
32
+ trace: Optional["Operation"] = None
33
+ servers: list[Server] | None = None
34
+ parameters: list[Parameter | Reference] | None = None
35
+
36
+ model_config = {"extra": "allow", "populate_by_name": True}
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:52
4
+ from .path_item import PathItem
5
+
6
+ """
7
+ https://spec.openapis.org/oas/v3.1.0#paths-object
8
+ """
9
+ Paths = dict[str, PathItem]
@@ -0,0 +1,14 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:53
4
+ from pydantic import BaseModel, Field
5
+
6
+
7
+ class Reference(BaseModel):
8
+ """
9
+ https://spec.openapis.org/oas/v3.1.0#reference-object
10
+ """
11
+
12
+ ref: str = Field(..., alias="$ref")
13
+
14
+ model_config = {"extra": "allow", "populate_by_name": True}
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:53
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from .media_type import MediaType
8
+
9
+
10
+ class RequestBody(BaseModel):
11
+ """
12
+ https://spec.openapis.org/oas/v3.1.0#request-body-object
13
+ """
14
+
15
+ description: str | None = None
16
+ content: dict[str, MediaType]
17
+ required: bool | None = True
18
+
19
+ model_config = {"extra": "allow"}
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:54
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from .header import Header
8
+ from .link import Link
9
+ from .media_type import MediaType
10
+ from .reference import Reference
11
+
12
+
13
+ class Response(BaseModel):
14
+ """
15
+ https://spec.openapis.org/oas/v3.1.0#response-object
16
+ """
17
+
18
+ description: str
19
+ headers: dict[str, Header | Reference] | None = None
20
+ content: dict[str, MediaType] | None = None
21
+ links: dict[str, Link | Reference] | None = None
22
+
23
+ model_config = {"extra": "allow"}
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:55
4
+
5
+ from .reference import Reference
6
+ from .response import Response
7
+
8
+ """
9
+ https://spec.openapis.org/oas/v3.1.0#responses-object
10
+ """
11
+ Responses = dict[str, Response | Reference]
@@ -0,0 +1,59 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:55
4
+ from typing import Any, Union
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+ from .data_type import DataType
9
+ from .discriminator import Discriminator
10
+ from .external_documentation import ExternalDocumentation
11
+ from .reference import Reference
12
+ from .xml import XML
13
+
14
+
15
+ class Schema(BaseModel):
16
+ """
17
+ https://spec.openapis.org/oas/v3.1.0#schema-object
18
+ """
19
+
20
+ ref: str | None = Field(alias="$ref", default=None)
21
+ title: str | None = None
22
+ multipleOf: float | None = Field(default=None, gt=0.0)
23
+ maximum: int | float | None = None
24
+ exclusiveMaximum: float | None = None
25
+ minimum: float | None = None
26
+ exclusiveMinimum: float | None = None
27
+ maxLength: int | None = Field(default=None, ge=0)
28
+ minLength: int | None = Field(default=None, ge=0)
29
+ pattern: str | None = None
30
+ maxItems: int | None = Field(default=None, ge=0)
31
+ minItems: int | None = Field(default=None, ge=0)
32
+ uniqueItems: bool | None = None
33
+ maxProperties: int | None = Field(default=None, ge=0)
34
+ minProperties: int | None = Field(default=None, ge=0)
35
+ required: list[str] | None = Field(default=None)
36
+ enum: None | list[Any] = Field(default=None)
37
+ type: DataType | None = Field(default=None)
38
+ allOf: list[Union[Reference, "Schema"]] | None = None
39
+ oneOf: list[Union[Reference, "Schema"]] | None = None
40
+ anyOf: list[Union[Reference, "Schema"]] | None = None
41
+ schema_not: Union[Reference, "Schema"] | None = Field(default=None, alias="not")
42
+ items: Union[Reference, "Schema"] | None = None
43
+ properties: dict[str, Union[Reference, "Schema"]] | None = None
44
+ prefixItems: list[Union[Reference, "Schema"]] | None = None
45
+ additionalProperties: Union[bool, Reference, "Schema"] | None = None
46
+ description: str | None = None
47
+ schema_format: str | None = Field(default=None, alias="format")
48
+ default: Any | None = None
49
+ nullable: bool | None = None
50
+ discriminator: Discriminator | None = None
51
+ readOnly: bool | None = None
52
+ writeOnly: bool | None = None
53
+ xml: XML | None = None
54
+ externalDocs: ExternalDocumentation | None = None
55
+ example: Any | None = None
56
+ deprecated: bool | None = None
57
+ const: Any | None = None
58
+
59
+ model_config = {"populate_by_name": True}
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:56
4
+ """
5
+ https://spec.openapis.org/oas/v3.1.0#security-requirement-object
6
+ """
7
+
8
+ SecurityRequirement = dict[str, list[str]]
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:56
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+ from .oauth_flows import OAuthFlows
8
+ from .security_scheme_in_type import SecuritySchemeInType
9
+
10
+
11
+ class SecurityScheme(BaseModel):
12
+ """
13
+ https://spec.openapis.org/oas/v3.1.0#security-scheme-object
14
+ """
15
+
16
+ type: str
17
+ description: str | None = None
18
+ name: str | None = None
19
+ security_scheme_in: SecuritySchemeInType | None = Field(default=None, alias="in")
20
+ scheme: str | None = None
21
+ bearerFormat: str | None = None
22
+ flows: OAuthFlows | None = None
23
+ openIdConnectUrl: str | None = None
24
+
25
+ model_config = {"extra": "allow", "populate_by_name": True}
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/4/7 11:13
4
+ from enum import Enum
5
+
6
+
7
+ class SecuritySchemeInType(str, Enum):
8
+ """The place Parameters can be put when calling an Endpoint"""
9
+
10
+ QUERY = "query"
11
+ HEADER = "header"
12
+ COOKIE = "cookie"
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2021/4/28 11:26
4
+
5
+ from pydantic import BaseModel
6
+
7
+ from .server_variable import ServerVariable
8
+
9
+
10
+ class Server(BaseModel):
11
+ """
12
+ https://spec.openapis.org/oas/v3.1.0#server-object
13
+ """
14
+
15
+ url: str
16
+ description: str | None = None
17
+ variables: dict[str, ServerVariable] | None = None
18
+
19
+ model_config = {"extra": "allow"}
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:57
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+
8
+ class ServerVariable(BaseModel):
9
+ """
10
+ https://spec.openapis.org/oas/v3.1.0#server-variable-object
11
+ """
12
+
13
+ enum: list[str] | None = Field(None, min_length=1)
14
+ default: str
15
+ description: str | None = None
16
+
17
+ model_config = {"extra": "allow"}
@@ -0,0 +1,14 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/4/6 16:29
4
+ from enum import Enum
5
+
6
+
7
+ class StyleValues(str, Enum):
8
+ matrix = "matrix"
9
+ label = "label"
10
+ form = "form"
11
+ simple = "simple"
12
+ spaceDelimited = "spaceDelimited"
13
+ pipeDelimited = "pipeDelimited"
14
+ deepObject = "deepObject"
@@ -0,0 +1,15 @@
1
+ from pydantic import BaseModel
2
+
3
+ from .external_documentation import ExternalDocumentation
4
+
5
+
6
+ class Tag(BaseModel):
7
+ """
8
+ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#tag-object
9
+ """
10
+
11
+ name: str
12
+ description: str | None = None
13
+ externalDocs: ExternalDocumentation | None = None
14
+
15
+ model_config = {"extra": "allow"}
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2021/5/10 14:51
4
+ from typing import Any
5
+
6
+ from pydantic import BaseModel, Field
7
+
8
+
9
+ class ValidationErrorModel(BaseModel):
10
+ # More information: https://docs.pydantic.dev/latest/concepts/models/#error-handling
11
+ type: str = Field(..., title="Error Type", description="A computer-readable identifier of the error type.")
12
+ loc: list[Any] = Field(..., title="Location", description="The error's location as a list.")
13
+ msg: str = Field(..., title="Message", description="A human readable explanation of the error.")
14
+ input: Any = Field(..., title="Input", description="The input provided for validation.")
15
+ url: str | None = Field(None, title="URL", description="The URL to further information about the error.")
16
+ ctx: dict[str, Any] | None = Field(
17
+ None,
18
+ title="Error context",
19
+ description="An optional object which contains values required to render the error message.",
20
+ )
21
+
22
+
23
+ # backward compatibility
24
+ UnprocessableEntity = ValidationErrorModel
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : llc
3
+ # @Time : 2023/7/4 9:58
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class XML(BaseModel):
9
+ """
10
+ https://spec.openapis.org/oas/v3.1.0#xml-object
11
+ """
12
+
13
+ name: str | None = None
14
+ namespace: str | None = None
15
+ prefix: str | None = None
16
+ attribute: bool = False
17
+ wrapped: bool = False
18
+
19
+ model_config = {"extra": "allow"}