jentic-openapi-datamodels 1.0.0a11__py3-none-any.whl → 1.0.0a13__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.
- jentic/apitools/openapi/datamodels/low/context.py +21 -0
- jentic/apitools/openapi/datamodels/low/extractors.py +126 -0
- jentic/apitools/openapi/datamodels/low/fields.py +45 -0
- jentic/apitools/openapi/datamodels/low/model_builder.py +113 -0
- jentic/apitools/openapi/datamodels/low/py.typed +0 -0
- jentic/apitools/openapi/datamodels/low/sources.py +89 -0
- jentic/apitools/openapi/datamodels/low/v30/__init__.py +0 -28
- jentic/apitools/openapi/datamodels/low/v30/discriminator.py +53 -78
- jentic/apitools/openapi/datamodels/low/v30/external_documentation.py +47 -61
- jentic/apitools/openapi/datamodels/low/v30/oauth_flow.py +54 -123
- jentic/apitools/openapi/datamodels/low/v30/oauth_flows.py +102 -151
- jentic/apitools/openapi/datamodels/low/v30/reference.py +43 -44
- jentic/apitools/openapi/datamodels/low/v30/schema.py +316 -607
- jentic/apitools/openapi/datamodels/low/v30/security_requirement.py +82 -72
- jentic/apitools/openapi/datamodels/low/v30/security_scheme.py +94 -286
- jentic/apitools/openapi/datamodels/low/v30/tag.py +88 -119
- jentic/apitools/openapi/datamodels/low/v30/xml.py +46 -120
- jentic_openapi_datamodels-1.0.0a13.dist-info/METADATA +211 -0
- jentic_openapi_datamodels-1.0.0a13.dist-info/RECORD +23 -0
- jentic/apitools/openapi/datamodels/low/v30/specification_object.py +0 -217
- jentic_openapi_datamodels-1.0.0a11.dist-info/METADATA +0 -52
- jentic_openapi_datamodels-1.0.0a11.dist-info/RECORD +0 -18
- /jentic/apitools/openapi/datamodels/low/{v30/py.typed → __init__.py} +0 -0
- {jentic_openapi_datamodels-1.0.0a11.dist-info → jentic_openapi_datamodels-1.0.0a13.dist-info}/WHEEL +0 -0
- {jentic_openapi_datamodels-1.0.0a11.dist-info → jentic_openapi_datamodels-1.0.0a13.dist-info}/licenses/LICENSE +0 -0
- {jentic_openapi_datamodels-1.0.0a11.dist-info → jentic_openapi_datamodels-1.0.0a13.dist-info}/licenses/NOTICE +0 -0
|
@@ -1,64 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
OpenAPI 3.0.4 Reference Object model.
|
|
1
|
+
from dataclasses import dataclass
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
"""
|
|
3
|
+
from ruamel import yaml
|
|
6
4
|
|
|
7
|
-
from jentic.apitools.openapi.datamodels.low.
|
|
5
|
+
from jentic.apitools.openapi.datamodels.low.context import Context
|
|
6
|
+
from jentic.apitools.openapi.datamodels.low.fields import fixed_field
|
|
7
|
+
from jentic.apitools.openapi.datamodels.low.model_builder import build_model
|
|
8
|
+
from jentic.apitools.openapi.datamodels.low.sources import (
|
|
9
|
+
FieldSource,
|
|
10
|
+
ValueSource,
|
|
11
|
+
YAMLInvalidValue,
|
|
12
|
+
)
|
|
8
13
|
|
|
9
14
|
|
|
10
|
-
__all__ = ["Reference"]
|
|
15
|
+
__all__ = ["Reference", "build"]
|
|
11
16
|
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
@dataclass(frozen=True, slots=True)
|
|
19
|
+
class Reference:
|
|
14
20
|
"""
|
|
15
|
-
|
|
21
|
+
Reference Object representation for OpenAPI 3.0.
|
|
16
22
|
|
|
17
23
|
A simple object to allow referencing other components in the OpenAPI document,
|
|
18
24
|
internally and externally.
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
Note: In OpenAPI 3.0, Reference Objects only have the $ref field.
|
|
27
|
+
Summary, description, and extensions were added in OpenAPI 3.1.
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
>>> ref.ref
|
|
26
|
-
'#/components/schemas/Pet'
|
|
27
|
-
>>> ref["$ref"]
|
|
28
|
-
'#/components/schemas/Pet'
|
|
29
|
-
|
|
30
|
-
>>> # External reference
|
|
31
|
-
>>> ref = Reference({"$ref": "https://example.com/schemas/Pet.json"})
|
|
32
|
-
>>> ref.ref
|
|
33
|
-
'https://example.com/schemas/Pet.json'
|
|
29
|
+
Attributes:
|
|
30
|
+
root_node: The top-level node representing the entire Reference object in the original source file
|
|
31
|
+
ref: REQUIRED. The reference string. Must be in the format of a URI.
|
|
34
32
|
"""
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
root_node: yaml.Node
|
|
35
|
+
ref: FieldSource[str] | None = fixed_field(metadata={"yaml_name": "$ref"})
|
|
38
36
|
|
|
39
|
-
@property
|
|
40
|
-
def ref(self) -> str | None:
|
|
41
|
-
"""
|
|
42
|
-
The reference string identifying the location of the referenced object.
|
|
43
37
|
|
|
44
|
-
|
|
38
|
+
def build(
|
|
39
|
+
root: yaml.Node, context: Context | None = None
|
|
40
|
+
) -> Reference | ValueSource[YAMLInvalidValue]:
|
|
41
|
+
"""
|
|
42
|
+
Build a Reference object from a YAML node.
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- External URL: "https://example.com/schemas/Pet.json"
|
|
49
|
-
- Relative file: "./schemas/Pet.yaml#/Pet"
|
|
44
|
+
Preserves all source data as-is, regardless of type. This is a low-level/plumbing
|
|
45
|
+
model that provides complete source fidelity for inspection and validation.
|
|
50
46
|
|
|
51
|
-
|
|
47
|
+
Args:
|
|
48
|
+
root: The YAML node to parse (should be a MappingNode)
|
|
49
|
+
context: Optional parsing context. If None, a default context will be created.
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
Returns:
|
|
52
|
+
A Reference object if the node is valid, or a ValueSource containing
|
|
53
|
+
the invalid data if the root is not a MappingNode (preserving the invalid data
|
|
54
|
+
and its source location for validation).
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
Example:
|
|
57
|
+
from ruamel.yaml import YAML
|
|
58
|
+
yaml = YAML()
|
|
59
|
+
root = yaml.compose("$ref: '#/components/schemas/Pet'")
|
|
60
|
+
reference = build(root)
|
|
61
|
+
assert reference.ref.value == '#/components/schemas/Pet'
|
|
62
|
+
"""
|
|
63
|
+
return build_model(root, Reference, context=context)
|