jentic-openapi-datamodels 1.0.0a28__tar.gz

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.
Files changed (75) hide show
  1. jentic_openapi_datamodels-1.0.0a28/LICENSE +202 -0
  2. jentic_openapi_datamodels-1.0.0a28/NOTICE +4 -0
  3. jentic_openapi_datamodels-1.0.0a28/PKG-INFO +434 -0
  4. jentic_openapi_datamodels-1.0.0a28/README.md +420 -0
  5. jentic_openapi_datamodels-1.0.0a28/pyproject.toml +35 -0
  6. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/__init__.py +0 -0
  7. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/context.py +21 -0
  8. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/extractors.py +126 -0
  9. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/fields.py +57 -0
  10. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/py.typed +0 -0
  11. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/sources.py +89 -0
  12. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/__init__.py +76 -0
  13. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/builders/__init__.py +312 -0
  14. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/callback.py +132 -0
  15. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/components.py +236 -0
  16. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/contact.py +61 -0
  17. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/discriminator.py +61 -0
  18. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/encoding.py +81 -0
  19. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/example.py +91 -0
  20. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/external_documentation.py +59 -0
  21. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/header.py +120 -0
  22. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/info.py +114 -0
  23. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/license.py +59 -0
  24. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/link.py +141 -0
  25. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/media_type.py +110 -0
  26. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/oauth_flow.py +65 -0
  27. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/oauth_flows.py +108 -0
  28. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/openapi.py +149 -0
  29. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/operation.py +134 -0
  30. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/parameter.py +123 -0
  31. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/path_item.py +125 -0
  32. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/paths.py +109 -0
  33. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/reference.py +62 -0
  34. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/request_body.py +108 -0
  35. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/response.py +104 -0
  36. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/responses.py +109 -0
  37. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/schema.py +341 -0
  38. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/security_requirement.py +104 -0
  39. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/security_scheme.py +129 -0
  40. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/server.py +111 -0
  41. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/server_variable.py +70 -0
  42. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/tag.py +63 -0
  43. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v30/xml.py +54 -0
  44. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/__init__.py +77 -0
  45. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/builders/__init__.py +347 -0
  46. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/callback.py +132 -0
  47. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/components.py +240 -0
  48. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/contact.py +61 -0
  49. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/discriminator.py +62 -0
  50. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/encoding.py +81 -0
  51. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/example.py +91 -0
  52. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/external_documentation.py +59 -0
  53. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/header.py +120 -0
  54. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/info.py +116 -0
  55. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/license.py +61 -0
  56. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/link.py +141 -0
  57. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/media_type.py +110 -0
  58. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/oauth_flow.py +65 -0
  59. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/oauth_flows.py +108 -0
  60. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/openapi.py +168 -0
  61. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/operation.py +133 -0
  62. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/parameter.py +123 -0
  63. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/path_item.py +125 -0
  64. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/paths.py +109 -0
  65. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/reference.py +68 -0
  66. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/request_body.py +108 -0
  67. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/response.py +104 -0
  68. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/responses.py +109 -0
  69. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/schema.py +498 -0
  70. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/security_requirement.py +104 -0
  71. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/security_scheme.py +129 -0
  72. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/server.py +111 -0
  73. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/server_variable.py +70 -0
  74. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/tag.py +63 -0
  75. jentic_openapi_datamodels-1.0.0a28/src/jentic/apitools/openapi/datamodels/low/v31/xml.py +54 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ Jentic OpenAPI Tools
