File: __init__.py

package info (click to toggle)
flask-openapi3 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,976 kB
  • sloc: python: 4,754; sh: 17; makefile: 15; javascript: 5
file content (94 lines) | stat: -rw-r--r-- 2,963 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: utf-8 -*-
# @Author  : llc
# @Time    : 2021/4/28 10:58
"""
OpenAPI v3.1.0 schema types, created according to the specification:
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md

The type orders are according to the contents of the specification:
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#table-of-contents
"""

from typing import Optional, Union

from flask import Request
from pydantic import BaseModel

from .callback import Callback
from .components import Components
from .contact import Contact
from .discriminator import Discriminator
from .encoding import Encoding
from .example import Example
from .external_documentation import ExternalDocumentation
from .file import FileStorage
from .header import Header
from .info import Info
from .license import License
from .link import Link
from .media_type import MediaType
from .oauth_flow import OAuthFlow
from .oauth_flows import OAuthFlows
from .operation import Operation
from .parameter import Parameter
from .parameter_in_type import ParameterInType
from .path_item import PathItem
from .paths import Paths
from .reference import Reference
from .request_body import RequestBody
from .response import Response
from .responses import Responses
from .schema import Schema
from .security_requirement import SecurityRequirement
from .security_scheme import SecurityScheme
from .server import Server
from .server_variable import ServerVariable
from .style_values import StyleValues
from .tag import Tag
from .validation_error import UnprocessableEntity
from .validation_error import ValidationErrorModel
from .xml import XML

OPENAPI3_REF_PREFIX = "#/components/schemas"
OPENAPI3_REF_TEMPLATE = OPENAPI3_REF_PREFIX + "/{model}"


class APISpec(BaseModel):
    """https://spec.openapis.org/oas/v3.1.0#openapi-object"""
    openapi: str
    info: Info
    servers: Optional[list[Server]] = None
    paths: Paths
    components: Optional[Components] = None
    security: Optional[list[SecurityRequirement]] = None
    tags: Optional[list[Tag]] = None
    externalDocs: Optional[ExternalDocumentation] = None
    webhooks: Optional[dict[str, Union[PathItem, Reference]]] = None

    model_config = {
        "extra": "allow"
    }


class OAuthConfig(BaseModel):
    """
    https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/oauth2.md#oauth-20-configuration
    """
    clientId: Optional[str] = None
    clientSecret: Optional[str] = None
    realm: Optional[str] = None
    appName: Optional[str] = None
    scopeSeparator: Optional[str] = None
    scopes: Optional[str] = None
    additionalQueryStringParams: Optional[dict[str, str]] = None
    useBasicAuthenticationWithAccessCodeGrant: Optional[bool] = False
    usePkceWithAuthorizationCodeGrant: Optional[bool] = False


class RawModel(Request):
    mimetypes: list[str] = ["application/json"]


Encoding.model_rebuild()
Operation.model_rebuild()
PathItem.model_rebuild()