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.
Files changed (26) hide show
  1. jentic/apitools/openapi/datamodels/low/context.py +21 -0
  2. jentic/apitools/openapi/datamodels/low/extractors.py +126 -0
  3. jentic/apitools/openapi/datamodels/low/fields.py +45 -0
  4. jentic/apitools/openapi/datamodels/low/model_builder.py +113 -0
  5. jentic/apitools/openapi/datamodels/low/py.typed +0 -0
  6. jentic/apitools/openapi/datamodels/low/sources.py +89 -0
  7. jentic/apitools/openapi/datamodels/low/v30/__init__.py +0 -28
  8. jentic/apitools/openapi/datamodels/low/v30/discriminator.py +53 -78
  9. jentic/apitools/openapi/datamodels/low/v30/external_documentation.py +47 -61
  10. jentic/apitools/openapi/datamodels/low/v30/oauth_flow.py +54 -123
  11. jentic/apitools/openapi/datamodels/low/v30/oauth_flows.py +102 -151
  12. jentic/apitools/openapi/datamodels/low/v30/reference.py +43 -44
  13. jentic/apitools/openapi/datamodels/low/v30/schema.py +316 -607
  14. jentic/apitools/openapi/datamodels/low/v30/security_requirement.py +82 -72
  15. jentic/apitools/openapi/datamodels/low/v30/security_scheme.py +94 -286
  16. jentic/apitools/openapi/datamodels/low/v30/tag.py +88 -119
  17. jentic/apitools/openapi/datamodels/low/v30/xml.py +46 -120
  18. jentic_openapi_datamodels-1.0.0a13.dist-info/METADATA +211 -0
  19. jentic_openapi_datamodels-1.0.0a13.dist-info/RECORD +23 -0
  20. jentic/apitools/openapi/datamodels/low/v30/specification_object.py +0 -217
  21. jentic_openapi_datamodels-1.0.0a11.dist-info/METADATA +0 -52
  22. jentic_openapi_datamodels-1.0.0a11.dist-info/RECORD +0 -18
  23. /jentic/apitools/openapi/datamodels/low/{v30/py.typed → __init__.py} +0 -0
  24. {jentic_openapi_datamodels-1.0.0a11.dist-info → jentic_openapi_datamodels-1.0.0a13.dist-info}/WHEEL +0 -0
  25. {jentic_openapi_datamodels-1.0.0a11.dist-info → jentic_openapi_datamodels-1.0.0a13.dist-info}/licenses/LICENSE +0 -0
  26. {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
- A simple object to allow referencing other components in the OpenAPI document.
5
- """
3
+ from ruamel import yaml
6
4
 
7
- from jentic.apitools.openapi.datamodels.low.v30.specification_object import SpecificationObject
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
- class Reference(SpecificationObject):
18
+ @dataclass(frozen=True, slots=True)
19
+ class Reference:
14
20
  """
15
- Represents a Reference Object from OpenAPI 3.0.4.
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
- IMPORTANT: Reference Objects in OpenAPI 3.0.x do NOT support specification extensions.
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
- Example:
23
- >>> # Internal reference
24
- >>> ref = Reference({"$ref": "#/components/schemas/Pet"})
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
- _supports_extensions: bool = False
37
- _fixed_fields: frozenset[str] = frozenset({"$ref"})
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
- Maps to the "$ref" field in OpenAPI.
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
- Can be:
47
- - Internal: "#/components/schemas/Pet"
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
- REQUIRED field.
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
- Returns:
54
- Reference string or None if not present
55
- """
56
- return self.get("$ref")
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
- @ref.setter
59
- def ref(self, value: str | None) -> None:
60
- """Set the reference string."""
61
- if value is None:
62
- self.pop("$ref", None)
63
- else:
64
- self["$ref"] = value
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)