jentic-openapi-traverse 1.0.0a29__tar.gz → 1.0.0a31__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.
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/PKG-INFO +2 -2
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/pyproject.toml +2 -2
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/datamodels/low/path.py +42 -23
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/LICENSE +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/NOTICE +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/README.md +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/datamodels/low/__init__.py +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/datamodels/low/introspection.py +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/datamodels/low/merge.py +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/datamodels/low/py.typed +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/datamodels/low/traversal.py +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/json/__init__.py +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/json/py.typed +0 -0
- {jentic_openapi_traverse-1.0.0a29 → jentic_openapi_traverse-1.0.0a31}/src/jentic/apitools/openapi/traverse/json/traversal.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jentic-openapi-traverse
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0a31
|
|
4
4
|
Summary: Jentic OpenAPI Traversal Utilities
|
|
5
5
|
Author: Jentic
|
|
6
6
|
Author-email: Jentic <hello@jentic.com>
|
|
7
7
|
License-Expression: Apache-2.0
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
License-File: NOTICE
|
|
10
|
-
Requires-Dist: jentic-openapi-datamodels~=1.0.
|
|
10
|
+
Requires-Dist: jentic-openapi-datamodels~=1.0.0a31
|
|
11
11
|
Requires-Dist: jsonpointer~=3.0.0
|
|
12
12
|
Requires-Python: >=3.11
|
|
13
13
|
Project-URL: Homepage, https://github.com/jentic/jentic-openapi-tools
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "jentic-openapi-traverse"
|
|
3
|
-
version = "1.0.0-alpha.
|
|
3
|
+
version = "1.0.0-alpha.31"
|
|
4
4
|
description = "Jentic OpenAPI Traversal Utilities"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Jentic", email = "hello@jentic.com" }]
|
|
@@ -8,7 +8,7 @@ license = "Apache-2.0"
|
|
|
8
8
|
license-files = ["LICENSE", "NOTICE"]
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
dependencies = [
|
|
11
|
-
"jentic-openapi-datamodels~=1.0.0-alpha.
|
|
11
|
+
"jentic-openapi-datamodels~=1.0.0-alpha.31",
|
|
12
12
|
"jsonpointer~=3.0.0"
|
|
13
13
|
]
|
|
14
14
|
|
|
@@ -118,43 +118,62 @@ class NodePath:
|
|
|
118
118
|
"$['paths']['/users/{id}']['parameters'][0]"
|
|
119
119
|
"$['components']['schemas']['User']['properties']['name']"
|
|
120
120
|
"""
|
|
121
|
+
parts = self.to_parts()
|
|
122
|
+
|
|
121
123
|
# Root node
|
|
122
|
-
if
|
|
124
|
+
if not parts:
|
|
123
125
|
return "$" if path_format == "jsonpath" else ""
|
|
124
126
|
|
|
125
|
-
# Walk back collecting all segments
|
|
126
|
-
segments: list[str | int] = []
|
|
127
|
-
current = self
|
|
128
|
-
while current.parent_path is not None:
|
|
129
|
-
# Add in reverse order (key first, then field) because we'll reverse the list
|
|
130
|
-
# This ensures field comes before key in the final path
|
|
131
|
-
if current.parent_key is not None:
|
|
132
|
-
segments.append(current.parent_key)
|
|
133
|
-
if current.parent_field:
|
|
134
|
-
# Convert Python field name to YAML name for output
|
|
135
|
-
parent_class = type(current.parent_path.node)
|
|
136
|
-
yaml_name = get_yaml_field_name(parent_class, current.parent_field)
|
|
137
|
-
segments.append(yaml_name)
|
|
138
|
-
current = current.parent_path
|
|
139
|
-
|
|
140
|
-
segments.reverse() # Root to leaf order
|
|
141
|
-
|
|
142
127
|
if path_format == "jsonpath":
|
|
143
128
|
# RFC 9535 Normalized JSONPath: $['field'][index]['key']
|
|
144
129
|
result = ["$"]
|
|
145
|
-
for
|
|
146
|
-
if isinstance(
|
|
130
|
+
for part in parts:
|
|
131
|
+
if isinstance(part, int):
|
|
147
132
|
# Array index: $[0]
|
|
148
|
-
result.append(f"[{
|
|
133
|
+
result.append(f"[{part}]")
|
|
149
134
|
else:
|
|
150
135
|
# Member name: $['field']
|
|
151
136
|
# Escape single quotes in the string
|
|
152
|
-
escaped = str(
|
|
137
|
+
escaped = str(part).replace("'", "\\'")
|
|
153
138
|
result.append(f"['{escaped}']")
|
|
154
139
|
return "".join(result)
|
|
155
140
|
|
|
156
141
|
# RFC 6901 JSON Pointer
|
|
157
|
-
return JsonPointer.from_parts(
|
|
142
|
+
return JsonPointer.from_parts(parts).path
|
|
143
|
+
|
|
144
|
+
def to_parts(self) -> list[str | int]:
|
|
145
|
+
"""
|
|
146
|
+
Return path as a list of path parts (field names, keys, and array indices).
|
|
147
|
+
|
|
148
|
+
Can be used with JsonPointer.from_parts() for conversion.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
List of path parts from root to this node.
|
|
152
|
+
Empty list for root node.
|
|
153
|
+
|
|
154
|
+
Examples:
|
|
155
|
+
[] (root)
|
|
156
|
+
["info"]
|
|
157
|
+
["paths", "/users", "get"]
|
|
158
|
+
["paths", "/users", "get", "parameters", 0]
|
|
159
|
+
["components", "schemas", "User", "properties", "name"]
|
|
160
|
+
"""
|
|
161
|
+
if self.parent_path is None:
|
|
162
|
+
return []
|
|
163
|
+
|
|
164
|
+
parts: list[str | int] = []
|
|
165
|
+
current = self
|
|
166
|
+
while current.parent_path is not None:
|
|
167
|
+
if current.parent_key is not None:
|
|
168
|
+
parts.append(current.parent_key)
|
|
169
|
+
if current.parent_field:
|
|
170
|
+
parent_class = type(current.parent_path.node)
|
|
171
|
+
yaml_name = get_yaml_field_name(parent_class, current.parent_field)
|
|
172
|
+
parts.append(yaml_name)
|
|
173
|
+
current = current.parent_path
|
|
174
|
+
|
|
175
|
+
parts.reverse()
|
|
176
|
+
return parts
|
|
158
177
|
|
|
159
178
|
def get_root(self) -> Any:
|
|
160
179
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|