sc-oa 0.7.0.13__py3-none-any.whl → 0.7.0.14__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.
Potentially problematic release.
This version of sc-oa might be problematic. Click here for more details.
- {sc_oa-0.7.0.13.dist-info → sc_oa-0.7.0.14.dist-info}/LICENSE +23 -23
- {sc_oa-0.7.0.13.dist-info → sc_oa-0.7.0.14.dist-info}/METADATA +45 -42
- sc_oa-0.7.0.14.dist-info/RECORD +26 -0
- {sc_oa-0.7.0.13.dist-info → sc_oa-0.7.0.14.dist-info}/WHEEL +1 -1
- sphinxcontrib/__init__.py +10 -0
- sphinxcontrib/openapi/__init__.py +93 -93
- sphinxcontrib/openapi/__main__.py +86 -86
- sphinxcontrib/openapi/_lib2to3.py +378 -378
- sphinxcontrib/openapi/directive.py +58 -58
- sphinxcontrib/openapi/locale/es_ES/LC_MESSAGES/openapi.po +170 -170
- sphinxcontrib/openapi/locale/fr_FR/LC_MESSAGES/openapi.po +170 -170
- sphinxcontrib/openapi/locale/openapi.pot +168 -168
- sphinxcontrib/openapi/openapi20.py +263 -263
- sphinxcontrib/openapi/openapi30.py +748 -748
- sphinxcontrib/openapi/renderers/__init__.py +18 -18
- sphinxcontrib/openapi/renderers/_description.py +26 -26
- sphinxcontrib/openapi/renderers/_httpdomain.py +620 -620
- sphinxcontrib/openapi/renderers/_httpdomain_old.py +59 -59
- sphinxcontrib/openapi/renderers/_model.py +422 -422
- sphinxcontrib/openapi/renderers/_toc.py +48 -48
- sphinxcontrib/openapi/renderers/abc.py +46 -46
- sphinxcontrib/openapi/schema_utils.py +137 -137
- sphinxcontrib/openapi/utils.py +137 -137
- sc_oa-0.7.0.13-py3.9-nspkg.pth +0 -1
- sc_oa-0.7.0.13.dist-info/RECORD +0 -27
- sc_oa-0.7.0.13.dist-info/namespace_packages.txt +0 -1
- {sc_oa-0.7.0.13.dist-info → sc_oa-0.7.0.14.dist-info}/top_level.txt +0 -0
sphinxcontrib/openapi/utils.py
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
"""
|
|
2
|
-
sphinxcontrib.openapi.utils
|
|
3
|
-
---------------------------
|
|
4
|
-
|
|
5
|
-
Common functionality shared across the various renderers.
|
|
6
|
-
|
|
7
|
-
:copyright: (c) 2016, Ihor Kalnytskyi.
|
|
8
|
-
:license: BSD, see LICENSE for details.
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
from __future__ import unicode_literals
|
|
12
|
-
|
|
13
|
-
import collections
|
|
14
|
-
import collections.abc
|
|
15
|
-
|
|
16
|
-
from contextlib import closing
|
|
17
|
-
import jsonschema
|
|
18
|
-
import yaml
|
|
19
|
-
try:
|
|
20
|
-
from m2r2 import convert as convert_markdown
|
|
21
|
-
except ImportError:
|
|
22
|
-
convert_markdown = None
|
|
23
|
-
|
|
24
|
-
from urllib.parse import urlsplit
|
|
25
|
-
from urllib.request import urlopen
|
|
26
|
-
|
|
27
|
-
import os.path
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class OpenApiRefResolver(jsonschema.RefResolver):
|
|
31
|
-
"""
|
|
32
|
-
Overrides resolve_remote to support both YAML and JSON
|
|
33
|
-
OpenAPI schemas.
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
try:
|
|
37
|
-
import requests
|
|
38
|
-
_requests = requests
|
|
39
|
-
except ImportError:
|
|
40
|
-
_requests = None
|
|
41
|
-
|
|
42
|
-
def resolve_remote(self, uri):
|
|
43
|
-
scheme, _, path, _, _ = urlsplit(uri)
|
|
44
|
-
_, extension = os.path.splitext(path)
|
|
45
|
-
|
|
46
|
-
if extension not in [".yml", ".yaml"] or scheme in self.handlers:
|
|
47
|
-
return super(OpenApiRefResolver, self).resolve_remote(uri)
|
|
48
|
-
|
|
49
|
-
if scheme in [u"http", u"https"] and self._requests:
|
|
50
|
-
response = self._requests.get(uri)
|
|
51
|
-
result = yaml.safe_load(response)
|
|
52
|
-
else:
|
|
53
|
-
# Otherwise, pass off to urllib and assume utf-8
|
|
54
|
-
with closing(urlopen(uri)) as url:
|
|
55
|
-
response = url.read().decode("utf-8")
|
|
56
|
-
result = yaml.safe_load(response)
|
|
57
|
-
|
|
58
|
-
if self.cache_remote:
|
|
59
|
-
self.store[uri] = result
|
|
60
|
-
return result
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def _resolve_refs(uri, spec):
|
|
64
|
-
"""Resolve JSON references in a given dictionary.
|
|
65
|
-
|
|
66
|
-
OpenAPI spec may contain JSON references to its nodes or external
|
|
67
|
-
sources, so any attempt to rely that there's some expected attribute
|
|
68
|
-
in the spec may fail. So we need to resolve JSON references before
|
|
69
|
-
we use it (i.e. replace with referenced object). For details see:
|
|
70
|
-
|
|
71
|
-
https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-02
|
|
72
|
-
|
|
73
|
-
The input spec is modified in-place despite being returned from
|
|
74
|
-
the function.
|
|
75
|
-
"""
|
|
76
|
-
|
|
77
|
-
resolver = OpenApiRefResolver(uri, spec)
|
|
78
|
-
|
|
79
|
-
def _do_resolve(node):
|
|
80
|
-
if isinstance(node, collections.abc.Mapping) and '$ref' in node:
|
|
81
|
-
ref = node['$ref']
|
|
82
|
-
with resolver.resolving(node['$ref']) as resolved:
|
|
83
|
-
ret = _do_resolve(resolved) # might have recursive references
|
|
84
|
-
# Restore the $ref in case we want to
|
|
85
|
-
# separate the entities in the document
|
|
86
|
-
if isinstance(ret, collections.abc.Mapping):
|
|
87
|
-
ret['$entity_ref'] = ref
|
|
88
|
-
return ret
|
|
89
|
-
elif isinstance(node, collections.abc.Mapping):
|
|
90
|
-
for k, v in node.items():
|
|
91
|
-
node[k] = _do_resolve(v)
|
|
92
|
-
elif isinstance(node, (list, tuple)):
|
|
93
|
-
for i in range(len(node)):
|
|
94
|
-
node[i] = _do_resolve(node[i])
|
|
95
|
-
return node
|
|
96
|
-
|
|
97
|
-
return _do_resolve(spec)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def normalize_spec(spec, **options):
|
|
101
|
-
# OpenAPI spec may contain JSON references, so we need resolve them
|
|
102
|
-
# before we access the actual values trying to build an httpdomain
|
|
103
|
-
# markup. Since JSON references may be relative, it's crucial to
|
|
104
|
-
# pass a document URI in order to properly resolve them.
|
|
105
|
-
spec = _resolve_refs(options.get('uri', ''), spec)
|
|
106
|
-
|
|
107
|
-
# OpenAPI spec may contain common endpoint's parameters top-level.
|
|
108
|
-
# In order to do not place if-s around the code to handle special
|
|
109
|
-
# cases, let's normalize the spec and push common parameters inside
|
|
110
|
-
# endpoints definitions.
|
|
111
|
-
for endpoint in spec['paths'].values():
|
|
112
|
-
parameters = endpoint.pop('parameters', [])
|
|
113
|
-
for method in endpoint.values():
|
|
114
|
-
method.setdefault('parameters', [])
|
|
115
|
-
method['parameters'].extend(parameters)
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def _conv_md(s):
|
|
119
|
-
try:
|
|
120
|
-
return convert_markdown(s)
|
|
121
|
-
except Exception:
|
|
122
|
-
return s
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def get_text_converter(options):
|
|
126
|
-
"""Decide on a text converter for prose."""
|
|
127
|
-
if 'format' in options:
|
|
128
|
-
if options['format'] == 'markdown':
|
|
129
|
-
if convert_markdown is None:
|
|
130
|
-
raise ValueError(
|
|
131
|
-
"Markdown conversion isn't available, "
|
|
132
|
-
"install the [markdown] extra."
|
|
133
|
-
)
|
|
134
|
-
return _conv_md
|
|
135
|
-
|
|
136
|
-
# No conversion needed.
|
|
137
|
-
return lambda s: s
|
|
1
|
+
"""
|
|
2
|
+
sphinxcontrib.openapi.utils
|
|
3
|
+
---------------------------
|
|
4
|
+
|
|
5
|
+
Common functionality shared across the various renderers.
|
|
6
|
+
|
|
7
|
+
:copyright: (c) 2016, Ihor Kalnytskyi.
|
|
8
|
+
:license: BSD, see LICENSE for details.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import unicode_literals
|
|
12
|
+
|
|
13
|
+
import collections
|
|
14
|
+
import collections.abc
|
|
15
|
+
|
|
16
|
+
from contextlib import closing
|
|
17
|
+
import jsonschema
|
|
18
|
+
import yaml
|
|
19
|
+
try:
|
|
20
|
+
from m2r2 import convert as convert_markdown
|
|
21
|
+
except ImportError:
|
|
22
|
+
convert_markdown = None
|
|
23
|
+
|
|
24
|
+
from urllib.parse import urlsplit
|
|
25
|
+
from urllib.request import urlopen
|
|
26
|
+
|
|
27
|
+
import os.path
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class OpenApiRefResolver(jsonschema.RefResolver):
|
|
31
|
+
"""
|
|
32
|
+
Overrides resolve_remote to support both YAML and JSON
|
|
33
|
+
OpenAPI schemas.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
import requests
|
|
38
|
+
_requests = requests
|
|
39
|
+
except ImportError:
|
|
40
|
+
_requests = None
|
|
41
|
+
|
|
42
|
+
def resolve_remote(self, uri):
|
|
43
|
+
scheme, _, path, _, _ = urlsplit(uri)
|
|
44
|
+
_, extension = os.path.splitext(path)
|
|
45
|
+
|
|
46
|
+
if extension not in [".yml", ".yaml"] or scheme in self.handlers:
|
|
47
|
+
return super(OpenApiRefResolver, self).resolve_remote(uri)
|
|
48
|
+
|
|
49
|
+
if scheme in [u"http", u"https"] and self._requests:
|
|
50
|
+
response = self._requests.get(uri)
|
|
51
|
+
result = yaml.safe_load(response)
|
|
52
|
+
else:
|
|
53
|
+
# Otherwise, pass off to urllib and assume utf-8
|
|
54
|
+
with closing(urlopen(uri)) as url:
|
|
55
|
+
response = url.read().decode("utf-8")
|
|
56
|
+
result = yaml.safe_load(response)
|
|
57
|
+
|
|
58
|
+
if self.cache_remote:
|
|
59
|
+
self.store[uri] = result
|
|
60
|
+
return result
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _resolve_refs(uri, spec):
|
|
64
|
+
"""Resolve JSON references in a given dictionary.
|
|
65
|
+
|
|
66
|
+
OpenAPI spec may contain JSON references to its nodes or external
|
|
67
|
+
sources, so any attempt to rely that there's some expected attribute
|
|
68
|
+
in the spec may fail. So we need to resolve JSON references before
|
|
69
|
+
we use it (i.e. replace with referenced object). For details see:
|
|
70
|
+
|
|
71
|
+
https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-02
|
|
72
|
+
|
|
73
|
+
The input spec is modified in-place despite being returned from
|
|
74
|
+
the function.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
resolver = OpenApiRefResolver(uri, spec)
|
|
78
|
+
|
|
79
|
+
def _do_resolve(node):
|
|
80
|
+
if isinstance(node, collections.abc.Mapping) and '$ref' in node:
|
|
81
|
+
ref = node['$ref']
|
|
82
|
+
with resolver.resolving(node['$ref']) as resolved:
|
|
83
|
+
ret = _do_resolve(resolved) # might have recursive references
|
|
84
|
+
# Restore the $ref in case we want to
|
|
85
|
+
# separate the entities in the document
|
|
86
|
+
if isinstance(ret, collections.abc.Mapping):
|
|
87
|
+
ret['$entity_ref'] = ref
|
|
88
|
+
return ret
|
|
89
|
+
elif isinstance(node, collections.abc.Mapping):
|
|
90
|
+
for k, v in node.items():
|
|
91
|
+
node[k] = _do_resolve(v)
|
|
92
|
+
elif isinstance(node, (list, tuple)):
|
|
93
|
+
for i in range(len(node)):
|
|
94
|
+
node[i] = _do_resolve(node[i])
|
|
95
|
+
return node
|
|
96
|
+
|
|
97
|
+
return _do_resolve(spec)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def normalize_spec(spec, **options):
|
|
101
|
+
# OpenAPI spec may contain JSON references, so we need resolve them
|
|
102
|
+
# before we access the actual values trying to build an httpdomain
|
|
103
|
+
# markup. Since JSON references may be relative, it's crucial to
|
|
104
|
+
# pass a document URI in order to properly resolve them.
|
|
105
|
+
spec = _resolve_refs(options.get('uri', ''), spec)
|
|
106
|
+
|
|
107
|
+
# OpenAPI spec may contain common endpoint's parameters top-level.
|
|
108
|
+
# In order to do not place if-s around the code to handle special
|
|
109
|
+
# cases, let's normalize the spec and push common parameters inside
|
|
110
|
+
# endpoints definitions.
|
|
111
|
+
for endpoint in spec['paths'].values():
|
|
112
|
+
parameters = endpoint.pop('parameters', [])
|
|
113
|
+
for method in endpoint.values():
|
|
114
|
+
method.setdefault('parameters', [])
|
|
115
|
+
method['parameters'].extend(parameters)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _conv_md(s):
|
|
119
|
+
try:
|
|
120
|
+
return convert_markdown(s)
|
|
121
|
+
except Exception:
|
|
122
|
+
return s
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def get_text_converter(options):
|
|
126
|
+
"""Decide on a text converter for prose."""
|
|
127
|
+
if 'format' in options:
|
|
128
|
+
if options['format'] == 'markdown':
|
|
129
|
+
if convert_markdown is None:
|
|
130
|
+
raise ValueError(
|
|
131
|
+
"Markdown conversion isn't available, "
|
|
132
|
+
"install the [markdown] extra."
|
|
133
|
+
)
|
|
134
|
+
return _conv_md
|
|
135
|
+
|
|
136
|
+
# No conversion needed.
|
|
137
|
+
return lambda s: s
|
sc_oa-0.7.0.13-py3.9-nspkg.pth
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('sphinxcontrib',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('sphinxcontrib', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('sphinxcontrib', [os.path.dirname(p)])));m = m or sys.modules.setdefault('sphinxcontrib', types.ModuleType('sphinxcontrib'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
|
sc_oa-0.7.0.13.dist-info/RECORD
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
sc_oa-0.7.0.13-py3.9-nspkg.pth,sha256=YYcv3GPokof0Lzq3hZHkJIlfNzBys5lF7Lt7JGRAP04,575
|
|
2
|
-
sphinxcontrib/openapi/__init__.py,sha256=LmtCBI-dTDmiKvrCSmg5YCzv0au6VCiNuZbULg0LvAs,3168
|
|
3
|
-
sphinxcontrib/openapi/__main__.py,sha256=CeXNtxW1vYEwojIlVxlMhoXz2qIxsCbJp58JEIoo5Js,2522
|
|
4
|
-
sphinxcontrib/openapi/_lib2to3.py,sha256=4LDmNmnGKTfXeq9TbVR0YXbwjYhFwq89zGA6XOtYgts,14002
|
|
5
|
-
sphinxcontrib/openapi/directive.py,sha256=FRZ2JgOekkNK-ltpkNjTDkEpJdkZa5PyXCisHsBa9bU,2117
|
|
6
|
-
sphinxcontrib/openapi/openapi20.py,sha256=zkwCm4aeZLMFNLM-uzj6UJQ4rHtFPdc95Airl3tpd78,9247
|
|
7
|
-
sphinxcontrib/openapi/openapi30.py,sha256=n92psjyd29EHfaz1a8AtUJhuSD7U3tBAGSrUnTl6bqM,29804
|
|
8
|
-
sphinxcontrib/openapi/schema_utils.py,sha256=mI6_4-b8b9j8dane9rHM5y9-Pe7yJgFuLQCBzQWLn3k,4583
|
|
9
|
-
sphinxcontrib/openapi/utils.py,sha256=XGgO2HH6iYlPmn7jP-p36vlKxa50QM4TMnCg8I7-g-g,4480
|
|
10
|
-
sphinxcontrib/openapi/locale/openapi.pot,sha256=69Ry6f7i1NPPE8AxGBBjAJNlK2klcWDbW01Z4eZeTtw,3999
|
|
11
|
-
sphinxcontrib/openapi/locale/es_ES/LC_MESSAGES/openapi.mo,sha256=qdW6yFaSVB_BsexvwM33U8X12yoHikgaI8N7a4U_gI4,1919
|
|
12
|
-
sphinxcontrib/openapi/locale/es_ES/LC_MESSAGES/openapi.po,sha256=FuLzvZ9-I-2CQ9nQTh4VhZ23FqlzYdD-SqMUPujpUUE,4527
|
|
13
|
-
sphinxcontrib/openapi/locale/fr_FR/LC_MESSAGES/openapi.mo,sha256=YS2uZZZ4bHpDXJmShv33NZhtIWcir9-qERusNDR-vqY,1956
|
|
14
|
-
sphinxcontrib/openapi/locale/fr_FR/LC_MESSAGES/openapi.po,sha256=wRkEX1USVUETXnFMXPFo_OH8NjVZJGymMn13E5a2iBo,4570
|
|
15
|
-
sphinxcontrib/openapi/renderers/__init__.py,sha256=76shdyGAuHpJ9Gy3y0MQP1hyT3OMI6uTSrnRMYHwklI,426
|
|
16
|
-
sphinxcontrib/openapi/renderers/_description.py,sha256=1J_e_4nl4wMT2dGkYdNbdQH80UuBJsNNQPq5axlcswM,728
|
|
17
|
-
sphinxcontrib/openapi/renderers/_httpdomain.py,sha256=vLpVQts97dRUzLi4lrPcD1UzGG7dBiPWgnPzbeIozdk,25166
|
|
18
|
-
sphinxcontrib/openapi/renderers/_httpdomain_old.py,sha256=4rbrX_zAaobYgwAI0veDSDhjPNWX4iIJJz9Sp-bKxcg,2691
|
|
19
|
-
sphinxcontrib/openapi/renderers/_model.py,sha256=z2R07XVlk5h5YwGbdqFDo2Oe6cFmvADMeV6eebms0hw,15520
|
|
20
|
-
sphinxcontrib/openapi/renderers/_toc.py,sha256=vY0giwCeyoBejkhEDD0Ok_vGCtZKobICnb1CK7vhDJQ,1526
|
|
21
|
-
sphinxcontrib/openapi/renderers/abc.py,sha256=CuIda0iT0jdEUd2OBGQdq4VcHl2XWKoCAayYztKAzOA,1531
|
|
22
|
-
sc_oa-0.7.0.13.dist-info/LICENSE,sha256=tgm4r1GgqXjKU6uEH1LIWT7ncoq7S56ZbuxNW-F94iU,1342
|
|
23
|
-
sc_oa-0.7.0.13.dist-info/METADATA,sha256=wIXidbNIwAyaEzfzXxAkBoRbqyCZjDBBUzdO3hvuobg,1499
|
|
24
|
-
sc_oa-0.7.0.13.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
25
|
-
sc_oa-0.7.0.13.dist-info/namespace_packages.txt,sha256=VJrV3_vaiKQVgVpR0I1iecxoO0drzGu-M0j40PVP2QQ,14
|
|
26
|
-
sc_oa-0.7.0.13.dist-info/top_level.txt,sha256=VJrV3_vaiKQVgVpR0I1iecxoO0drzGu-M0j40PVP2QQ,14
|
|
27
|
-
sc_oa-0.7.0.13.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
sphinxcontrib
|
|
File without changes
|