2
+ Copyright (c) 2025 Jentic
3
+ Jentic OpenAPI Tools is licensed under Apache 2.0 license.
4
+ Copy of the Apache 2.0 license can be found in `LICENSE` file.
@@ -0,0 +1,434 @@
1
+ Metadata-Version: 2.4
2
+ Name: jentic-openapi-datamodels
3
+ Version: 1.0.0a28
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
+ # jentic-openapi-datamodels
16
+
17
+ Low-level data models for OpenAPI specifications.
18
+
19
+ This package provides data model classes for representing OpenAPI specification objects in Python.
20
+
21
+ ## Features
22
+
23
+ **Low-Level Architecture**
24
+ - **Preserve Everything**: All data from source documents preserved exactly as-is, including invalid values
25
+ - **Zero Validation**: No validation or coercion during parsing - deferred to higher layers
26
+ - **Separation of Concerns**: Low-level model focuses on faithful representation; validation belongs elsewhere
27
+
28
+ **Source Tracking**
29
+ - **Complete Source Fidelity**: Every field tracks its exact YAML node location
30
+ - **Precise Error Reporting**: Line and column numbers via `start_mark` and `end_mark`
31
+ - **Metadata Preservation**: Full position tracking for accurate diagnostics
32
+
33
+ **Python Integration**
34
+ - **Python-Idiomatic Naming**: snake_case field names (e.g., `bearer_format`, `property_name`)
35
+ - **Spec-Aligned Mapping**: Automatic YAML name mapping (e.g., `bearerFormat` ↔ `bearer_format`)
36
+ - **Type Safety**: Full type hints with Generic types (`FieldSource[T]`, `KeySource[T]`, `ValueSource[T]`)
37
+
38
+ **Extensibility**
39
+ - **Extension Support**: Automatic extraction of OpenAPI `x-*` specification extensions
40
+ - **Unknown Field Tracking**: Capture typos and invalid fields for validation tools
41
+ - **Generic Builder Pattern**: Core `build_model()` function with object-specific builders for complex cases
42
+
43
+ **Performance**
44
+ - **Memory Efficient**: Immutable frozen dataclasses with `__slots__` for optimal memory usage
45
+ - **Shared Context**: All instances share a single YAML constructor for efficiency
46
+
47
+ **Version Support**
48
+ - **OpenAPI 2.0**: Planned for future release
49
+ - **OpenAPI 3.0.x**: Fully implemented
50
+ - **OpenAPI 3.1.x**: Fully implemented with JSON Schema 2020-12 support
51
+ - **OpenAPI 3.2.x**: Planned for future release
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install jentic-openapi-datamodels
57
+ ```
58
+
59
+ **Prerequisites:**
60
+ - Python 3.11+
61
+
62
+ ## Quick Start
63
+
64
+ ### Parsing with the `datamodel-low` Parser Backend (Recommended)
65
+
66
+ The easiest way to parse OpenAPI documents into datamodels is using the `datamodel-low` backend from `jentic-openapi-parser`. This backend automatically detects the OpenAPI version and returns the appropriate typed datamodel:
67
+
68
+ ```python
69
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
70
+ from jentic.apitools.openapi.parser.backends.datamodel_low import DataModelLow
71
+ from jentic.apitools.openapi.datamodels.low.v30.openapi import OpenAPI30
72
+ from jentic.apitools.openapi.datamodels.low.v31.openapi import OpenAPI31
73
+
74
+ # Create parser with datamodel-low backend
75
+ parser = OpenAPIParser("datamodel-low")
76
+
77
+ # Parse OpenAPI 3.0 document - automatically returns OpenAPI30
78
+ doc = parser.parse("""
79
+ openapi: 3.0.4
80
+ info:
81
+ title: Pet Store API
82
+ version: 1.0.0
83
+ paths:
84
+ /pets:
85
+ get:
86
+ summary: List all pets
87
+ responses:
88
+ '200':
89
+ description: A list of pets
90
+ """, return_type=DataModelLow)
91
+
92
+ assert isinstance(doc, OpenAPI30)
93
+ print(doc.openapi.value) # "3.0.4"
94
+ print(doc.info.value.title.value) # "Pet Store API"
95
+
96
+ # Parse OpenAPI 3.1 document - automatically returns OpenAPI31
97
+ doc = parser.parse("""
98
+ openapi: 3.1.2
99
+ info:
100
+ title: Pet Store API
101
+ version: 1.0.0
102
+ paths: {}
103
+ """, return_type=DataModelLow)
104
+
105
+ assert isinstance(doc, OpenAPI31)
106
+ print(doc.openapi.value) # "3.1.2"
107
+ ```
108
+
109
+ **Benefits of `datamodel-low` backend:**
110
+ - Automatic version detection (no manual version checking)
111
+ - Returns strongly-typed `OpenAPI30` or `OpenAPI31` objects
112
+ - Complete source tracking preserved
113
+ - Single-step parsing (no need to manually call `build()`)
114
+
115
+ ### Manual Parsing with Builder Functions
116
+
117
+ For advanced use cases or custom workflows, you can manually parse and build datamodels:
118
+
119
+ #### Parsing OpenAPI 3.0 Documents
120
+
121
+ The manual approach uses the `ruamel-ast` backend followed by calling the builder function:
122
+
123
+ ```python
124
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
125
+ from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
126
+ from jentic.apitools.openapi.datamodels.low.v30 import build
127
+
128
+ # Parse OpenAPI document
129
+ parser = OpenAPIParser("ruamel-ast")
130
+ root = parser.parse("""
131
+ openapi: 3.0.4
132
+ info:
133
+ title: Pet Store API
134
+ version: 1.0.0
135
+ paths:
136
+ /pets:
137
+ get:
138
+ summary: List all pets
139
+ responses:
140
+ '200':
141
+ description: A list of pets
142
+ """, return_type=MappingNode)
143
+
144
+ # Build OpenAPI document model
145
+ openapi_doc = build(root)
146
+
147
+ # Access document fields via Python naming (snake_case)
148
+ print(openapi_doc.openapi.value) # "3.0.4"
149
+ print(openapi_doc.info.value.title.value) # "Pet Store API"
150
+ print(openapi_doc.info.value.version.value) # "1.0.0"
151
+
152
+ # Access nested fields with full type safety
153
+ for path_key, path_item in openapi_doc.paths.value.path_items.items():
154
+ print(f"Path: {path_key.value}") # "/pets"
155
+ if path_item.value.get:
156
+ operation = path_item.value.get.value
157
+ print(f" Summary: {operation.summary.value}") # "List all pets"
158
+ ```
159
+
160
+ #### Parsing OpenAPI 3.1 Documents with JSON Schema 2020-12
161
+
162
+ OpenAPI 3.1 fully supports JSON Schema 2020-12, including advanced features like boolean schemas, conditional validation and vocabulary declarations:
163
+
164
+ ```python
165
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
166
+ from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
167
+ from jentic.apitools.openapi.datamodels.low.v31 import build
168
+
169
+ # Parse OpenAPI 3.1 document with JSON Schema 2020-12 features
170
+ parser = OpenAPIParser("ruamel-ast")
171
+ root = parser.parse("""
172
+ openapi: 3.1.2
173
+ info:
174
+ title: Pet Store API
175
+ version: 1.0.0
176
+ paths:
177
+ /pets:
178
+ get:
179
+ responses:
180
+ '200':
181
+ description: Pet list
182
+ content:
183
+ application/json:
184
+ schema:
185
+ type: array
186
+ prefixItems:
187
+ - type: string
188
+ - type: integer
189
+ items: false
190
+ contains:
191
+ type: object
192
+ required: [id]
193
+ """, return_type=MappingNode)
194
+
195
+ openapi_doc = build(root)
196
+
197
+ # Access JSON Schema 2020-12 features
198
+ schema = openapi_doc.paths.value.path_items["/pets"].value.get.value.responses.value["200"].value.content.value["application/json"].value.schema
199
+ print(schema.prefix_items.value[0].type.value) # "string"
200
+ print(schema.items.value) # False (boolean schema)
201
+ print(schema.contains.value.required.value[0].value) # "id"
202
+ ```
203
+
204
+ ### Parsing Individual Spec Objects
205
+
206
+ You can also parse individual OpenAPI specification objects:
207
+
208
+ ```python
209
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
210
+ from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
211
+ from jentic.apitools.openapi.datamodels.low.v30.security_scheme import build as build_security_scheme
212
+
213
+ # Parse a Security Scheme object
214
+ parser = OpenAPIParser("ruamel-ast")
215
+ root = parser.parse("""
216
+ type: http
217
+ scheme: bearer
218
+ bearerFormat: JWT
219
+ """, return_type=MappingNode)
220
+
221
+ security_scheme = build_security_scheme(root)
222
+
223
+ # Access via Python field names (snake_case)
224
+ print(security_scheme.bearer_format.value) # "JWT"
225
+
226
+ # Access source location information
227
+ print(security_scheme.bearer_format.key_node.value) # "bearerFormat"
228
+ print(security_scheme.bearer_format.key_node.start_mark.line) # Line number
229
+ ```
230
+
231
+ You can also parse OpenAPI 3.1 Schema objects with JSON Schema 2020-12 features:
232
+
233
+ ```python
234
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
235
+ from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
236
+ from jentic.apitools.openapi.datamodels.low.v31.schema import build as build_schema
237
+
238
+ # Parse a Schema object with JSON Schema 2020-12 features
239
+ parser = OpenAPIParser("ruamel-ast")
240
+ root = parser.parse("""
241
+ type: object
242
+ properties:
243
+ id:
244
+ type: integer
245
+ tags:
246
+ type: array
247
+ prefixItems:
248
+ - type: string
249
+ - type: string
250
+ items: false
251
+ patternProperties:
252
+ "^x-":
253
+ type: string
254
+ unevaluatedProperties: false
255
+ if:
256
+ properties:
257
+ premium:
258
+ const: true
259
+ then:
260
+ required: [support_tier]
261
+ """, return_type=MappingNode)
262
+
263
+ schema = build_schema(root)
264
+
265
+ # Access JSON Schema 2020-12 fields via Python naming (snake_case)
266
+ print(schema.properties.value["id"].type.value) # "integer"
267
+ print(schema.pattern_properties.value["^x-"].type.value) # "string"
268
+ print(schema.unevaluated_properties.value) # False
269
+ print(schema.prefix_items.value[0].type.value) # "string"
270
+
271
+ # Access conditional schema fields
272
+ print(schema.if_.value.properties.value["premium"].const.value) # True
273
+ print(schema.then_.value.required.value[0].value) # "support_tier"
274
+
275
+ # Access source location information
276
+ print(schema.type.key_node.start_mark.line) # Line number for "type" key
277
+ ```
278
+
279
+ ### Field Name Mapping
280
+
281
+ YAML `camelCase` fields automatically map to Python `snake_case`:
282
+ - `bearerFormat` → `bearer_format`
283
+ - `authorizationUrl` → `authorization_url`
284
+ - `openIdConnectUrl` → `openid_connect_url`
285
+
286
+ Special cases for Python reserved keywords and `$` fields:
287
+
288
+ - `in` → `in_`
289
+ - `if` → `if_`
290
+ - `then` → `then_`
291
+ - `else` → `else_`
292
+ - `not` → `not_`
293
+ - `$ref` → `ref`
294
+ - `$id` → `id`
295
+ - `$schema` → `schema`
296
+
297
+ ### Source Tracking
298
+
299
+ The package provides three immutable wrapper types for preserving source information:
300
+
301
+ **FieldSource[T]** - For OpenAPI fields with key-value pairs
302
+ - Used for: Fixed fields (`name`, `bearer_format`) and patterned fields (status codes, path items, schema properties)
303
+ - Tracks: Both key and value nodes
304
+ - Example: `SecurityScheme.bearer_format` is `FieldSource[str]`, response status codes are `FieldSource[Response]`
305
+
306
+ **KeySource[T]** - For dictionary keys
307
+ - Used for: keys in OpenAPI fields, `x-*` extensions and mapping dictionaries
308
+ - Tracks: Only key node
309
+ - Example: Keys in `Discriminator.mapping` are `KeySource[str]`
310
+
311
+ **ValueSource[T]** - For dictionary values and array items
312
+ - Used for: values in OpenAPI fields, in `x-*` extensions, mapping dictionaries and array items
313
+ - Tracks: Only value node
314
+ - Example: Values in `Discriminator.mapping` are `ValueSource[str]`
315
+
316
+ ```python
317
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
318
+ from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
319
+ from jentic.apitools.openapi.datamodels.low.v30 import build
320
+
321
+ # FieldSource: Fixed specification fields in OpenAPI document
322
+ parser = OpenAPIParser("ruamel-ast")
323
+ root = parser.parse("""
324
+ openapi: 3.0.4
325
+ info:
326
+ title: Pet Store API
327
+ version: 1.0.0
328
+ paths: {}
329
+ """, return_type=MappingNode)
330
+ openapi_doc = build(root)
331
+
332
+ field = openapi_doc.info.value.title # FieldSource[str]
333
+ print(field.value) # "Pet Store API" - The actual value
334
+ print(field.key_node) # YAML node for "title"
335
+ print(field.value_node) # YAML node for "Pet Store API"
336
+
337
+ # KeySource/ValueSource: Dictionary fields (extensions, mapping)
338
+ # Extensions in OpenAPI objects use KeySource/ValueSource
339
+ root = parser.parse("""
340
+ openapi: 3.0.4
341
+ info:
342
+ title: API
343
+ version: 1.0.0
344
+ x-custom: value
345
+ x-another: data
346
+ paths: {}
347
+ """, return_type=MappingNode)
348
+ openapi_doc = build(root)
349
+
350
+ for key, value in openapi_doc.info.value.extensions.items():
351
+ print(key.value) # KeySource[str]: "x-custom" or "x-another"
352
+ print(key.key_node) # YAML node for the extension key
353
+ print(value.value) # ValueSource: "value" or "data"
354
+ print(value.value_node) # YAML node for the extension value
355
+ ```
356
+
357
+ ### Location Ranges
358
+
359
+ Access precise location ranges within the source document using start_mark and end_mark:
360
+
361
+ ```python
362
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
363
+ from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
364
+ from jentic.apitools.openapi.datamodels.low.v30 import build
365
+
366
+ yaml_content = """
367
+ openapi: 3.0.4
368
+ info:
369
+ title: Pet Store API
370
+ version: 1.0.0
371
+ description: A sample Pet Store API
372
+ paths: {}
373
+ """
374
+
375
+ parser = OpenAPIParser("ruamel-ast")
376
+ root = parser.parse(yaml_content, return_type=MappingNode)
377
+ openapi_doc = build(root)
378
+
379
+ # Access location information for any field
380
+ field = openapi_doc.info.value.title
381
+
382
+ # Key location (e.g., "title")
383
+ print(f"Key start: line {field.key_node.start_mark.line}, col {field.key_node.start_mark.column}")
384
+ print(f"Key end: line {field.key_node.end_mark.line}, col {field.key_node.end_mark.column}")
385
+
386
+ # Value location (e.g., "Pet Store API")
387
+ print(f"Value start: line {field.value_node.start_mark.line}, col {field.value_node.start_mark.column}")
388
+ print(f"Value end: line {field.value_node.end_mark.line}, col {field.value_node.end_mark.column}")
389
+
390
+ # Full field range (from key start to value end)
391
+ start = field.key_node.start_mark
392
+ end = field.value_node.end_mark
393
+ print(f"Field range: ({start.line}:{start.column}) to ({end.line}:{end.column})")
394
+ ```
395
+
396
+ ### Invalid Data Handling
397
+
398
+ Low-level models preserve invalid data without validation:
399
+
400
+ ```python
401
+ from jentic.apitools.openapi.parser.core import OpenAPIParser
402
+ from jentic.apitools.openapi.parser.backends.ruamel_ast import MappingNode
403
+ from jentic.apitools.openapi.datamodels.low.v30 import build
404
+
405
+ parser = OpenAPIParser("ruamel-ast")
406
+ root = parser.parse("""
407
+ openapi: 3.0.4
408
+ info:
409
+ title: 123 # Intentionally wrong type for demonstration (should be string)
410
+ version: 1.0.0
411
+ paths: {}
412
+ """, return_type=MappingNode)
413
+
414
+ openapi_doc = build(root)
415
+ print(openapi_doc.info.value.title.value) # 123 (preserved as-is)
416
+ print(type(openapi_doc.info.value.title.value)) # <class 'int'>
417
+
418
+ # Invalid data is preserved with full source tracking for validation tools
419
+ print(openapi_doc.info.value.title.value_node.start_mark.line) # Line number
420
+ ```
421
+
422
+ ### Error Reporting
423
+
424
+ This architecture—where the low-level model preserves data without validation and validation tools consume
425
+ that data—allows the low-level model to remain simple while enabling sophisticated validation tools to provide
426
+ user-friendly error messages with exact source locations.
427
+
428
+ ## Testing
429
+
430
+ Run the test suite:
431
+
432
+ ```bash
433
+ uv run --package jentic-openapi-datamodels pytest packages/jentic-openapi-datamodels -v
434
+ ```