-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathmodels.py
More file actions
106 lines (84 loc) · 2.23 KB
/
models.py
File metadata and controls
106 lines (84 loc) · 2.23 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
from typing import List, Optional, Union
from openapi_pydantic.v3.v3_0 import (
Operation as Operation30,
)
from openapi_pydantic.v3.v3_0 import (
PathItem as PathItem30,
)
from openapi_pydantic.v3.v3_0 import (
Schema as Schema30,
)
from openapi_pydantic.v3.v3_1 import (
Operation as Operation31,
)
from openapi_pydantic.v3.v3_1 import (
PathItem as PathItem31,
)
from openapi_pydantic.v3.v3_1 import (
Schema as Schema31,
)
from pydantic import BaseModel
# Type unions for compatibility with both OpenAPI 3.0 and 3.1
Operation = Union[Operation30, Operation31]
PathItem = Union[PathItem30, PathItem31]
Schema = Union[Schema30, Schema31]
class LibraryConfig(BaseModel):
name: str
library_name: str
template_name: str
include_async: bool
include_sync: bool
class TypeConversion(BaseModel):
original_type: str
converted_type: str
import_types: Optional[List[str]] = None
class OpReturnType(BaseModel):
type: Optional[TypeConversion] = None
status_code: int
complex_type: bool = False
list_type: Optional[str] = None
class ServiceOperation(BaseModel):
params: str
operation_id: str
query_params: List[str]
header_params: List[str]
return_type: OpReturnType
operation: Operation
pathItem: PathItem
content: str
async_client: Optional[bool] = False
tag: Optional[str] = None
path_name: str
body_param: Optional[str] = None
method: str
use_orjson: bool = False
class Property(BaseModel):
name: str
type: TypeConversion
required: bool
default: Optional[str]
import_type: Optional[List[str]] = None
class Model(BaseModel):
file_name: str
content: str
openapi_object: Schema
properties: List[Property] = []
class Service(BaseModel):
file_name: str
operations: List[ServiceOperation]
content: str
async_client: Optional[bool] = False
library_import: str
use_orjson: bool = False
class APIConfig(BaseModel):
file_name: str
base_url: str
content: str
class StaticFile(BaseModel):
file_name: str
content: str
class ConversionResult(BaseModel):
models: List[Model]
services: List[Service]
api_config: APIConfig
static_files: List[StaticFile] = []