jentic-openapi-transformer 1.0.0a10__tar.gz → 1.0.0a12__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.
Potentially problematic release.
This version of jentic-openapi-transformer might be problematic. Click here for more details.
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/PKG-INFO +5 -4
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/pyproject.toml +8 -3
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/core/references.py +13 -30
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/LICENSE +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/NOTICE +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/README.md +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/bundler/backends/base.py +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/bundler/backends/default.py +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/bundler/backends/py.typed +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/bundler/core/__init__.py +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/bundler/core/bundler.py +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/bundler/core/py.typed +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/core/__init__.py +0 -0
- {jentic_openapi_transformer-1.0.0a10 → jentic_openapi_transformer-1.0.0a12}/src/jentic/apitools/openapi/transformer/core/normalize.py +0 -0
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jentic-openapi-transformer
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.0a12
|
|
4
4
|
Summary: Jentic OpenAPI Transformer
|
|
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-
|
|
11
|
-
Requires-Dist: jentic-openapi-
|
|
12
|
-
Requires-Dist: jentic-openapi-
|
|
10
|
+
Requires-Dist: jentic-openapi-common~=1.0.0a12
|
|
11
|
+
Requires-Dist: jentic-openapi-parser~=1.0.0a12
|
|
12
|
+
Requires-Dist: jentic-openapi-traverse~=1.0.0a12
|
|
13
|
+
Requires-Dist: jentic-openapi-transformer-redocly~=1.0.0a12 ; extra == 'redocly'
|
|
13
14
|
Requires-Python: >=3.11
|
|
14
15
|
Project-URL: Homepage, https://github.com/jentic/jentic-openapi-tools
|
|
15
16
|
Provides-Extra: redocly
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "jentic-openapi-transformer"
|
|
3
|
-
version = "1.0.0-alpha.
|
|
3
|
+
version = "1.0.0-alpha.12"
|
|
4
4
|
description = "Jentic OpenAPI Transformer"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Jentic", email = "hello@jentic.com" }]
|
|
7
7
|
license = "Apache-2.0"
|
|
8
8
|
license-files = ["LICENSE", "NOTICE"]
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
|
-
dependencies = [
|
|
10
|
+
dependencies = [
|
|
11
|
+
"jentic-openapi-common~=1.0.0-alpha.12",
|
|
12
|
+
"jentic-openapi-parser~=1.0.0-alpha.12",
|
|
13
|
+
"jentic-openapi-traverse~=1.0.0-alpha.12",
|
|
14
|
+
]
|
|
11
15
|
|
|
12
16
|
[tool.uv]
|
|
13
17
|
package = true
|
|
@@ -18,12 +22,13 @@ module-name = "jentic.apitools.openapi.transformer"
|
|
|
18
22
|
module-root = "src/"
|
|
19
23
|
|
|
20
24
|
[project.optional-dependencies]
|
|
21
|
-
redocly = ["jentic-openapi-transformer-redocly~=1.0.0-alpha.
|
|
25
|
+
redocly = ["jentic-openapi-transformer-redocly~=1.0.0-alpha.12"]
|
|
22
26
|
|
|
23
27
|
[project.urls]
|
|
24
28
|
Homepage = "https://github.com/jentic/jentic-openapi-tools"
|
|
25
29
|
|
|
26
30
|
[tool.uv.sources]
|
|
31
|
+
jentic-openapi-common = { workspace = true }
|
|
27
32
|
jentic-openapi-parser = { workspace = true }
|
|
28
33
|
jentic-openapi-traverse = { workspace = true }
|
|
29
34
|
jentic-openapi-transformer-redocly = { workspace = true }
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
from typing import Any, Iterator, List, MutableMapping, Tuple, cast
|
|
2
|
-
from urllib.parse import urljoin
|
|
2
|
+
from urllib.parse import urljoin
|
|
3
3
|
|
|
4
|
+
from jentic.apitools.openapi.common.uri import (
|
|
5
|
+
is_absolute_uri,
|
|
6
|
+
is_fragment_only_uri,
|
|
7
|
+
is_http_https_url,
|
|
8
|
+
is_scheme_relative_uri,
|
|
9
|
+
)
|
|
4
10
|
from jentic.apitools.openapi.traverse.json import JSONPath, traverse
|
|
5
11
|
|
|
6
12
|
|
|
@@ -24,7 +30,7 @@ def find_relative_urls(root: Any) -> List[Tuple[JSONPath, str, str]]:
|
|
|
24
30
|
out: List[Tuple[JSONPath, str, str]] = []
|
|
25
31
|
for path, _parent, key, value in iter_url_fields(root):
|
|
26
32
|
assert isinstance(key, str)
|
|
27
|
-
if key == "$ref" and
|
|
33
|
+
if key == "$ref" and is_fragment_only_uri(value):
|
|
28
34
|
continue
|
|
29
35
|
if _is_relative_like(value):
|
|
30
36
|
new_path = cast(JSONPath, (*path, key))
|
|
@@ -40,9 +46,9 @@ def find_absolute_http_urls(root: Any) -> List[Tuple[JSONPath, str, str]]:
|
|
|
40
46
|
out: List[Tuple[JSONPath, str, str]] = []
|
|
41
47
|
for path, _parent, key, value in iter_url_fields(root):
|
|
42
48
|
assert isinstance(key, str)
|
|
43
|
-
if key == "$ref" and
|
|
49
|
+
if key == "$ref" and is_fragment_only_uri(value):
|
|
44
50
|
continue
|
|
45
|
-
if not _is_relative_like(value) and
|
|
51
|
+
if not _is_relative_like(value) and is_http_https_url(value):
|
|
46
52
|
new_path = cast(JSONPath, (*path, key))
|
|
47
53
|
out.append((new_path, key, value))
|
|
48
54
|
return out
|
|
@@ -83,13 +89,13 @@ def rewrite_urls_inplace(root: Any, opts: RewriteOptions) -> int:
|
|
|
83
89
|
changed = 0
|
|
84
90
|
for _path, parent, key, value in iter_url_fields(root):
|
|
85
91
|
# value is str by iter_url_fields contract
|
|
86
|
-
if key == "$ref" and
|
|
92
|
+
if key == "$ref" and is_fragment_only_uri(value):
|
|
87
93
|
continue # keep pure fragments
|
|
88
94
|
|
|
89
95
|
new_value = value
|
|
90
96
|
if _is_relative_like(value):
|
|
91
97
|
new_value = _absolutize(value, opts.base_url)
|
|
92
|
-
elif opts.include_absolute_urls and opts.original_base_url and
|
|
98
|
+
elif opts.include_absolute_urls and opts.original_base_url and is_absolute_uri(value):
|
|
93
99
|
new_value = _retarget_absolute(value, opts.original_base_url, opts.base_url)
|
|
94
100
|
|
|
95
101
|
if new_value != value:
|
|
@@ -136,29 +142,6 @@ _URL_KEYS_EXPLICIT: frozenset[str] = frozenset(
|
|
|
136
142
|
)
|
|
137
143
|
|
|
138
144
|
|
|
139
|
-
def _is_fragment_only(s: str) -> bool:
|
|
140
|
-
return s.startswith("#")
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
def _is_scheme_relative(s: str) -> bool:
|
|
144
|
-
# e.g. //cdn.example.com/x.yaml (no scheme, but host present)
|
|
145
|
-
return s.startswith("//")
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
def _is_absolute_uri(s: str) -> bool:
|
|
149
|
-
if _is_scheme_relative(s):
|
|
150
|
-
return True
|
|
151
|
-
p = urlparse(s)
|
|
152
|
-
return bool(p.scheme)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
def _is_absolute_http_uri(s: str) -> bool:
|
|
156
|
-
if _is_scheme_relative(s):
|
|
157
|
-
return False
|
|
158
|
-
p = urlparse(s)
|
|
159
|
-
return bool(p.scheme) and p.scheme in ("http", "https")
|
|
160
|
-
|
|
161
|
-
|
|
162
145
|
def _looks_like_uri(s: str) -> bool:
|
|
163
146
|
# Heuristic: treat strings with ':' before any slash as potentially absolute
|
|
164
147
|
# but we also want to catch relative paths like './x', '../x', 'a/b', '/a'
|
|
@@ -190,7 +173,7 @@ def _is_relative_like(s: str) -> bool:
|
|
|
190
173
|
"""Relative (incl. root-relative '/x') and not fragment-only or scheme-relative."""
|
|
191
174
|
if not _looks_like_uri(s):
|
|
192
175
|
return False
|
|
193
|
-
if
|
|
176
|
+
if is_fragment_only_uri(s) or is_scheme_relative_uri(s) or is_absolute_uri(s):
|
|
194
177
|
return False
|
|
195
178
|
# At this point treat anything else as relative: './x', '../x', 'x', 'x/y', '/x'
|
|
196
179
|
return True
|
|
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
|