sc-oa 0.7.0.15__py3-none-any.whl → 0.7.0.16__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.

@@ -1,59 +1,59 @@
1
- """Here lies still breathing and only renderer implementation."""
2
-
3
- from docutils.parsers.rst import directives
4
-
5
- from . import abc
6
- from .. import openapi20, openapi30, utils
7
-
8
-
9
- class HttpdomainOldRenderer(abc.RestructuredTextRenderer):
10
-
11
- option_spec = {
12
- # A list of endpoints to be rendered. Endpoints must be whitespace
13
- # delimited.
14
- "paths": lambda s: s.split(),
15
- # Regular expression patterns to includes/excludes endpoints to/from
16
- # rendering. Similar to paths, the patterns must be whitespace
17
- # delimited.
18
- "include": lambda s: s.split(),
19
- "exclude": lambda s: s.split(),
20
- # Endpoints to be included based on HTTP method names.
21
- "methods": lambda s: s.split(),
22
- # Render the request body structure when passed.
23
- "request": directives.flag,
24
- # Render request/response examples when passed.
25
- "examples": directives.flag, # render examples when passed
26
- # Render request/response examples in one block or inline with the response codes.
27
- "contextpath": directives.flag, # use the server path as prefix in service URL
28
- "group_examples": directives.flag, # render examples in one block
29
- # Include links to entity description
30
- "entities": directives.flag,
31
- # Group endpoints by tags when passed. By default, no grouping is
32
- # applied and endpoints are rendered in the order they met in spec.
33
- "group": directives.flag,
34
- # Markup format to render OpenAPI descriptions.
35
- "format": str,
36
- }
37
-
38
- def __init__(self, state, options):
39
- self._state = state
40
- self._options = options
41
-
42
- def render_restructuredtext_markup(self, spec):
43
- # OpenAPI spec may contain JSON references, common properties, etc.
44
- # Trying to render the spec "As Is" will require to put multiple if-s
45
- # around the code. In order to simplify rendering flow, let's make it
46
- # have only one (expected) schema, i.e. normalize it.
47
- utils.normalize_spec(spec, **self._options)
48
-
49
- # We support both OpenAPI 2.0 (f.k.a. Swagger) and OpenAPI 3.0.0, so
50
- # determine which version we are parsing here.
51
- spec_version = spec.get("openapi", spec.get("swagger", "2.0"))
52
- if spec_version.startswith("2."):
53
- openapihttpdomain = openapi20.openapihttpdomain
54
- elif spec_version.startswith("3."):
55
- openapihttpdomain = openapi30.openapihttpdomain
56
- else:
57
- raise ValueError("Unsupported OpenAPI version (%s)" % spec_version)
58
-
59
- yield from openapihttpdomain(spec, **self._options)
1
+ """Here lies still breathing and only renderer implementation."""
2
+
3
+ from docutils.parsers.rst import directives
4
+
5
+ from . import abc
6
+ from .. import openapi20, openapi30, utils
7
+
8
+
9
+ class HttpdomainOldRenderer(abc.RestructuredTextRenderer):
10
+
11
+ option_spec = {
12
+ # A list of endpoints to be rendered. Endpoints must be whitespace
13
+ # delimited.
14
+ "paths": lambda s: s.split(),
15
+ # Regular expression patterns to includes/excludes endpoints to/from
16
+ # rendering. Similar to paths, the patterns must be whitespace
17
+ # delimited.
18
+ "include": lambda s: s.split(),
19
+ "exclude": lambda s: s.split(),
20
+ # Endpoints to be included based on HTTP method names.
21
+ "methods": lambda s: s.split(),
22
+ # Render the request body structure when passed.
23
+ "request": directives.flag,
24
+ # Render request/response examples when passed.
25
+ "examples": directives.flag, # render examples when passed
26
+ # Render request/response examples in one block or inline with the response codes.
27
+ "contextpath": directives.flag, # use the server path as prefix in service URL
28
+ "group_examples": directives.flag, # render examples in one block
29
+ # Include links to entity description
30
+ "entities": directives.flag,
31
+ # Group endpoints by tags when passed. By default, no grouping is
32
+ # applied and endpoints are rendered in the order they met in spec.
33
+ "group": directives.flag,
34
+ # Markup format to render OpenAPI descriptions.
35
+ "format": str,
36
+ }
37
+
38
+ def __init__(self, state, options):
39
+ self._state = state
40
+ self._options = options
41
+
42
+ def render_restructuredtext_markup(self, spec):
43
+ # OpenAPI spec may contain JSON references, common properties, etc.
44
+ # Trying to render the spec "As Is" will require to put multiple if-s
45
+ # around the code. In order to simplify rendering flow, let's make it
46
+ # have only one (expected) schema, i.e. normalize it.
47
+ utils.normalize_spec(spec, **self._options)
48
+
49
+ # We support both OpenAPI 2.0 (f.k.a. Swagger) and OpenAPI 3.0.0, so
50
+ # determine which version we are parsing here.
51
+ spec_version = spec.get("openapi", spec.get("swagger", "2.0"))
52
+ if spec_version.startswith("2."):
53
+ openapihttpdomain = openapi20.openapihttpdomain
54
+ elif spec_version.startswith("3."):
55
+ openapihttpdomain = openapi30.openapihttpdomain
56
+ else:
57
+ raise ValueError("Unsupported OpenAPI version (%s)" % spec_version)
58
+
59
+ yield from openapihttpdomain(spec, **self._options)