jentic-openapi-datamodels 1.0.0a19__py3-none-any.whl → 1.0.0a20__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.
- {jentic_openapi_datamodels-1.0.0a19.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/METADATA +37 -30
- {jentic_openapi_datamodels-1.0.0a19.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/RECORD +5 -5
- {jentic_openapi_datamodels-1.0.0a19.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/WHEEL +0 -0
- {jentic_openapi_datamodels-1.0.0a19.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/licenses/LICENSE +0 -0
- {jentic_openapi_datamodels-1.0.0a19.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/licenses/NOTICE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jentic-openapi-datamodels
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0a20
|
|
4
4
|
Summary: Jentic OpenAPI Data Models
|
|
5
5
|
Author: Jentic
|
|
6
6
|
Author-email: Jentic <hello@jentic.com>
|
|
@@ -66,12 +66,13 @@ pip install jentic-openapi-datamodels
|
|
|
66
66
|
The main use case is parsing complete OpenAPI Documents:
|
|
67
67
|
|
|
68
68
|
```python
|
|
69
|
-
from
|
|
69
|
+
from jentic.apitools.openapi.parser.core import OpenAPIParser
|
|
70
|
+
from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
|
|
70
71
|
from jentic.apitools.openapi.datamodels.low.v30 import build
|
|
71
72
|
|
|
72
73
|
# Parse OpenAPI document
|
|
73
|
-
|
|
74
|
-
root =
|
|
74
|
+
parser = OpenAPIParser("ruamel-ast")
|
|
75
|
+
root = parser.parse("""
|
|
75
76
|
openapi: 3.0.4
|
|
76
77
|
info:
|
|
77
78
|
title: Pet Store API
|
|
@@ -83,7 +84,7 @@ paths:
|
|
|
83
84
|
responses:
|
|
84
85
|
'200':
|
|
85
86
|
description: A list of pets
|
|
86
|
-
""")
|
|
87
|
+
""", return_type=MappingNode)
|
|
87
88
|
|
|
88
89
|
# Build OpenAPI document model
|
|
89
90
|
openapi_doc = build(root)
|
|
@@ -106,12 +107,13 @@ for path_key, path_item in openapi_doc.paths.value.path_items.items():
|
|
|
106
107
|
OpenAPI 3.1 fully supports JSON Schema 2020-12, including advanced features like boolean schemas, conditional validation and vocabulary declarations:
|
|
107
108
|
|
|
108
109
|
```python
|
|
109
|
-
from
|
|
110
|
+
from jentic.apitools.openapi.parser.core import OpenAPIParser
|
|
111
|
+
from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
|
|
110
112
|
from jentic.apitools.openapi.datamodels.low.v31 import build
|
|
111
113
|
|
|
112
114
|
# Parse OpenAPI 3.1 document with JSON Schema 2020-12 features
|
|
113
|
-
|
|
114
|
-
root =
|
|
115
|
+
parser = OpenAPIParser("ruamel-ast")
|
|
116
|
+
root = parser.parse("""
|
|
115
117
|
openapi: 3.1.2
|
|
116
118
|
info:
|
|
117
119
|
title: Pet Store API
|
|
@@ -133,7 +135,7 @@ paths:
|
|
|
133
135
|
contains:
|
|
134
136
|
type: object
|
|
135
137
|
required: [id]
|
|
136
|
-
""")
|
|
138
|
+
""", return_type=MappingNode)
|
|
137
139
|
|
|
138
140
|
openapi_doc = build(root)
|
|
139
141
|
|
|
@@ -149,16 +151,17 @@ print(schema.contains.value.required.value[0].value) # "id"
|
|
|
149
151
|
You can also parse individual OpenAPI specification objects:
|
|
150
152
|
|
|
151
153
|
```python
|
|
152
|
-
from
|
|
154
|
+
from jentic.apitools.openapi.parser.core import OpenAPIParser
|
|
155
|
+
from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
|
|
153
156
|
from jentic.apitools.openapi.datamodels.low.v30.security_scheme import build as build_security_scheme
|
|
154
157
|
|
|
155
158
|
# Parse a Security Scheme object
|
|
156
|
-
|
|
157
|
-
root =
|
|
159
|
+
parser = OpenAPIParser("ruamel-ast")
|
|
160
|
+
root = parser.parse("""
|
|
158
161
|
type: http
|
|
159
162
|
scheme: bearer
|
|
160
163
|
bearerFormat: JWT
|
|
161
|
-
""")
|
|
164
|
+
""", return_type=MappingNode)
|
|
162
165
|
|
|
163
166
|
security_scheme = build_security_scheme(root)
|
|
164
167
|
|
|
@@ -173,12 +176,13 @@ print(security_scheme.bearer_format.key_node.start_mark.line) # Line number
|
|
|
173
176
|
You can also parse OpenAPI 3.1 Schema objects with JSON Schema 2020-12 features:
|
|
174
177
|
|
|
175
178
|
```python
|
|
176
|
-
from
|
|
179
|
+
from jentic.apitools.openapi.parser.core import OpenAPIParser
|
|
180
|
+
from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
|
|
177
181
|
from jentic.apitools.openapi.datamodels.low.v31.schema import build as build_schema
|
|
178
182
|
|
|
179
183
|
# Parse a Schema object with JSON Schema 2020-12 features
|
|
180
|
-
|
|
181
|
-
root =
|
|
184
|
+
parser = OpenAPIParser("ruamel-ast")
|
|
185
|
+
root = parser.parse("""
|
|
182
186
|
type: object
|
|
183
187
|
properties:
|
|
184
188
|
id:
|
|
@@ -199,7 +203,7 @@ if:
|
|
|
199
203
|
const: true
|
|
200
204
|
then:
|
|
201
205
|
required: [support_tier]
|
|
202
|
-
""")
|
|
206
|
+
""", return_type=MappingNode)
|
|
203
207
|
|
|
204
208
|
schema = build_schema(root)
|
|
205
209
|
|
|
@@ -255,18 +259,19 @@ The package provides three immutable wrapper types for preserving source informa
|
|
|
255
259
|
- Example: Values in `Discriminator.mapping` are `ValueSource[str]`
|
|
256
260
|
|
|
257
261
|
```python
|
|
258
|
-
from
|
|
262
|
+
from jentic.apitools.openapi.parser.core import OpenAPIParser
|
|
263
|
+
from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
|
|
259
264
|
from jentic.apitools.openapi.datamodels.low.v30 import build
|
|
260
265
|
|
|
261
266
|
# FieldSource: Fixed specification fields in OpenAPI document
|
|
262
|
-
|
|
263
|
-
root =
|
|
267
|
+
parser = OpenAPIParser("ruamel-ast")
|
|
268
|
+
root = parser.parse("""
|
|
264
269
|
openapi: 3.0.4
|
|
265
270
|
info:
|
|
266
271
|
title: Pet Store API
|
|
267
272
|
version: 1.0.0
|
|
268
273
|
paths: {}
|
|
269
|
-
""")
|
|
274
|
+
""", return_type=MappingNode)
|
|
270
275
|
openapi_doc = build(root)
|
|
271
276
|
|
|
272
277
|
field = openapi_doc.info.value.title # FieldSource[str]
|
|
@@ -276,7 +281,7 @@ print(field.value_node) # YAML node for "Pet Store API"
|
|
|
276
281
|
|
|
277
282
|
# KeySource/ValueSource: Dictionary fields (extensions, mapping)
|
|
278
283
|
# Extensions in OpenAPI objects use KeySource/ValueSource
|
|
279
|
-
root =
|
|
284
|
+
root = parser.parse("""
|
|
280
285
|
openapi: 3.0.4
|
|
281
286
|
info:
|
|
282
287
|
title: API
|
|
@@ -284,7 +289,7 @@ info:
|
|
|
284
289
|
x-custom: value
|
|
285
290
|
x-another: data
|
|
286
291
|
paths: {}
|
|
287
|
-
""")
|
|
292
|
+
""", return_type=MappingNode)
|
|
288
293
|
openapi_doc = build(root)
|
|
289
294
|
|
|
290
295
|
for key, value in openapi_doc.info.value.extensions.items():
|
|
@@ -299,7 +304,8 @@ for key, value in openapi_doc.info.value.extensions.items():
|
|
|
299
304
|
Access precise location ranges within the source document using start_mark and end_mark:
|
|
300
305
|
|
|
301
306
|
```python
|
|
302
|
-
from
|
|
307
|
+
from jentic.apitools.openapi.parser.core import OpenAPIParser
|
|
308
|
+
from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
|
|
303
309
|
from jentic.apitools.openapi.datamodels.low.v30 import build
|
|
304
310
|
|
|
305
311
|
yaml_content = """
|
|
@@ -311,8 +317,8 @@ info:
|
|
|
311
317
|
paths: {}
|
|
312
318
|
"""
|
|
313
319
|
|
|
314
|
-
|
|
315
|
-
root =
|
|
320
|
+
parser = OpenAPIParser("ruamel-ast")
|
|
321
|
+
root = parser.parse(yaml_content, return_type=MappingNode)
|
|
316
322
|
openapi_doc = build(root)
|
|
317
323
|
|
|
318
324
|
# Access location information for any field
|
|
@@ -337,17 +343,18 @@ print(f"Field range: ({start.line}:{start.column}) to ({end.line}:{end.column})"
|
|
|
337
343
|
Low-level models preserve invalid data without validation:
|
|
338
344
|
|
|
339
345
|
```python
|
|
340
|
-
from
|
|
346
|
+
from jentic.apitools.openapi.parser.core import OpenAPIParser
|
|
347
|
+
from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
|
|
341
348
|
from jentic.apitools.openapi.datamodels.low.v30 import build
|
|
342
349
|
|
|
343
|
-
|
|
344
|
-
root =
|
|
350
|
+
parser = OpenAPIParser("ruamel-ast")
|
|
351
|
+
root = parser.parse("""
|
|
345
352
|
openapi: 3.0.4
|
|
346
353
|
info:
|
|
347
354
|
title: 123 # Intentionally wrong type for demonstration (should be string)
|
|
348
355
|
version: 1.0.0
|
|
349
356
|
paths: {}
|
|
350
|
-
""")
|
|
357
|
+
""", return_type=MappingNode)
|
|
351
358
|
|
|
352
359
|
openapi_doc = build(root)
|
|
353
360
|
print(openapi_doc.info.value.title.value) # 123 (preserved as-is)
|
{jentic_openapi_datamodels-1.0.0a19.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/RECORD
RENAMED
|
@@ -68,8 +68,8 @@ jentic/apitools/openapi/datamodels/low/v31/server.py,sha256=IA-dDnhqdD6WCZ_bjdGw
|
|
|
68
68
|
jentic/apitools/openapi/datamodels/low/v31/server_variable.py,sha256=UfGDky_NVUF_WQc5ZIU947MjmpxaO__VIv6sq8HMsk0,2762
|
|
69
69
|
jentic/apitools/openapi/datamodels/low/v31/tag.py,sha256=8-QfVk4dUp3r-LbseMSvlCcAWeZkzlhZP3giVKNgaPI,2359
|
|
70
70
|
jentic/apitools/openapi/datamodels/low/v31/xml.py,sha256=SFLNLrhiZRWVH_CBV8SqtO4C4qjDjGtqz_lYpp84BnE,1930
|
|
71
|
-
jentic_openapi_datamodels-1.0.
|
|
72
|
-
jentic_openapi_datamodels-1.0.
|
|
73
|
-
jentic_openapi_datamodels-1.0.
|
|
74
|
-
jentic_openapi_datamodels-1.0.
|
|
75
|
-
jentic_openapi_datamodels-1.0.
|
|
71
|
+
jentic_openapi_datamodels-1.0.0a20.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
72
|
+
jentic_openapi_datamodels-1.0.0a20.dist-info/licenses/NOTICE,sha256=pAOGW-rGw9KNc2cuuLWZkfx0GSTV4TicbgBKZSLPMIs,168
|
|
73
|
+
jentic_openapi_datamodels-1.0.0a20.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
74
|
+
jentic_openapi_datamodels-1.0.0a20.dist-info/METADATA,sha256=7Q28pNaN1yY8_95wbff-bV1izBBWiitL5HZNLAMq3ME,12466
|
|
75
|
+
jentic_openapi_datamodels-1.0.0a20.dist-info/RECORD,,
|
{jentic_openapi_datamodels-1.0.0a19.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|