wellapi 0.2.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.
@@ -0,0 +1,404 @@
1
+ from enum import Enum
2
+ from typing import Annotated, Any, Literal, Optional, Union
3
+
4
+ from pydantic import AnyUrl, BaseModel, EmailStr, Field
5
+ from typing_extensions import TypedDict
6
+
7
+ METHODS_WITH_BODY = {"GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"}
8
+ REF_PREFIX = "#/components/schemas/"
9
+ REF_TEMPLATE = "#/components/schemas/{model}"
10
+
11
+
12
+ class BaseModelWithConfig(BaseModel):
13
+ model_config = {"extra": "allow"}
14
+
15
+
16
+ class Contact(BaseModelWithConfig):
17
+ name: str | None = None
18
+ url: AnyUrl | None = None
19
+ email: EmailStr | None = None
20
+
21
+
22
+ class License(BaseModelWithConfig):
23
+ name: str
24
+ url: AnyUrl | None = None
25
+
26
+
27
+ class Info(BaseModelWithConfig):
28
+ title: str
29
+ description: str | None = None
30
+ termsOfService: str | None = None
31
+ contact: Contact | None = None
32
+ license: License | None = None
33
+ version: str
34
+
35
+
36
+ class ServerVariable(BaseModelWithConfig):
37
+ enum: Annotated[list[str] | None, Field(min_length=1)] = None
38
+ default: str
39
+ description: str | None = None
40
+
41
+
42
+ class Server(BaseModelWithConfig):
43
+ url: AnyUrl | str
44
+ description: str | None = None
45
+ variables: dict[str, ServerVariable] | None = None
46
+
47
+
48
+ class Reference(BaseModel):
49
+ ref: str = Field(alias="$ref")
50
+
51
+
52
+ class Discriminator(BaseModel):
53
+ propertyName: str
54
+ mapping: dict[str, str] | None = None
55
+
56
+
57
+ class XML(BaseModelWithConfig):
58
+ name: str | None = None
59
+ namespace: str | None = None
60
+ prefix: str | None = None
61
+ attribute: bool | None = None
62
+ wrapped: bool | None = None
63
+
64
+
65
+ class ExternalDocumentation(BaseModelWithConfig):
66
+ description: str | None = None
67
+ url: AnyUrl
68
+
69
+
70
+ class Schema(BaseModelWithConfig):
71
+ # Ref: JSON Schema 2020-12: https://json-schema.org/draft/2020-12/json-schema-core.html#name-the-json-schema-core-vocabu
72
+ # Core Vocabulary
73
+ schema_: str | None = Field(default=None, alias="$schema")
74
+ vocabulary: str | None = Field(default=None, alias="$vocabulary")
75
+ id: str | None = Field(default=None, alias="$id")
76
+ anchor: str | None = Field(default=None, alias="$anchor")
77
+ dynamicAnchor: str | None = Field(default=None, alias="$dynamicAnchor")
78
+ ref: str | None = Field(default=None, alias="$ref")
79
+ dynamicRef: str | None = Field(default=None, alias="$dynamicRef")
80
+ defs: dict[str, "SchemaOrBool"] | None = Field(default=None, alias="$defs")
81
+ comment: str | None = Field(default=None, alias="$comment")
82
+ # Ref: JSON Schema 2020-12: https://json-schema.org/draft/2020-12/json-schema-core.html#name-a-vocabulary-for-applying-s
83
+ # A Vocabulary for Applying Subschemas
84
+ allOf: list["SchemaOrBool"] | None = None
85
+ anyOf: list["SchemaOrBool"] | None = None
86
+ oneOf: list["SchemaOrBool"] | None = None
87
+ not_: Optional["SchemaOrBool"] = Field(default=None, alias="not")
88
+ if_: Optional["SchemaOrBool"] = Field(default=None, alias="if")
89
+ then: Optional["SchemaOrBool"] = None
90
+ else_: Optional["SchemaOrBool"] = Field(default=None, alias="else")
91
+ dependentSchemas: dict[str, "SchemaOrBool"] | None = None
92
+ prefixItems: list["SchemaOrBool"] | None = None
93
+ # TODO: uncomment and remove below when deprecating Pydantic v1
94
+ # It generales a list of schemas for tuples, before prefixItems was available
95
+ # items: Optional["SchemaOrBool"] = None
96
+ items: Union["SchemaOrBool", list["SchemaOrBool"]] | None = None
97
+ contains: Optional["SchemaOrBool"] = None
98
+ properties: dict[str, "SchemaOrBool"] | None = None
99
+ patternProperties: dict[str, "SchemaOrBool"] | None = None
100
+ additionalProperties: Optional["SchemaOrBool"] = None
101
+ propertyNames: Optional["SchemaOrBool"] = None
102
+ unevaluatedItems: Optional["SchemaOrBool"] = None
103
+ unevaluatedProperties: Optional["SchemaOrBool"] = None
104
+ # Ref: JSON Schema Validation 2020-12: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-a-vocabulary-for-structural
105
+ # A Vocabulary for Structural Validation
106
+ type: str | None = None
107
+ enum: list[Any] | None = None
108
+ const: Any | None = None
109
+ multipleOf: float | None = Field(default=None, gt=0)
110
+ maximum: float | None = None
111
+ exclusiveMaximum: float | None = None
112
+ minimum: float | None = None
113
+ exclusiveMinimum: float | None = None
114
+ maxLength: int | None = Field(default=None, ge=0)
115
+ minLength: int | None = Field(default=None, ge=0)
116
+ pattern: str | None = None
117
+ maxItems: int | None = Field(default=None, ge=0)
118
+ minItems: int | None = Field(default=None, ge=0)
119
+ uniqueItems: bool | None = None
120
+ maxContains: int | None = Field(default=None, ge=0)
121
+ minContains: int | None = Field(default=None, ge=0)
122
+ maxProperties: int | None = Field(default=None, ge=0)
123
+ minProperties: int | None = Field(default=None, ge=0)
124
+ required: list[str] | None = None
125
+ dependentRequired: dict[str, set[str]] | None = None
126
+ # Ref: JSON Schema Validation 2020-12: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-vocabularies-for-semantic-c
127
+ # Vocabularies for Semantic Content With "format"
128
+ format: str | None = None
129
+ # Ref: JSON Schema Validation 2020-12: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-a-vocabulary-for-the-conten
130
+ # A Vocabulary for the Contents of String-Encoded Data
131
+ contentEncoding: str | None = None
132
+ contentMediaType: str | None = None
133
+ contentSchema: Optional["SchemaOrBool"] = None
134
+ # Ref: JSON Schema Validation 2020-12: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-a-vocabulary-for-basic-meta
135
+ # A Vocabulary for Basic Meta-Data Annotations
136
+ title: str | None = None
137
+ description: str | None = None
138
+ default: Any | None = None
139
+ deprecated: bool | None = None
140
+ readOnly: bool | None = None
141
+ writeOnly: bool | None = None
142
+ examples: list[Any] | None = None
143
+ # Ref: OpenAPI 3.1.0: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object
144
+ # Schema Object
145
+ discriminator: Discriminator | None = None
146
+ xml: XML | None = None
147
+ externalDocs: ExternalDocumentation | None = None
148
+
149
+
150
+ # Ref: https://json-schema.org/draft/2020-12/json-schema-core.html#name-json-schema-documents
151
+ # A JSON Schema MUST be an object or a boolean.
152
+ SchemaOrBool = Schema | bool
153
+
154
+
155
+ class Example(TypedDict, total=False):
156
+ __pydantic_config__ = {"extra": "allow"}
157
+
158
+ summary: str | None
159
+ description: str | None
160
+ value: Any | None
161
+ externalValue: AnyUrl | None
162
+
163
+
164
+ class ParameterInType(Enum):
165
+ query = "query"
166
+ header = "header"
167
+ path = "path"
168
+ cookie = "cookie"
169
+
170
+
171
+ class Encoding(BaseModelWithConfig):
172
+ contentType: str | None = None
173
+ headers: dict[str, Union["Header", Reference]] | None = None
174
+ style: str | None = None
175
+ explode: bool | None = None
176
+ allowReserved: bool | None = None
177
+
178
+
179
+ class MediaType(BaseModelWithConfig):
180
+ schema_: Schema | Reference | None = Field(default=None, alias="schema")
181
+ example: Any | None = None
182
+ examples: dict[str, Example | Reference] | None = None
183
+ encoding: dict[str, Encoding] | None = None
184
+
185
+
186
+ class ParameterBase(BaseModelWithConfig):
187
+ description: str | None = None
188
+ required: bool | None = None
189
+ deprecated: bool | None = None
190
+ # Serialization rules for simple scenarios
191
+ style: str | None = None
192
+ explode: bool | None = None
193
+ allowReserved: bool | None = None
194
+ schema_: Schema | Reference | None = Field(default=None, alias="schema")
195
+ example: Any | None = None
196
+ examples: dict[str, Example | Reference] | None = None
197
+ # Serialization rules for more complex scenarios
198
+ content: dict[str, MediaType] | None = None
199
+
200
+
201
+ class Parameter(ParameterBase):
202
+ name: str
203
+ in_: ParameterInType = Field(alias="in")
204
+
205
+
206
+ class Header(ParameterBase):
207
+ pass
208
+
209
+
210
+ class RequestBody(BaseModelWithConfig):
211
+ description: str | None = None
212
+ content: dict[str, MediaType]
213
+ required: bool | None = None
214
+
215
+
216
+ class Link(BaseModelWithConfig):
217
+ operationRef: str | None = None
218
+ operationId: str | None = None
219
+ parameters: dict[str, Any | str] | None = None
220
+ requestBody: Any | str | None = None
221
+ description: str | None = None
222
+ server: Server | None = None
223
+
224
+
225
+ class Response(BaseModelWithConfig):
226
+ description: str
227
+ headers: dict[str, Header | Reference] | None = None
228
+ content: dict[str, MediaType] | None = None
229
+ links: dict[str, Link | Reference] | None = None
230
+
231
+
232
+ class AmazonApiGatewayIntegration(BaseModelWithConfig):
233
+ httpMethod: str
234
+ type: str
235
+ uri: str | dict
236
+ cacheKeyParameters: list[str] | None = None
237
+ cacheNamespace: str | None = None
238
+
239
+
240
+ class RequestValidators(Enum):
241
+ basic = "basic"
242
+ paramsOnly = "params-only"
243
+ bodyOnly = "body-only"
244
+
245
+
246
+ class Operation(BaseModelWithConfig):
247
+ tags: list[str] | None = None
248
+ summary: str | None = None
249
+ description: str | None = None
250
+ externalDocs: ExternalDocumentation | None = None
251
+ operationId: str | None = None
252
+ parameters: list[Parameter | Reference] | None = None
253
+ requestBody: RequestBody | Reference | None = None
254
+ # Using Any for Specification Extensions
255
+ responses: dict[str, Response | Any] | None = None
256
+ callbacks: dict[str, dict[str, "PathItem"] | Reference] | None = None
257
+ deprecated: bool | None = None
258
+ security: list[dict[str, list[str]]] | None = None
259
+ servers: list[Server] | None = None
260
+ # Using for AWS integration
261
+ amazonApiGatewayIntegration: AmazonApiGatewayIntegration = Field(
262
+ alias="x-amazon-apigateway-integration"
263
+ )
264
+ amazonApiGatewayRequestValidator: RequestValidators | None = Field(
265
+ alias="x-amazon-apigateway-request-validator"
266
+ )
267
+
268
+
269
+ class PathItem(BaseModelWithConfig):
270
+ ref: str | None = Field(default=None, alias="$ref")
271
+ summary: str | None = None
272
+ description: str | None = None
273
+ get: Operation | None = None
274
+ put: Operation | None = None
275
+ post: Operation | None = None
276
+ delete: Operation | None = None
277
+ options: Operation | None = None
278
+ head: Operation | None = None
279
+ patch: Operation | None = None
280
+ trace: Operation | None = None
281
+ servers: list[Server] | None = None
282
+ parameters: list[Parameter | Reference] | None = None
283
+
284
+
285
+ class SecuritySchemeType(Enum):
286
+ apiKey = "apiKey"
287
+ http = "http"
288
+ oauth2 = "oauth2"
289
+ openIdConnect = "openIdConnect"
290
+
291
+
292
+ class SecurityBase(BaseModelWithConfig):
293
+ type_: SecuritySchemeType = Field(alias="type")
294
+ description: str | None = None
295
+
296
+
297
+ class APIKeyIn(Enum):
298
+ query = "query"
299
+ header = "header"
300
+ cookie = "cookie"
301
+
302
+
303
+ class APIKey(SecurityBase):
304
+ type_: SecuritySchemeType = Field(default=SecuritySchemeType.apiKey, alias="type")
305
+ in_: APIKeyIn = Field(alias="in")
306
+ name: str
307
+
308
+
309
+ class HTTPBase(SecurityBase):
310
+ type_: SecuritySchemeType = Field(default=SecuritySchemeType.http, alias="type")
311
+ scheme: str
312
+
313
+
314
+ class HTTPBearer(HTTPBase):
315
+ scheme: Literal["bearer"] = "bearer"
316
+ bearerFormat: str | None = None
317
+
318
+
319
+ class OAuthFlow(BaseModelWithConfig):
320
+ refreshUrl: str | None = None
321
+ scopes: dict[str, str] = {}
322
+
323
+
324
+ class OAuthFlowImplicit(OAuthFlow):
325
+ authorizationUrl: str
326
+
327
+
328
+ class OAuthFlowPassword(OAuthFlow):
329
+ tokenUrl: str
330
+
331
+
332
+ class OAuthFlowClientCredentials(OAuthFlow):
333
+ tokenUrl: str
334
+
335
+
336
+ class OAuthFlowAuthorizationCode(OAuthFlow):
337
+ authorizationUrl: str
338
+ tokenUrl: str
339
+
340
+
341
+ class OAuthFlows(BaseModelWithConfig):
342
+ implicit: OAuthFlowImplicit | None = None
343
+ password: OAuthFlowPassword | None = None
344
+ clientCredentials: OAuthFlowClientCredentials | None = None
345
+ authorizationCode: OAuthFlowAuthorizationCode | None = None
346
+
347
+
348
+ class OAuth2(SecurityBase):
349
+ type_: SecuritySchemeType = Field(default=SecuritySchemeType.oauth2, alias="type")
350
+ flows: OAuthFlows
351
+
352
+
353
+ class OpenIdConnect(SecurityBase):
354
+ type_: SecuritySchemeType = Field(
355
+ default=SecuritySchemeType.openIdConnect, alias="type"
356
+ )
357
+ openIdConnectUrl: str
358
+
359
+
360
+ SecurityScheme = APIKey | HTTPBase | OAuth2 | OpenIdConnect | HTTPBearer
361
+
362
+
363
+ class Components(BaseModelWithConfig):
364
+ schemas: dict[str, Schema | Reference] | None = None
365
+ responses: dict[str, Response | Reference] | None = None
366
+ parameters: dict[str, Parameter | Reference] | None = None
367
+ examples: dict[str, Example | Reference] | None = None
368
+ requestBodies: dict[str, RequestBody | Reference] | None = None
369
+ headers: dict[str, Header | Reference] | None = None
370
+ securitySchemes: dict[str, SecurityScheme | Reference] | None = None
371
+ links: dict[str, Link | Reference] | None = None
372
+ # Using Any for Specification Extensions
373
+ callbacks: dict[str, dict[str, PathItem] | Reference | Any] | None = None
374
+
375
+
376
+ class Tag(BaseModelWithConfig):
377
+ name: str
378
+ description: str | None = None
379
+ externalDocs: ExternalDocumentation | None = None
380
+
381
+
382
+ class AmazonRequestValidator(BaseModelWithConfig):
383
+ validateRequestBody: bool
384
+ validateRequestParameters: bool
385
+
386
+
387
+ class OpenAPI(BaseModelWithConfig):
388
+ openapi: str
389
+ info: Info
390
+ amazonApiGatewayRequestValidators: dict[
391
+ RequestValidators, AmazonRequestValidator
392
+ ] = Field(alias="x-amazon-apigateway-request-validators")
393
+ servers: list[Server] | None = None
394
+ # Using Any for Specification Extensions
395
+ paths: dict[str, PathItem | Any] | None = None
396
+ components: Components | None = None
397
+ security: list[dict[str, list[str]]] | None = None
398
+ tags: list[Tag] | None = None
399
+ externalDocs: ExternalDocumentation | None = None
400
+
401
+
402
+ Schema.model_rebuild()
403
+ Operation.model_rebuild()
404
+ Encoding.model_rebuild()