swagger-sdk-generator 0.0.0-stage → 3.0.0
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.
- package/README.md +58 -2
- package/dist/cli/commands/generate.d.ts +2 -0
- package/dist/cli/commands/generate.js +196 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.js +130 -0
- package/dist/cli/commands/inspect.d.ts +2 -0
- package/dist/cli/commands/inspect.js +164 -0
- package/dist/cli/commands/templates.d.ts +2 -0
- package/dist/cli/commands/templates.js +126 -0
- package/dist/cli/context.d.ts +16 -0
- package/dist/cli/context.js +85 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +25 -0
- package/dist/config/dotenv.d.ts +2 -0
- package/dist/config/dotenv.js +82 -0
- package/dist/config/interpolate.d.ts +8 -0
- package/dist/config/interpolate.js +85 -0
- package/dist/config/load.d.ts +11 -0
- package/dist/config/load.js +182 -0
- package/dist/config/migrate-v3.d.ts +5 -0
- package/dist/config/migrate-v3.js +6 -0
- package/dist/config/mode-compatibility.d.ts +9 -0
- package/dist/config/mode-compatibility.js +17 -0
- package/dist/config/modes.d.ts +13 -0
- package/dist/config/modes.js +27 -0
- package/dist/config/preset-definitions.d.ts +2 -0
- package/dist/config/preset-definitions.js +4 -0
- package/dist/config/presets.d.ts +25 -0
- package/dist/config/presets.js +36 -0
- package/dist/config/resolve.d.ts +32 -0
- package/dist/config/resolve.js +288 -0
- package/dist/config/schema.d.ts +93 -0
- package/dist/config/schema.js +173 -0
- package/dist/config/types.d.ts +42 -0
- package/dist/config/types.js +2 -0
- package/dist/config/workspace.d.ts +30 -0
- package/dist/config/workspace.js +95 -0
- package/dist/core/case-align.d.ts +5 -0
- package/dist/core/case-align.js +90 -0
- package/dist/core/deep-merge.d.ts +2 -0
- package/dist/core/deep-merge.js +21 -0
- package/dist/core/file-set.d.ts +10 -0
- package/dist/core/file-set.js +31 -0
- package/dist/core/import-module.d.ts +1 -0
- package/dist/core/import-module.js +61 -0
- package/dist/core/log.d.ts +9 -0
- package/dist/core/log.js +24 -0
- package/dist/core/manifest.d.ts +17 -0
- package/dist/core/manifest.js +195 -0
- package/dist/core/overlaps.d.ts +6 -0
- package/dist/core/overlaps.js +67 -0
- package/dist/core/package-version.d.ts +1 -0
- package/dist/core/package-version.js +44 -0
- package/dist/core/pipeline.d.ts +30 -0
- package/dist/core/pipeline.js +335 -0
- package/dist/core/plugin.d.ts +72 -0
- package/dist/core/plugin.js +2 -0
- package/dist/core/targets.d.ts +14 -0
- package/dist/core/targets.js +120 -0
- package/dist/core/unmanaged.d.ts +3 -0
- package/dist/core/unmanaged.js +101 -0
- package/dist/core/writer.d.ts +28 -0
- package/dist/core/writer.js +148 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +37 -0
- package/dist/ir/casing.d.ts +5 -0
- package/dist/ir/casing.js +22 -0
- package/dist/ir/graph.d.ts +8 -0
- package/dist/ir/graph.js +95 -0
- package/dist/ir/operations/grouping.d.ts +17 -0
- package/dist/ir/operations/grouping.js +39 -0
- package/dist/ir/operations/legacy-naming.d.ts +2 -0
- package/dist/ir/operations/legacy-naming.js +8 -0
- package/dist/ir/operations/naming.d.ts +6 -0
- package/dist/ir/operations/naming.js +54 -0
- package/dist/ir/option-errors.d.ts +3 -0
- package/dist/ir/option-errors.js +68 -0
- package/dist/ir/transforms/builtins.d.ts +2 -0
- package/dist/ir/transforms/builtins.js +4 -0
- package/dist/ir/transforms/index.d.ts +10 -0
- package/dist/ir/transforms/index.js +39 -0
- package/dist/ir/transforms/types.d.ts +9 -0
- package/dist/ir/transforms/types.js +2 -0
- package/dist/ir/types.d.ts +140 -0
- package/dist/ir/types.js +2 -0
- package/dist/runtime/axios.d.ts +28 -0
- package/dist/runtime/axios.js +132 -0
- package/dist/runtime/fetch.d.ts +6 -0
- package/dist/runtime/fetch.js +38 -0
- package/dist/runtime/index.d.ts +54 -0
- package/dist/runtime/index.js +167 -0
- package/dist/runtime/rtk.d.ts +35 -0
- package/dist/runtime/rtk.js +36 -0
- package/dist/runtime/transport.d.ts +38 -0
- package/dist/runtime/transport.js +30 -0
- package/dist/runtime/wire.d.ts +27 -0
- package/dist/runtime/wire.js +148 -0
- package/dist/spec/html-entities.d.ts +1 -0
- package/dist/spec/html-entities.js +25 -0
- package/dist/spec/load.d.ts +26 -0
- package/dist/spec/load.js +130 -0
- package/dist/spec/openapi/all-of.d.ts +3 -0
- package/dist/spec/openapi/all-of.js +9 -0
- package/dist/spec/openapi/normalize.d.ts +4 -0
- package/dist/spec/openapi/normalize.js +31 -0
- package/dist/spec/openapi/operations.d.ts +4 -0
- package/dist/spec/openapi/operations.js +173 -0
- package/dist/spec/openapi/schema.d.ts +51 -0
- package/dist/spec/openapi/schema.js +307 -0
- package/dist/targets/declarative/config.d.ts +533 -0
- package/dist/targets/declarative/config.js +280 -0
- package/dist/targets/declarative/extensions.d.ts +45 -0
- package/dist/targets/declarative/extensions.js +123 -0
- package/dist/targets/declarative/files.d.ts +13 -0
- package/dist/targets/declarative/files.js +127 -0
- package/dist/targets/declarative/format.d.ts +4 -0
- package/dist/targets/declarative/format.js +104 -0
- package/dist/targets/declarative/index.d.ts +9 -0
- package/dist/targets/declarative/index.js +170 -0
- package/dist/targets/declarative/liquid.d.ts +8 -0
- package/dist/targets/declarative/liquid.js +57 -0
- package/dist/targets/declarative/naming-case.d.ts +3 -0
- package/dist/targets/declarative/naming-case.js +31 -0
- package/dist/targets/declarative/naming.d.ts +42 -0
- package/dist/targets/declarative/naming.js +174 -0
- package/dist/targets/declarative/scaffold.d.ts +5 -0
- package/dist/targets/declarative/scaffold.js +146 -0
- package/dist/targets/declarative/types.d.ts +52 -0
- package/dist/targets/declarative/types.js +287 -0
- package/dist/targets/declarative/views.d.ts +180 -0
- package/dist/targets/declarative/views.js +447 -0
- package/dist/targets/python/extensions.js +152 -0
- package/dist/targets/python/target.json +549 -0
- package/dist/targets/python/templates/client/client.liquid +114 -0
- package/dist/targets/python/templates/client/httpx_transport.liquid +172 -0
- package/dist/targets/python/templates/client/init.liquid +20 -0
- package/dist/targets/python/templates/client/partials/operation_method.liquid +41 -0
- package/dist/targets/python/templates/client/resource.liquid +28 -0
- package/dist/targets/python/templates/client/runtime.liquid +133 -0
- package/dist/targets/python/templates/client/transport.liquid +62 -0
- package/dist/targets/python/templates/models/module.liquid +48 -0
- package/dist/targets/python/templates/models/partials/docstring.liquid +5 -0
- package/dist/targets/python/templates/models/partials/enum_class.liquid +11 -0
- package/dist/targets/python/templates/models/partials/field_line.liquid +5 -0
- package/dist/targets/python/templates/models/partials/model_class.liquid +17 -0
- package/dist/targets/typescript/compatibility-naming.d.ts +6 -0
- package/dist/targets/typescript/compatibility-naming.js +28 -0
- package/dist/targets/typescript/compatibility-options.d.ts +5 -0
- package/dist/targets/typescript/compatibility-options.js +8 -0
- package/dist/targets/typescript/compatibility-target.d.ts +5 -0
- package/dist/targets/typescript/compatibility-target.js +10 -0
- package/dist/targets/typescript/http-operations.d.ts +34 -0
- package/dist/targets/typescript/http-operations.js +155 -0
- package/dist/targets/typescript/imports.d.ts +43 -0
- package/dist/targets/typescript/imports.js +154 -0
- package/dist/targets/typescript/index.d.ts +7 -0
- package/dist/targets/typescript/index.js +52 -0
- package/dist/targets/typescript/mock-compatibility.d.ts +4 -0
- package/dist/targets/typescript/mock-compatibility.js +6 -0
- package/dist/targets/typescript/mock-hints.d.ts +13 -0
- package/dist/targets/typescript/mock-hints.js +75 -0
- package/dist/targets/typescript/mock-reachability.d.ts +12 -0
- package/dist/targets/typescript/mock-reachability.js +87 -0
- package/dist/targets/typescript/model-compatibility.d.ts +14 -0
- package/dist/targets/typescript/model-compatibility.js +16 -0
- package/dist/targets/typescript/naming.d.ts +13 -0
- package/dist/targets/typescript/naming.js +50 -0
- package/dist/targets/typescript/options.d.ts +124 -0
- package/dist/targets/typescript/options.js +90 -0
- package/dist/targets/typescript/outputs/client.d.ts +67 -0
- package/dist/targets/typescript/outputs/client.js +187 -0
- package/dist/targets/typescript/outputs/mocks.d.ts +32 -0
- package/dist/targets/typescript/outputs/mocks.js +371 -0
- package/dist/targets/typescript/outputs/models.d.ts +85 -0
- package/dist/targets/typescript/outputs/models.js +246 -0
- package/dist/targets/typescript/outputs/rtk-query.d.ts +69 -0
- package/dist/targets/typescript/outputs/rtk-query.js +266 -0
- package/dist/targets/typescript/prettier.d.ts +7 -0
- package/dist/targets/typescript/prettier.js +44 -0
- package/dist/targets/typescript/templates/client/client.liquid +30 -0
- package/dist/targets/typescript/templates/client/partials/api-member.liquid +13 -0
- package/dist/targets/typescript/templates/client/partials/jsdoc.liquid +10 -0
- package/dist/targets/typescript/templates/client/partials/method.liquid +26 -0
- package/dist/targets/typescript/templates/client/partials/query-type.liquid +10 -0
- package/dist/targets/typescript/templates/client/resource.liquid +34 -0
- package/dist/targets/typescript/templates/mocks/mock.liquid +15 -0
- package/dist/targets/typescript/templates/mocks/partials/factory.liquid +12 -0
- package/dist/targets/typescript/templates/mocks/partials/imports.liquid +7 -0
- package/dist/targets/typescript/templates/models/alias.liquid +16 -0
- package/dist/targets/typescript/templates/models/enum.liquid +27 -0
- package/dist/targets/typescript/templates/models/index.liquid +14 -0
- package/dist/targets/typescript/templates/models/model.liquid +25 -0
- package/dist/targets/typescript/templates/models/partials/const.liquid +10 -0
- package/dist/targets/typescript/templates/models/partials/imports.liquid +9 -0
- package/dist/targets/typescript/templates/models/partials/jsdoc.liquid +9 -0
- package/dist/targets/typescript/templates/models/partials/property.liquid +7 -0
- package/dist/targets/typescript/templates/rtk-query/api.liquid +16 -0
- package/dist/targets/typescript/templates/rtk-query/partials/arg-types.liquid +6 -0
- package/dist/targets/typescript/templates/rtk-query/partials/endpoint-mutation.liquid +13 -0
- package/dist/targets/typescript/templates/rtk-query/partials/endpoint-query.liquid +13 -0
- package/dist/targets/typescript/templates/rtk-query/partials/file-warning.liquid +7 -0
- package/dist/targets/typescript/templates/rtk-query/partials/hooks.liquid +9 -0
- package/dist/targets/typescript/templates/rtk-query/partials/imports.liquid +7 -0
- package/dist/targets/typescript/templates/rtk-query/partials/request-config.liquid +9 -0
- package/dist/targets/typescript/templates/rtk-query/resource.liquid +40 -0
- package/dist/targets/typescript/ts-type.d.ts +70 -0
- package/dist/targets/typescript/ts-type.js +62 -0
- package/dist/targets/typescript/type-printer.d.ts +21 -0
- package/dist/targets/typescript/type-printer.js +115 -0
- package/dist/templates/engine.d.ts +20 -0
- package/dist/templates/engine.js +161 -0
- package/dist/templates/inspect.d.ts +27 -0
- package/dist/templates/inspect.js +331 -0
- package/package.json +65 -4
- package/schema/sdk-gen.local.schema.json +75 -0
- package/schema/sdk-gen.schema.json +980 -0
- package/schema/sdk-gen.target.schema.json +1384 -0
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../schema/sdk-gen.target.schema.json",
|
|
3
|
+
"name": "python",
|
|
4
|
+
"naming": {
|
|
5
|
+
"reserved": [
|
|
6
|
+
"False",
|
|
7
|
+
"None",
|
|
8
|
+
"True",
|
|
9
|
+
"and",
|
|
10
|
+
"as",
|
|
11
|
+
"assert",
|
|
12
|
+
"async",
|
|
13
|
+
"await",
|
|
14
|
+
"break",
|
|
15
|
+
"class",
|
|
16
|
+
"continue",
|
|
17
|
+
"def",
|
|
18
|
+
"del",
|
|
19
|
+
"elif",
|
|
20
|
+
"else",
|
|
21
|
+
"except",
|
|
22
|
+
"finally",
|
|
23
|
+
"for",
|
|
24
|
+
"from",
|
|
25
|
+
"global",
|
|
26
|
+
"if",
|
|
27
|
+
"import",
|
|
28
|
+
"in",
|
|
29
|
+
"is",
|
|
30
|
+
"lambda",
|
|
31
|
+
"nonlocal",
|
|
32
|
+
"not",
|
|
33
|
+
"or",
|
|
34
|
+
"pass",
|
|
35
|
+
"raise",
|
|
36
|
+
"return",
|
|
37
|
+
"try",
|
|
38
|
+
"while",
|
|
39
|
+
"with",
|
|
40
|
+
"yield"
|
|
41
|
+
],
|
|
42
|
+
"escape": "{{ name }}_",
|
|
43
|
+
"invalid": "_{{ name }}",
|
|
44
|
+
"type": {
|
|
45
|
+
"case": "pascal",
|
|
46
|
+
"empty": "Model",
|
|
47
|
+
"reserved": [
|
|
48
|
+
"ArithmeticError",
|
|
49
|
+
"AssertionError",
|
|
50
|
+
"AttributeError",
|
|
51
|
+
"BaseException",
|
|
52
|
+
"BaseExceptionGroup",
|
|
53
|
+
"BlockingIOError",
|
|
54
|
+
"BrokenPipeError",
|
|
55
|
+
"BufferError",
|
|
56
|
+
"BytesWarning",
|
|
57
|
+
"ChildProcessError",
|
|
58
|
+
"ConnectionAbortedError",
|
|
59
|
+
"ConnectionError",
|
|
60
|
+
"ConnectionRefusedError",
|
|
61
|
+
"ConnectionResetError",
|
|
62
|
+
"DeprecationWarning",
|
|
63
|
+
"EOFError",
|
|
64
|
+
"Ellipsis",
|
|
65
|
+
"EncodingWarning",
|
|
66
|
+
"EnvironmentError",
|
|
67
|
+
"Exception",
|
|
68
|
+
"ExceptionGroup",
|
|
69
|
+
"False",
|
|
70
|
+
"FileExistsError",
|
|
71
|
+
"FileNotFoundError",
|
|
72
|
+
"FloatingPointError",
|
|
73
|
+
"FutureWarning",
|
|
74
|
+
"GeneratorExit",
|
|
75
|
+
"IOError",
|
|
76
|
+
"ImportError",
|
|
77
|
+
"ImportWarning",
|
|
78
|
+
"IndentationError",
|
|
79
|
+
"IndexError",
|
|
80
|
+
"InterruptedError",
|
|
81
|
+
"IsADirectoryError",
|
|
82
|
+
"KeyError",
|
|
83
|
+
"KeyboardInterrupt",
|
|
84
|
+
"LookupError",
|
|
85
|
+
"MemoryError",
|
|
86
|
+
"ModuleNotFoundError",
|
|
87
|
+
"NameError",
|
|
88
|
+
"None",
|
|
89
|
+
"NotADirectoryError",
|
|
90
|
+
"NotImplemented",
|
|
91
|
+
"NotImplementedError",
|
|
92
|
+
"OSError",
|
|
93
|
+
"OverflowError",
|
|
94
|
+
"PendingDeprecationWarning",
|
|
95
|
+
"PermissionError",
|
|
96
|
+
"ProcessLookupError",
|
|
97
|
+
"RecursionError",
|
|
98
|
+
"ReferenceError",
|
|
99
|
+
"ResourceWarning",
|
|
100
|
+
"RuntimeError",
|
|
101
|
+
"RuntimeWarning",
|
|
102
|
+
"StopAsyncIteration",
|
|
103
|
+
"StopIteration",
|
|
104
|
+
"SyntaxError",
|
|
105
|
+
"SyntaxWarning",
|
|
106
|
+
"SystemError",
|
|
107
|
+
"SystemExit",
|
|
108
|
+
"TabError",
|
|
109
|
+
"TimeoutError",
|
|
110
|
+
"True",
|
|
111
|
+
"TypeError",
|
|
112
|
+
"UnboundLocalError",
|
|
113
|
+
"UnicodeDecodeError",
|
|
114
|
+
"UnicodeEncodeError",
|
|
115
|
+
"UnicodeError",
|
|
116
|
+
"UnicodeTranslateError",
|
|
117
|
+
"UnicodeWarning",
|
|
118
|
+
"UserWarning",
|
|
119
|
+
"ValueError",
|
|
120
|
+
"Warning",
|
|
121
|
+
"ZeroDivisionError",
|
|
122
|
+
"__debug__",
|
|
123
|
+
"abs",
|
|
124
|
+
"aiter",
|
|
125
|
+
"all",
|
|
126
|
+
"anext",
|
|
127
|
+
"any",
|
|
128
|
+
"ascii",
|
|
129
|
+
"bin",
|
|
130
|
+
"bool",
|
|
131
|
+
"breakpoint",
|
|
132
|
+
"bytearray",
|
|
133
|
+
"bytes",
|
|
134
|
+
"callable",
|
|
135
|
+
"chr",
|
|
136
|
+
"classmethod",
|
|
137
|
+
"compile",
|
|
138
|
+
"complex",
|
|
139
|
+
"copyright",
|
|
140
|
+
"credits",
|
|
141
|
+
"delattr",
|
|
142
|
+
"dict",
|
|
143
|
+
"dir",
|
|
144
|
+
"divmod",
|
|
145
|
+
"enumerate",
|
|
146
|
+
"eval",
|
|
147
|
+
"exec",
|
|
148
|
+
"exit",
|
|
149
|
+
"filter",
|
|
150
|
+
"float",
|
|
151
|
+
"format",
|
|
152
|
+
"frozenset",
|
|
153
|
+
"getattr",
|
|
154
|
+
"globals",
|
|
155
|
+
"hasattr",
|
|
156
|
+
"hash",
|
|
157
|
+
"help",
|
|
158
|
+
"hex",
|
|
159
|
+
"id",
|
|
160
|
+
"input",
|
|
161
|
+
"int",
|
|
162
|
+
"isinstance",
|
|
163
|
+
"issubclass",
|
|
164
|
+
"iter",
|
|
165
|
+
"len",
|
|
166
|
+
"license",
|
|
167
|
+
"list",
|
|
168
|
+
"locals",
|
|
169
|
+
"map",
|
|
170
|
+
"max",
|
|
171
|
+
"memoryview",
|
|
172
|
+
"min",
|
|
173
|
+
"next",
|
|
174
|
+
"object",
|
|
175
|
+
"oct",
|
|
176
|
+
"open",
|
|
177
|
+
"ord",
|
|
178
|
+
"pow",
|
|
179
|
+
"print",
|
|
180
|
+
"property",
|
|
181
|
+
"quit",
|
|
182
|
+
"range",
|
|
183
|
+
"repr",
|
|
184
|
+
"reversed",
|
|
185
|
+
"round",
|
|
186
|
+
"set",
|
|
187
|
+
"setattr",
|
|
188
|
+
"slice",
|
|
189
|
+
"sorted",
|
|
190
|
+
"staticmethod",
|
|
191
|
+
"str",
|
|
192
|
+
"sum",
|
|
193
|
+
"super",
|
|
194
|
+
"tuple",
|
|
195
|
+
"type",
|
|
196
|
+
"vars",
|
|
197
|
+
"zip"
|
|
198
|
+
],
|
|
199
|
+
"qualify": "namespace",
|
|
200
|
+
"unique": true
|
|
201
|
+
},
|
|
202
|
+
"property": {
|
|
203
|
+
"case": {
|
|
204
|
+
"option": "fieldNames",
|
|
205
|
+
"default": "preserve"
|
|
206
|
+
},
|
|
207
|
+
"fallbackCase": "snake",
|
|
208
|
+
"empty": "field",
|
|
209
|
+
"reserved": [
|
|
210
|
+
"model_config"
|
|
211
|
+
],
|
|
212
|
+
"avoid": [
|
|
213
|
+
"@models"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
"enumKey": {
|
|
217
|
+
"case": "snake",
|
|
218
|
+
"empty": "field",
|
|
219
|
+
"reserved": [
|
|
220
|
+
"model_config"
|
|
221
|
+
],
|
|
222
|
+
"after": "{{ name | upcase }}",
|
|
223
|
+
"numeric": "value_{% if negative %}minus_{% endif %}{{ abs }}",
|
|
224
|
+
"null": "none",
|
|
225
|
+
"unique": true
|
|
226
|
+
},
|
|
227
|
+
"operation": {
|
|
228
|
+
"case": "snake",
|
|
229
|
+
"empty": "operation",
|
|
230
|
+
"unique": true
|
|
231
|
+
},
|
|
232
|
+
"param": {
|
|
233
|
+
"case": "snake",
|
|
234
|
+
"empty": "param",
|
|
235
|
+
"reserved": [
|
|
236
|
+
"self",
|
|
237
|
+
"body",
|
|
238
|
+
"headers",
|
|
239
|
+
"response",
|
|
240
|
+
"_runtime",
|
|
241
|
+
"bool",
|
|
242
|
+
"bytes",
|
|
243
|
+
"date",
|
|
244
|
+
"datetime",
|
|
245
|
+
"dict",
|
|
246
|
+
"float",
|
|
247
|
+
"int",
|
|
248
|
+
"list",
|
|
249
|
+
"str"
|
|
250
|
+
],
|
|
251
|
+
"unique": true
|
|
252
|
+
},
|
|
253
|
+
"resource": {
|
|
254
|
+
"case": "pascal",
|
|
255
|
+
"empty": "Root",
|
|
256
|
+
"reserved": [
|
|
257
|
+
"Aclose",
|
|
258
|
+
"And",
|
|
259
|
+
"As",
|
|
260
|
+
"Assert",
|
|
261
|
+
"Async",
|
|
262
|
+
"Await",
|
|
263
|
+
"Break",
|
|
264
|
+
"Class",
|
|
265
|
+
"Close",
|
|
266
|
+
"Continue",
|
|
267
|
+
"Def",
|
|
268
|
+
"Del",
|
|
269
|
+
"Elif",
|
|
270
|
+
"Else",
|
|
271
|
+
"Except",
|
|
272
|
+
"Finally",
|
|
273
|
+
"For",
|
|
274
|
+
"From",
|
|
275
|
+
"Global",
|
|
276
|
+
"If",
|
|
277
|
+
"Import",
|
|
278
|
+
"In",
|
|
279
|
+
"Is",
|
|
280
|
+
"Lambda",
|
|
281
|
+
"Nonlocal",
|
|
282
|
+
"Not",
|
|
283
|
+
"Or",
|
|
284
|
+
"Pass",
|
|
285
|
+
"Raise",
|
|
286
|
+
"Return",
|
|
287
|
+
"Try",
|
|
288
|
+
"While",
|
|
289
|
+
"With",
|
|
290
|
+
"Yield"
|
|
291
|
+
],
|
|
292
|
+
"escape": "{{ name }}Resource",
|
|
293
|
+
"after": "{{ name }}Api",
|
|
294
|
+
"avoid": [
|
|
295
|
+
"@models"
|
|
296
|
+
],
|
|
297
|
+
"unique": true
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
"types": {
|
|
301
|
+
"string": "str",
|
|
302
|
+
"string:date-time": {
|
|
303
|
+
"type": "datetime",
|
|
304
|
+
"imports": [
|
|
305
|
+
{
|
|
306
|
+
"module": "datetime",
|
|
307
|
+
"name": "datetime"
|
|
308
|
+
}
|
|
309
|
+
]
|
|
310
|
+
},
|
|
311
|
+
"string:date": {
|
|
312
|
+
"type": "date",
|
|
313
|
+
"imports": [
|
|
314
|
+
{
|
|
315
|
+
"module": "datetime",
|
|
316
|
+
"name": "date"
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
},
|
|
320
|
+
"string:uuid": {
|
|
321
|
+
"type": "UUID",
|
|
322
|
+
"imports": [
|
|
323
|
+
{
|
|
324
|
+
"module": "uuid",
|
|
325
|
+
"name": "UUID"
|
|
326
|
+
}
|
|
327
|
+
]
|
|
328
|
+
},
|
|
329
|
+
"string:binary": "bytes",
|
|
330
|
+
"integer": "int",
|
|
331
|
+
"number": "float",
|
|
332
|
+
"boolean": "bool",
|
|
333
|
+
"null": "None",
|
|
334
|
+
"any": {
|
|
335
|
+
"type": "Any",
|
|
336
|
+
"imports": [
|
|
337
|
+
{
|
|
338
|
+
"module": "typing",
|
|
339
|
+
"name": "Any"
|
|
340
|
+
}
|
|
341
|
+
]
|
|
342
|
+
},
|
|
343
|
+
"ref": "{{ name }}",
|
|
344
|
+
"ref:unresolved": {
|
|
345
|
+
"type": "Any",
|
|
346
|
+
"imports": [
|
|
347
|
+
{
|
|
348
|
+
"module": "typing",
|
|
349
|
+
"name": "Any"
|
|
350
|
+
}
|
|
351
|
+
]
|
|
352
|
+
},
|
|
353
|
+
"array": "list[{{ items }}]",
|
|
354
|
+
"map": "dict[str, {{ values }}]",
|
|
355
|
+
"object": {
|
|
356
|
+
"type": "dict[str, Any]",
|
|
357
|
+
"imports": [
|
|
358
|
+
{
|
|
359
|
+
"module": "typing",
|
|
360
|
+
"name": "Any"
|
|
361
|
+
}
|
|
362
|
+
]
|
|
363
|
+
},
|
|
364
|
+
"enum": {
|
|
365
|
+
"type": "Literal[{{ literals | join: \", \" }}]",
|
|
366
|
+
"imports": [
|
|
367
|
+
{
|
|
368
|
+
"module": "typing",
|
|
369
|
+
"name": "Literal"
|
|
370
|
+
}
|
|
371
|
+
]
|
|
372
|
+
},
|
|
373
|
+
"union": "{{ members | uniq | join: \" | \" }}",
|
|
374
|
+
"intersection": {
|
|
375
|
+
"type": "Any",
|
|
376
|
+
"imports": [
|
|
377
|
+
{
|
|
378
|
+
"module": "typing",
|
|
379
|
+
"name": "Any"
|
|
380
|
+
}
|
|
381
|
+
],
|
|
382
|
+
"comment": "intersection emitted as Any"
|
|
383
|
+
},
|
|
384
|
+
"literal": {
|
|
385
|
+
"type": "Literal[{{ literal }}]",
|
|
386
|
+
"imports": [
|
|
387
|
+
{
|
|
388
|
+
"module": "typing",
|
|
389
|
+
"name": "Literal"
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
},
|
|
393
|
+
"nullable": "{% if type contains 'None' %}{{ type }}{% else %}{{ type }} | None{% endif %}",
|
|
394
|
+
"optional": "{% assign parts = type | remove: ' ' | split: '|' %}{% if parts contains 'None' %}{{ type }}{% else %}{{ type }} | None{% endif %}",
|
|
395
|
+
"fallback": {
|
|
396
|
+
"type": "Any",
|
|
397
|
+
"imports": [
|
|
398
|
+
{
|
|
399
|
+
"module": "typing",
|
|
400
|
+
"name": "Any"
|
|
401
|
+
}
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
"literals": {
|
|
406
|
+
"null": "None",
|
|
407
|
+
"true": "True",
|
|
408
|
+
"false": "False",
|
|
409
|
+
"string": "{{ value | quote }}",
|
|
410
|
+
"number": "{{ value }}"
|
|
411
|
+
},
|
|
412
|
+
"imports": {
|
|
413
|
+
"ref": {
|
|
414
|
+
"module": "{{ options.modelsModule }}",
|
|
415
|
+
"name": "{{ name }}"
|
|
416
|
+
},
|
|
417
|
+
"group": "from {{ module }} import {{ names | join: \", \" }}",
|
|
418
|
+
"order": [
|
|
419
|
+
"datetime",
|
|
420
|
+
"enum",
|
|
421
|
+
"typing",
|
|
422
|
+
"uuid",
|
|
423
|
+
"pydantic"
|
|
424
|
+
],
|
|
425
|
+
"names": "alphabetical"
|
|
426
|
+
},
|
|
427
|
+
"files": [
|
|
428
|
+
{
|
|
429
|
+
"once": true,
|
|
430
|
+
"contents": [],
|
|
431
|
+
"template": "client/transport",
|
|
432
|
+
"path": "transport.py"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"once": true,
|
|
436
|
+
"contents": [],
|
|
437
|
+
"template": "client/httpx_transport",
|
|
438
|
+
"path": "httpx_transport.py"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"once": true,
|
|
442
|
+
"contents": [],
|
|
443
|
+
"template": "client/client",
|
|
444
|
+
"path": "client.py"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"once": true,
|
|
448
|
+
"contents": [],
|
|
449
|
+
"template": "client/init",
|
|
450
|
+
"path": "__init__.py"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"once": true,
|
|
454
|
+
"contents": [],
|
|
455
|
+
"template": "client/runtime",
|
|
456
|
+
"path": "_runtime.py"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"each": "resource",
|
|
460
|
+
"template": "client/resource",
|
|
461
|
+
"path": "{{ name | snake }}.py"
|
|
462
|
+
}
|
|
463
|
+
],
|
|
464
|
+
"outputs": {
|
|
465
|
+
"models": {
|
|
466
|
+
"description": "Python pydantic v2 models for every schema component",
|
|
467
|
+
"files": [
|
|
468
|
+
{
|
|
469
|
+
"once": true,
|
|
470
|
+
"template": "models/module",
|
|
471
|
+
"path": "{{ options.module }}",
|
|
472
|
+
"order": "dependencies"
|
|
473
|
+
}
|
|
474
|
+
],
|
|
475
|
+
"options": {
|
|
476
|
+
"dir": {
|
|
477
|
+
"type": "string",
|
|
478
|
+
"default": "./models",
|
|
479
|
+
"description": "Output directory (resolved against cwd by the core)."
|
|
480
|
+
},
|
|
481
|
+
"module": {
|
|
482
|
+
"type": "string",
|
|
483
|
+
"default": "models.py",
|
|
484
|
+
"description": "Python module file emitted under the output directory."
|
|
485
|
+
},
|
|
486
|
+
"fieldNames": {
|
|
487
|
+
"type": "string",
|
|
488
|
+
"enum": [
|
|
489
|
+
"preserve",
|
|
490
|
+
"snake"
|
|
491
|
+
],
|
|
492
|
+
"default": "preserve",
|
|
493
|
+
"description": "Python field naming strategy."
|
|
494
|
+
},
|
|
495
|
+
"optionalStyle": {
|
|
496
|
+
"type": "string",
|
|
497
|
+
"enum": [
|
|
498
|
+
"none-default"
|
|
499
|
+
],
|
|
500
|
+
"default": "none-default",
|
|
501
|
+
"description": "Optional fields are typed with `None` and default to `None`."
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
"client": {
|
|
506
|
+
"description": "Python operation client over a generated Transport Protocol, with an optional httpx adapter",
|
|
507
|
+
"files": [
|
|
508
|
+
0,
|
|
509
|
+
1,
|
|
510
|
+
2,
|
|
511
|
+
3,
|
|
512
|
+
4,
|
|
513
|
+
5
|
|
514
|
+
],
|
|
515
|
+
"options": {
|
|
516
|
+
"dir": {
|
|
517
|
+
"type": "string",
|
|
518
|
+
"default": "./client",
|
|
519
|
+
"description": "Output directory (resolved against cwd by the core)."
|
|
520
|
+
},
|
|
521
|
+
"modelsModule": {
|
|
522
|
+
"type": "string",
|
|
523
|
+
"default": "..models.models",
|
|
524
|
+
"description": "Import path of the generated models module, as seen from the client package. The default fits the default layout (models output `./models/models.py` next to client output `./client`, both inside one package); set it when the models output moves (e.g. `..models` for `module: \"__init__.py\"`, or an absolute `myapp.models`)."
|
|
525
|
+
},
|
|
526
|
+
"transport": {
|
|
527
|
+
"type": "string",
|
|
528
|
+
"enum": [
|
|
529
|
+
"httpx",
|
|
530
|
+
"none"
|
|
531
|
+
],
|
|
532
|
+
"default": "httpx",
|
|
533
|
+
"description": "Emit the default httpx transport adapter, or only the transport protocol."
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
"resources": {
|
|
539
|
+
"stripPrefixes": [
|
|
540
|
+
"/api"
|
|
541
|
+
]
|
|
542
|
+
},
|
|
543
|
+
"format": {
|
|
544
|
+
"command": "ruff format --stdin-filename {file} -",
|
|
545
|
+
"stdin": true,
|
|
546
|
+
"enabled": false,
|
|
547
|
+
"maxBlankLines": 1
|
|
548
|
+
}
|
|
549
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{% comment %}
|
|
2
|
+
API entry point: `Api` / `AsyncApi` (one attribute per resource) and the `create_api` /
|
|
3
|
+
`create_async_api` factories over the transport contract.
|
|
4
|
+
Data: FileView (once) — api.resources[] (ResourceView), api.info.servers
|
|
5
|
+
{% endcomment -%}
|
|
6
|
+
{%- assign server = api.info.servers | first | default: '' -%}
|
|
7
|
+
{%- assign scheme = server | split: '://' | first -%}
|
|
8
|
+
{%- assign defaultBaseUrl = '' -%}
|
|
9
|
+
{%- if server contains '://' and server contains '{' -%}{%- elsif server contains '://' -%}
|
|
10
|
+
{%- if scheme == 'http' or scheme == 'https' -%}{%- assign defaultBaseUrl = server -%}{%- endif -%}
|
|
11
|
+
{%- endif -%}
|
|
12
|
+
# Generated by swagger-sdk-generator. Do not edit.
|
|
13
|
+
"""Entry point: `create_api(...)` / `create_async_api(...)`."""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
{% if options.transport != 'none' %}
|
|
17
|
+
from collections.abc import Callable, Mapping
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
19
|
+
{% endif %}
|
|
20
|
+
from .transport import AsyncTransport, Transport
|
|
21
|
+
{% for resource in api.resources -%}
|
|
22
|
+
from .{{ resource.name | snake }} import Async{{ resource.name }}, {{ resource.name }}
|
|
23
|
+
{% endfor -%}
|
|
24
|
+
{% if options.transport != 'none' %}
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
import httpx
|
|
27
|
+
{% endif %}
|
|
28
|
+
|
|
29
|
+
class Api:
|
|
30
|
+
"""Synchronous API: one attribute per resource. `close()` / `with` closes the transport when it can."""
|
|
31
|
+
|
|
32
|
+
def __init__(self, transport: Transport) -> None:
|
|
33
|
+
self._transport = transport
|
|
34
|
+
{% for resource in api.resources -%}
|
|
35
|
+
self.{{ resource.name | remove_last: 'Api' | snake }} = {{ resource.name }}(transport)
|
|
36
|
+
{% endfor %}
|
|
37
|
+
def close(self) -> None:
|
|
38
|
+
close = getattr(self._transport, "close", None)
|
|
39
|
+
if callable(close):
|
|
40
|
+
close()
|
|
41
|
+
|
|
42
|
+
def __enter__(self) -> Api:
|
|
43
|
+
return self
|
|
44
|
+
|
|
45
|
+
def __exit__(self, *exc_info: object) -> None:
|
|
46
|
+
self.close()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class AsyncApi:
|
|
50
|
+
"""Asynchronous API: one attribute per resource. `aclose()` / `async with` closes the transport when it can."""
|
|
51
|
+
|
|
52
|
+
def __init__(self, transport: AsyncTransport) -> None:
|
|
53
|
+
self._transport = transport
|
|
54
|
+
{% for resource in api.resources -%}
|
|
55
|
+
self.{{ resource.name | remove_last: 'Api' | snake }} = Async{{ resource.name }}(transport)
|
|
56
|
+
{% endfor %}
|
|
57
|
+
async def aclose(self) -> None:
|
|
58
|
+
aclose = getattr(self._transport, "aclose", None)
|
|
59
|
+
if callable(aclose):
|
|
60
|
+
await aclose()
|
|
61
|
+
|
|
62
|
+
async def __aenter__(self) -> AsyncApi:
|
|
63
|
+
return self
|
|
64
|
+
|
|
65
|
+
async def __aexit__(self, *exc_info: object) -> None:
|
|
66
|
+
await self.aclose()
|
|
67
|
+
|
|
68
|
+
{% if options.transport == 'none' %}
|
|
69
|
+
def create_api(*, transport: Transport) -> Api:
|
|
70
|
+
"""An `Api` over your transport (the generated httpx transport is disabled)."""
|
|
71
|
+
return Api(transport)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def create_async_api(*, transport: AsyncTransport) -> AsyncApi:
|
|
75
|
+
"""An `AsyncApi` over your transport (the generated httpx transport is disabled)."""
|
|
76
|
+
return AsyncApi(transport)
|
|
77
|
+
{% else %}
|
|
78
|
+
def create_api(
|
|
79
|
+
*,
|
|
80
|
+
base_url: str | None = {% if defaultBaseUrl != '' %}{{ defaultBaseUrl | quote }}{% else %}None{% endif %},
|
|
81
|
+
get_token: Callable[[], str | None] | None = None,
|
|
82
|
+
headers: Mapping[str, str] | None = None,
|
|
83
|
+
timeout: float | httpx.Timeout | None = None,
|
|
84
|
+
client: httpx.Client | None = None,
|
|
85
|
+
transport: Transport | None = None,
|
|
86
|
+
) -> Api:
|
|
87
|
+
"""An `Api` over `transport`, or over the default httpx transport (`base_url`, bearer `get_token`, ...)."""
|
|
88
|
+
if transport is None:
|
|
89
|
+
if base_url is None:
|
|
90
|
+
raise ValueError("base_url is required when no transport is given")
|
|
91
|
+
from .httpx_transport import HttpxTransport
|
|
92
|
+
|
|
93
|
+
transport = HttpxTransport(base_url, get_token=get_token, headers=headers, timeout=timeout, client=client)
|
|
94
|
+
return Api(transport)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def create_async_api(
|
|
98
|
+
*,
|
|
99
|
+
base_url: str | None = {% if defaultBaseUrl != '' %}{{ defaultBaseUrl | quote }}{% else %}None{% endif %},
|
|
100
|
+
get_token: Callable[[], str | None] | None = None,
|
|
101
|
+
headers: Mapping[str, str] | None = None,
|
|
102
|
+
timeout: float | httpx.Timeout | None = None,
|
|
103
|
+
client: httpx.AsyncClient | None = None,
|
|
104
|
+
transport: AsyncTransport | None = None,
|
|
105
|
+
) -> AsyncApi:
|
|
106
|
+
"""An `AsyncApi` over `transport`, or over the default async httpx transport."""
|
|
107
|
+
if transport is None:
|
|
108
|
+
if base_url is None:
|
|
109
|
+
raise ValueError("base_url is required when no transport is given")
|
|
110
|
+
from .httpx_transport import AsyncHttpxTransport
|
|
111
|
+
|
|
112
|
+
transport = AsyncHttpxTransport(base_url, get_token=get_token, headers=headers, timeout=timeout, client=client)
|
|
113
|
+
return AsyncApi(transport)
|
|
114
|
+
{% endif %}
|