jentic-openapi-datamodels 1.0.0a18__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/apitools/openapi/datamodels/low/extractors.py +3 -3
- jentic/apitools/openapi/datamodels/low/v30/__init__.py +76 -0
- jentic/apitools/openapi/datamodels/low/v30/builders/__init__.py +312 -0
- jentic/apitools/openapi/datamodels/low/v30/callback.py +131 -0
- jentic/apitools/openapi/datamodels/low/v30/components.py +236 -0
- jentic/apitools/openapi/datamodels/low/v30/contact.py +4 -10
- jentic/apitools/openapi/datamodels/low/v30/discriminator.py +4 -9
- jentic/apitools/openapi/datamodels/low/v30/encoding.py +81 -0
- jentic/apitools/openapi/datamodels/low/v30/example.py +91 -0
- jentic/apitools/openapi/datamodels/low/v30/external_documentation.py +4 -10
- jentic/apitools/openapi/datamodels/low/v30/header.py +120 -0
- jentic/apitools/openapi/datamodels/low/v30/info.py +14 -23
- jentic/apitools/openapi/datamodels/low/v30/license.py +4 -10
- jentic/apitools/openapi/datamodels/low/v30/link.py +141 -0
- jentic/apitools/openapi/datamodels/low/v30/media_type.py +110 -0
- jentic/apitools/openapi/datamodels/low/v30/oauth_flow.py +4 -10
- jentic/apitools/openapi/datamodels/low/v30/oauth_flows.py +7 -15
- jentic/apitools/openapi/datamodels/low/v30/openapi.py +149 -0
- jentic/apitools/openapi/datamodels/low/v30/operation.py +134 -0
- jentic/apitools/openapi/datamodels/low/v30/parameter.py +123 -0
- jentic/apitools/openapi/datamodels/low/v30/path_item.py +125 -0
- jentic/apitools/openapi/datamodels/low/v30/paths.py +108 -0
- jentic/apitools/openapi/datamodels/low/v30/reference.py +5 -9
- jentic/apitools/openapi/datamodels/low/v30/request_body.py +108 -0
- jentic/apitools/openapi/datamodels/low/v30/response.py +104 -0
- jentic/apitools/openapi/datamodels/low/v30/responses.py +109 -0
- jentic/apitools/openapi/datamodels/low/v30/schema.py +81 -97
- jentic/apitools/openapi/datamodels/low/v30/security_requirement.py +14 -9
- jentic/apitools/openapi/datamodels/low/v30/security_scheme.py +42 -22
- jentic/apitools/openapi/datamodels/low/v30/server.py +111 -0
- jentic/apitools/openapi/datamodels/low/v30/server_variable.py +4 -10
- jentic/apitools/openapi/datamodels/low/v30/tag.py +8 -46
- jentic/apitools/openapi/datamodels/low/v30/xml.py +4 -10
- jentic/apitools/openapi/datamodels/low/v31/__init__.py +77 -0
- jentic/apitools/openapi/datamodels/low/v31/builders/__init__.py +347 -0
- jentic/apitools/openapi/datamodels/low/v31/callback.py +131 -0
- jentic/apitools/openapi/datamodels/low/v31/components.py +240 -0
- jentic/apitools/openapi/datamodels/low/v31/contact.py +61 -0
- jentic/apitools/openapi/datamodels/low/v31/discriminator.py +62 -0
- jentic/apitools/openapi/datamodels/low/v31/encoding.py +81 -0
- jentic/apitools/openapi/datamodels/low/v31/example.py +91 -0
- jentic/apitools/openapi/datamodels/low/v31/external_documentation.py +59 -0
- jentic/apitools/openapi/datamodels/low/v31/header.py +120 -0
- jentic/apitools/openapi/datamodels/low/v31/info.py +116 -0
- jentic/apitools/openapi/datamodels/low/v31/license.py +61 -0
- jentic/apitools/openapi/datamodels/low/v31/link.py +141 -0
- jentic/apitools/openapi/datamodels/low/v31/media_type.py +110 -0
- jentic/apitools/openapi/datamodels/low/v31/oauth_flow.py +65 -0
- jentic/apitools/openapi/datamodels/low/v31/oauth_flows.py +108 -0
- jentic/apitools/openapi/datamodels/low/v31/openapi.py +168 -0
- jentic/apitools/openapi/datamodels/low/v31/operation.py +133 -0
- jentic/apitools/openapi/datamodels/low/v31/parameter.py +123 -0
- jentic/apitools/openapi/datamodels/low/v31/path_item.py +125 -0
- jentic/apitools/openapi/datamodels/low/v31/paths.py +108 -0
- jentic/apitools/openapi/datamodels/low/v31/reference.py +65 -0
- jentic/apitools/openapi/datamodels/low/v31/request_body.py +108 -0
- jentic/apitools/openapi/datamodels/low/v31/response.py +104 -0
- jentic/apitools/openapi/datamodels/low/v31/responses.py +109 -0
- jentic/apitools/openapi/datamodels/low/v31/schema.py +498 -0
- jentic/apitools/openapi/datamodels/low/v31/security_requirement.py +106 -0
- jentic/apitools/openapi/datamodels/low/v31/security_scheme.py +129 -0
- jentic/apitools/openapi/datamodels/low/v31/server.py +111 -0
- jentic/apitools/openapi/datamodels/low/v31/server_variable.py +70 -0
- jentic/apitools/openapi/datamodels/low/v31/tag.py +63 -0
- jentic/apitools/openapi/datamodels/low/v31/xml.py +54 -0
- jentic_openapi_datamodels-1.0.0a20.dist-info/METADATA +379 -0
- jentic_openapi_datamodels-1.0.0a20.dist-info/RECORD +75 -0
- jentic/apitools/openapi/datamodels/low/model_builder.py +0 -129
- jentic_openapi_datamodels-1.0.0a18.dist-info/METADATA +0 -211
- jentic_openapi_datamodels-1.0.0a18.dist-info/RECORD +0 -27
- {jentic_openapi_datamodels-1.0.0a18.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/WHEEL +0 -0
- {jentic_openapi_datamodels-1.0.0a18.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/licenses/LICENSE +0 -0
- {jentic_openapi_datamodels-1.0.0a18.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/licenses/NOTICE +0 -0
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: jentic-openapi-datamodels
|
|
3
|
-
Version: 1.0.0a18
|
|
4
|
-
Summary: Jentic OpenAPI Data Models
|
|
5
|
-
Author: Jentic
|
|
6
|
-
Author-email: Jentic <hello@jentic.com>
|
|
7
|
-
License-Expression: Apache-2.0
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
License-File: NOTICE
|
|
10
|
-
Requires-Dist: ruamel-yaml~=0.18.15
|
|
11
|
-
Requires-Python: >=3.11
|
|
12
|
-
Project-URL: Homepage, https://github.com/jentic/jentic-openapi-tools
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
|
|
15
|
-
from semantic_release.cli.commands.version import build_distributions
|
|
16
|
-
|
|
17
|
-
# jentic-openapi-datamodels
|
|
18
|
-
|
|
19
|
-
Low-level and high-level data models for OpenAPI specifications.
|
|
20
|
-
|
|
21
|
-
This package provides data model classes for representing OpenAPI specification objects in Python.
|
|
22
|
-
|
|
23
|
-
## Features
|
|
24
|
-
|
|
25
|
-
**Low-Level Architecture**
|
|
26
|
-
- **Preserve Everything**: All data from source documents preserved exactly as-is, including invalid values
|
|
27
|
-
- **Zero Validation**: No validation or coercion during parsing - deferred to higher layers
|
|
28
|
-
- **Separation of Concerns**: Low-level model focuses on faithful representation; validation belongs elsewhere
|
|
29
|
-
|
|
30
|
-
**Source Tracking**
|
|
31
|
-
- **Complete Source Fidelity**: Every field tracks its exact YAML node location
|
|
32
|
-
- **Precise Error Reporting**: Line and column numbers via `start_mark` and `end_mark`
|
|
33
|
-
- **Metadata Preservation**: Full position tracking for accurate diagnostics
|
|
34
|
-
|
|
35
|
-
**Python Integration**
|
|
36
|
-
- **Python-Idiomatic Naming**: snake_case field names (e.g., `bearer_format`, `property_name`)
|
|
37
|
-
- **Spec-Aligned Mapping**: Automatic YAML name mapping (e.g., `bearerFormat` ↔ `bearer_format`)
|
|
38
|
-
- **Type Safety**: Full type hints with Generic types (`FieldSource[T]`, `KeySource[T]`, `ValueSource[T]`)
|
|
39
|
-
|
|
40
|
-
**Extensibility**
|
|
41
|
-
- **Extension Support**: Automatic extraction of OpenAPI `x-*` specification extensions
|
|
42
|
-
- **Unknown Field Tracking**: Capture typos and invalid fields for validation tools
|
|
43
|
-
- **Generic Builder Pattern**: Core `build_model()` function with object-specific builders for complex cases
|
|
44
|
-
|
|
45
|
-
**Performance**
|
|
46
|
-
- **Memory Efficient**: Immutable frozen dataclasses with `__slots__` for optimal memory usage
|
|
47
|
-
- **Shared Context**: All instances share a single YAML constructor for efficiency
|
|
48
|
-
|
|
49
|
-
**Version Support**
|
|
50
|
-
- **OpenAPI 2.0**: Planned for future release
|
|
51
|
-
- **OpenAPI 3.0.x**: Currently implemented
|
|
52
|
-
- **OpenAPI 3.1.x**: Planned for future release
|
|
53
|
-
- **OpenAPI 3.2.x**: Planned for future release
|
|
54
|
-
|
|
55
|
-
## Installation
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
pip install jentic-openapi-datamodels
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Prerequisites:**
|
|
62
|
-
- Python 3.11+
|
|
63
|
-
|
|
64
|
-
## Quick Start
|
|
65
|
-
|
|
66
|
-
### Basic Usage
|
|
67
|
-
|
|
68
|
-
```python
|
|
69
|
-
from ruamel.yaml import YAML
|
|
70
|
-
from jentic.apitools.openapi.datamodels.low.v30.security_scheme import build
|
|
71
|
-
|
|
72
|
-
# Parse YAML
|
|
73
|
-
yaml = YAML()
|
|
74
|
-
root = yaml.compose("""
|
|
75
|
-
type: http
|
|
76
|
-
scheme: bearer
|
|
77
|
-
bearerFormat: JWT
|
|
78
|
-
""")
|
|
79
|
-
|
|
80
|
-
# Build low-level model
|
|
81
|
-
security_scheme = build(root)
|
|
82
|
-
|
|
83
|
-
# Access via Python field names (snake_case)
|
|
84
|
-
print(security_scheme.bearer_format.value) # "JWT"
|
|
85
|
-
|
|
86
|
-
# Access source location information
|
|
87
|
-
print(security_scheme.bearer_format.key_node.value) # "bearerFormat"
|
|
88
|
-
print(security_scheme.bearer_format.key_node.start_mark.line) # Line number
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Field Name Mapping
|
|
92
|
-
|
|
93
|
-
YAML `camelCase` fields automatically map to Python `snake_case`:
|
|
94
|
-
- `bearerFormat` → `bearer_format`
|
|
95
|
-
- `authorizationUrl` → `authorization_url`
|
|
96
|
-
- `openIdConnectUrl` → `openid_connect_url`
|
|
97
|
-
|
|
98
|
-
Special cases for Python reserved keywords/special characters:
|
|
99
|
-
- `$ref` → `ref`
|
|
100
|
-
- `in` → `in_`
|
|
101
|
-
|
|
102
|
-
### Source Tracking
|
|
103
|
-
|
|
104
|
-
The package provides three immutable wrapper types for preserving source information:
|
|
105
|
-
|
|
106
|
-
**FieldSource[T]** - For OpenAPI fields with key-value pairs
|
|
107
|
-
- Used for: Fixed fields (`name`, `bearer_format`) and patterned fields (status codes, path items, schema properties)
|
|
108
|
-
- Tracks: Both key and value nodes
|
|
109
|
-
- Example: `SecurityScheme.bearer_format` is `FieldSource[str]`, response status codes are `FieldSource[Response]`
|
|
110
|
-
|
|
111
|
-
**KeySource[T]** - For dictionary keys
|
|
112
|
-
- Used for: keys in OpenAPI fields, `x-*` extensions and mapping dictionaries
|
|
113
|
-
- Tracks: Only key node
|
|
114
|
-
- Example: Keys in `Discriminator.mapping` are `KeySource[str]`
|
|
115
|
-
|
|
116
|
-
**ValueSource[T]** - For dictionary values and array items
|
|
117
|
-
- Used for: values in OpenAPI fields, in `x-*` extensions, mapping dictionaries and array items
|
|
118
|
-
- Tracks: Only value node
|
|
119
|
-
- Example: Values in `Discriminator.mapping` are `ValueSource[str]`
|
|
120
|
-
|
|
121
|
-
```python
|
|
122
|
-
from ruamel.yaml import YAML
|
|
123
|
-
from jentic.apitools.openapi.datamodels.low.v30.security_scheme import build as build_security_scheme
|
|
124
|
-
from jentic.apitools.openapi.datamodels.low.v30.discriminator import build as build_discriminator
|
|
125
|
-
|
|
126
|
-
# FieldSource: Fixed specification fields
|
|
127
|
-
yaml = YAML()
|
|
128
|
-
root = yaml.compose("type: http\nscheme: bearer\nbearerFormat: JWT")
|
|
129
|
-
security_scheme = build_security_scheme(root)
|
|
130
|
-
|
|
131
|
-
field = security_scheme.bearer_format # FieldSource[str]
|
|
132
|
-
print(field.value) # "JWT" - The actual value
|
|
133
|
-
print(field.key_node) # YAML node for "bearerFormat"
|
|
134
|
-
print(field.value_node) # YAML node for "JWT"
|
|
135
|
-
|
|
136
|
-
# KeySource/ValueSource: Dictionary fields (mapping, extensions)
|
|
137
|
-
root = yaml.compose("propertyName: petType\nmapping:\n dog: Dog\n cat: Cat")
|
|
138
|
-
discriminator = build_discriminator(root)
|
|
139
|
-
|
|
140
|
-
for key, value in discriminator.mapping.value.items():
|
|
141
|
-
print(key.value) # KeySource[str]: "dog" or "cat"
|
|
142
|
-
print(key.key_node) # YAML node for the key
|
|
143
|
-
print(value.value) # ValueSource[str]: "Dog" or "Cat"
|
|
144
|
-
print(value.value_node) # YAML node for the value
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### Location Ranges
|
|
148
|
-
|
|
149
|
-
Access precise location ranges within the source document using start_mark and end_mark:
|
|
150
|
-
|
|
151
|
-
```python
|
|
152
|
-
from ruamel.yaml import YAML
|
|
153
|
-
from jentic.apitools.openapi.datamodels.low.v30.security_scheme import build as build_security_scheme
|
|
154
|
-
|
|
155
|
-
yaml_content = """
|
|
156
|
-
type: http
|
|
157
|
-
scheme: bearer
|
|
158
|
-
bearerFormat: JWT
|
|
159
|
-
description: Bearer token authentication
|
|
160
|
-
"""
|
|
161
|
-
|
|
162
|
-
yaml = YAML()
|
|
163
|
-
root = yaml.compose(yaml_content)
|
|
164
|
-
security_scheme = build_security_scheme(root)
|
|
165
|
-
|
|
166
|
-
# Access location information for any field
|
|
167
|
-
field = security_scheme.bearer_format
|
|
168
|
-
|
|
169
|
-
# Key location (e.g., "bearerFormat")
|
|
170
|
-
print(f"Key start: line {field.key_node.start_mark.line}, col {field.key_node.start_mark.column}")
|
|
171
|
-
print(f"Key end: line {field.key_node.end_mark.line}, col {field.key_node.end_mark.column}")
|
|
172
|
-
|
|
173
|
-
# Value location (e.g., "JWT")
|
|
174
|
-
print(f"Value start: line {field.value_node.start_mark.line}, col {field.value_node.start_mark.column}")
|
|
175
|
-
print(f"Value end: line {field.value_node.end_mark.line}, col {field.value_node.end_mark.column}")
|
|
176
|
-
|
|
177
|
-
# Full field range (from key start to value end)
|
|
178
|
-
start = field.key_node.start_mark
|
|
179
|
-
end = field.value_node.end_mark
|
|
180
|
-
print(f"Field range: ({start.line}:{start.column}) to ({end.line}:{end.column})")
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Invalid Data Handling
|
|
184
|
-
|
|
185
|
-
Low-level models preserve invalid data:
|
|
186
|
-
|
|
187
|
-
```python
|
|
188
|
-
from ruamel.yaml import YAML
|
|
189
|
-
from jentic.apitools.openapi.datamodels.low.v30.security_scheme import build as build_security_scheme
|
|
190
|
-
|
|
191
|
-
yaml = YAML()
|
|
192
|
-
root = yaml.compose("bearerFormat: 123") # Wrong type (should be string)
|
|
193
|
-
|
|
194
|
-
security_scheme = build_security_scheme(root)
|
|
195
|
-
print(security_scheme.bearer_format.value) # 123 (preserved as-is)
|
|
196
|
-
print(type(security_scheme.bearer_format.value)) # <class 'int'>
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### Error Reporting
|
|
200
|
-
|
|
201
|
-
This architecture—where the low-level model preserves data without validation and validation tools consume
|
|
202
|
-
that data—allows the low-level model to remain simple while enabling sophisticated validation tools to provide
|
|
203
|
-
user-friendly error messages with exact source locations.
|
|
204
|
-
|
|
205
|
-
## Testing
|
|
206
|
-
|
|
207
|
-
Run the test suite:
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
uv run --package jentic-openapi-datamodels pytest packages/jentic-openapi-datamodels -v
|
|
211
|
-
```
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
jentic/apitools/openapi/datamodels/low/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
jentic/apitools/openapi/datamodels/low/context.py,sha256=pAuPf8GmdttXMEeuO4clAvTTxH7LMtEHdxoo1RpyK2c,555
|
|
3
|
-
jentic/apitools/openapi/datamodels/low/extractors.py,sha256=ACtSbRRzICi9cjLzldcwN4GDuieT_JvW81lPZ44mq6c,4954
|
|
4
|
-
jentic/apitools/openapi/datamodels/low/fields.py,sha256=g1Sta-eN4JDg_AnuJxe1MeWS3Ut81A5dw_ZIdyGrgbk,1448
|
|
5
|
-
jentic/apitools/openapi/datamodels/low/model_builder.py,sha256=sB_83TNWncOkt9g39MJnlNRIanqCnQ0OUVLy1fd5Jy8,5722
|
|
6
|
-
jentic/apitools/openapi/datamodels/low/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
jentic/apitools/openapi/datamodels/low/sources.py,sha256=H4I6LSn-Ry6cJageIyhCvE0H85O7Lh94gdCIm60wj0E,2924
|
|
8
|
-
jentic/apitools/openapi/datamodels/low/v30/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
jentic/apitools/openapi/datamodels/low/v30/contact.py,sha256=j_EbbdZlEBtyMyd1yOddNra6sHSCFiYC9JtxvoQZDj4,2373
|
|
10
|
-
jentic/apitools/openapi/datamodels/low/v30/discriminator.py,sha256=GVIyNbaoMVhkfavfFhKvlFHvwcIiSDPHKVAmgV9_7pQ,2537
|
|
11
|
-
jentic/apitools/openapi/datamodels/low/v30/external_documentation.py,sha256=5H2SeBkTH4MPakQPyy2NrSuPoh1n64OzeFVbfpyrh28,2448
|
|
12
|
-
jentic/apitools/openapi/datamodels/low/v30/info.py,sha256=_LzPYLqT8hDECwoqZWwED4o3p5ANa8bikmDS-SWff5Y,5090
|
|
13
|
-
jentic/apitools/openapi/datamodels/low/v30/license.py,sha256=r7ZvD5Ya5m1DYdDOVivw3PIWDpJEmZXiS5mc4Kq8Uj4,2184
|
|
14
|
-
jentic/apitools/openapi/datamodels/low/v30/oauth_flow.py,sha256=u6VnU4pMfu-Atg2Ooslp0ladGGhfw3VEjLHgMqZHRn8,2906
|
|
15
|
-
jentic/apitools/openapi/datamodels/low/v30/oauth_flows.py,sha256=gXgCmvYQ0d5v36VeGw2MqkIG20dbClfWIN7IDMq8V_c,4652
|
|
16
|
-
jentic/apitools/openapi/datamodels/low/v30/reference.py,sha256=zwz09f_sgzj5a1KV0V5IwhB313Se5JYX1pr5FaJaxZU,2134
|
|
17
|
-
jentic/apitools/openapi/datamodels/low/v30/schema.py,sha256=XmXBlM7JvLA16d8SbyCJfjvnPVAYGi1B7Ejqizx-MNA,16203
|
|
18
|
-
jentic/apitools/openapi/datamodels/low/v30/security_requirement.py,sha256=beYB2TrfflvxnVO83b2iNzVKrInupJ_59zsvM8NYj-k,4032
|
|
19
|
-
jentic/apitools/openapi/datamodels/low/v30/security_scheme.py,sha256=tPOfcx0sh0w-gMMwtOxjybduRb7q-oI8PTq1SDS8ozg,4819
|
|
20
|
-
jentic/apitools/openapi/datamodels/low/v30/server_variable.py,sha256=FAzpwV9xRdcGZ99UaZG6ibUwZaenHTXH4GKX-wzQ2lU,2941
|
|
21
|
-
jentic/apitools/openapi/datamodels/low/v30/tag.py,sha256=FenkPaMCMAXZWJkA2heWewhxB2etKA-opuas494fUhA,3831
|
|
22
|
-
jentic/apitools/openapi/datamodels/low/v30/xml.py,sha256=1LjV-JsU5MqEFPV9e-zVKyJ9qt7QfwWjGN3oVLGxsnQ,2109
|
|
23
|
-
jentic_openapi_datamodels-1.0.0a18.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
24
|
-
jentic_openapi_datamodels-1.0.0a18.dist-info/licenses/NOTICE,sha256=pAOGW-rGw9KNc2cuuLWZkfx0GSTV4TicbgBKZSLPMIs,168
|
|
25
|
-
jentic_openapi_datamodels-1.0.0a18.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
26
|
-
jentic_openapi_datamodels-1.0.0a18.dist-info/METADATA,sha256=A1YJ75PZcrFjuwKeCkc6vRxvgU1d9L4BojErF05rj9I,7439
|
|
27
|
-
jentic_openapi_datamodels-1.0.0a18.dist-info/RECORD,,
|
{jentic_openapi_datamodels-1.0.0a18.dist-info → jentic_openapi_datamodels-1.0.0a20.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|