jentic-openapi-traverse 1.0.0a24__py3-none-any.whl → 1.0.0a26__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.
@@ -15,9 +15,33 @@ __all__ = [
15
15
  "get_traversable_fields",
16
16
  "unwrap_value",
17
17
  "is_datamodel_node",
18
+ "get_yaml_field_name",
18
19
  ]
19
20
 
20
21
 
22
+ def get_yaml_field_name(node_class: type, python_field_name: str) -> str:
23
+ """
24
+ Convert Python field name to YAML field name using metadata.
25
+
26
+ Args:
27
+ node_class: Datamodel class type
28
+ python_field_name: Python attribute name (e.g., "external_docs")
29
+
30
+ Returns:
31
+ YAML field name from metadata, or python_field_name if not found
32
+ (e.g., "externalDocs")
33
+ """
34
+ fixed = fixed_fields(node_class)
35
+ patterned = patterned_fields(node_class)
36
+
37
+ # Try fixed fields first, then patterned
38
+ field_obj = fixed.get(python_field_name) or patterned.get(python_field_name)
39
+ if field_obj:
40
+ return field_obj.metadata.get("yaml_name", python_field_name)
41
+
42
+ return python_field_name
43
+
44
+
21
45
  # Cache of field names to check per class type
22
46
  # {Info: ["title", "description", "contact", ...], Operation: [...], ...}
23
47
  _FIELD_NAMES_CACHE: dict[type, list[str]] = {}
@@ -5,6 +5,8 @@ from typing import Any, Literal
5
5
 
6
6
  from jsonpointer import JsonPointer
7
7
 
8
+ from .introspection import get_yaml_field_name
9
+
8
10
 
9
11
  __all__ = ["NodePath"]
10
12
 
@@ -129,7 +131,10 @@ class NodePath:
129
131
  if current.parent_key is not None:
130
132
  segments.append(current.parent_key)
131
133
  if current.parent_field:
132
- segments.append(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)
133
138
  current = current.parent_path
134
139
 
135
140
  segments.reverse() # Root to leaf order
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jentic-openapi-traverse
3
- Version: 1.0.0a24
3
+ Version: 1.0.0a26
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.0a24
10
+ Requires-Dist: jentic-openapi-datamodels~=1.0.0a26
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,14 +1,14 @@
1
1
  jentic/apitools/openapi/traverse/datamodels/low/__init__.py,sha256=M0xRiYA2ErksACo8bKSVIu6PVx9aiYTDCHEkcTnmXAA,277
2
- jentic/apitools/openapi/traverse/datamodels/low/introspection.py,sha256=_QzvTnxrSlyRc_QIajyEkaKEwyng7t1y_qx9dEXxwg8,3216
2
+ jentic/apitools/openapi/traverse/datamodels/low/introspection.py,sha256=iSACRXtpeWRwTx0gI5ZcuWtCGguUPn7eCun3JJQfziY,3970
3
3
  jentic/apitools/openapi/traverse/datamodels/low/merge.py,sha256=Z7OpX14y740oC2ML_ylTE0TTh-ZbrEaliMU9s1bDFfM,4411
4
- jentic/apitools/openapi/traverse/datamodels/low/path.py,sha256=l-2w0uV4OobkswNfhBXkv9wgGMYyB4HEpPTivMmto8o,5442
4
+ jentic/apitools/openapi/traverse/datamodels/low/path.py,sha256=g6nCpOaAq5koWd5KMhq-F285AhK-wmRX3WUxMZupfGs,5693
5
5
  jentic/apitools/openapi/traverse/datamodels/low/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  jentic/apitools/openapi/traverse/datamodels/low/traversal.py,sha256=cAWnTQjmb5fKafbiEaJvv-FK-3fuip-EhdOLfZLVQjk,8774
7
7
  jentic/apitools/openapi/traverse/json/__init__.py,sha256=1euUmpZviE_ECtpXYchpO8hZito2BINPjfSHMNqAU8k,326
8
8
  jentic/apitools/openapi/traverse/json/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  jentic/apitools/openapi/traverse/json/traversal.py,sha256=1ouszn4S29X0iJaMxxb1neyClbWXqIKwFGhHROcpBSI,3524
10
- jentic_openapi_traverse-1.0.0a24.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
11
- jentic_openapi_traverse-1.0.0a24.dist-info/licenses/NOTICE,sha256=pAOGW-rGw9KNc2cuuLWZkfx0GSTV4TicbgBKZSLPMIs,168
12
- jentic_openapi_traverse-1.0.0a24.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
13
- jentic_openapi_traverse-1.0.0a24.dist-info/METADATA,sha256=m7DrnZ_zS1W1NHvPLFxAIx4_dLZxGAFrApk0mG5cEsg,14733
14
- jentic_openapi_traverse-1.0.0a24.dist-info/RECORD,,
10
+ jentic_openapi_traverse-1.0.0a26.dist-info/licenses/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
11
+ jentic_openapi_traverse-1.0.0a26.dist-info/licenses/NOTICE,sha256=pAOGW-rGw9KNc2cuuLWZkfx0GSTV4TicbgBKZSLPMIs,168
12
+ jentic_openapi_traverse-1.0.0a26.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
13
+ jentic_openapi_traverse-1.0.0a26.dist-info/METADATA,sha256=o-0Gq03a0aqzbvyIsxpnssVbtifKLwh40MbkBLQaQuo,14733
14
+ jentic_openapi_traverse-1.0.0a26.dist-info/RECORD,,