robotframework-openapitools 1.0.0b4__py3-none-any.whl → 1.0.1__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.
- OpenApiDriver/__init__.py +1 -0
- OpenApiDriver/openapi_executors.py +32 -4
- OpenApiDriver/openapidriver.libspec +183 -80
- OpenApiDriver/openapidriver.py +8 -279
- OpenApiLibCore/__init__.py +26 -0
- OpenApiLibCore/data_generation/__init__.py +0 -0
- OpenApiLibCore/data_generation/body_data_generation.py +4 -4
- OpenApiLibCore/data_generation/data_generation_core.py +18 -45
- OpenApiLibCore/data_invalidation.py +1 -5
- OpenApiLibCore/dto_base.py +31 -22
- OpenApiLibCore/dto_utils.py +31 -3
- OpenApiLibCore/localized_faker.py +0 -0
- OpenApiLibCore/models.py +26 -18
- OpenApiLibCore/openapi_libcore.libspec +229 -121
- OpenApiLibCore/openapi_libcore.py +45 -274
- OpenApiLibCore/parameter_utils.py +3 -3
- OpenApiLibCore/path_functions.py +5 -6
- OpenApiLibCore/path_invalidation.py +5 -7
- OpenApiLibCore/protocols.py +6 -0
- OpenApiLibCore/request_data.py +0 -0
- OpenApiLibCore/resource_relations.py +4 -2
- OpenApiLibCore/validation.py +4 -9
- OpenApiLibCore/value_utils.py +1 -1
- openapi_libgen/__init__.py +3 -0
- openapi_libgen/generator.py +2 -4
- openapi_libgen/parsing_utils.py +9 -5
- openapi_libgen/spec_parser.py +4 -4
- openapitools_docs/__init__.py +0 -0
- openapitools_docs/docstrings.py +891 -0
- openapitools_docs/documentation_generator.py +35 -0
- openapitools_docs/templates/documentation.jinja +209 -0
- {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.1.dist-info}/METADATA +16 -98
- robotframework_openapitools-1.0.1.dist-info/RECORD +44 -0
- robotframework_openapitools-1.0.0b4.dist-info/RECORD +0 -40
- {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.1.dist-info}/LICENSE +0 -0
- {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.1.dist-info}/WHEEL +0 -0
- {robotframework_openapitools-1.0.0b4.dist-info → robotframework_openapitools-1.0.1.dist-info}/entry_points.txt +0 -0
OpenApiLibCore/dto_utils.py
CHANGED
@@ -7,7 +7,11 @@ from typing import Any, Callable, Type, overload
|
|
7
7
|
from robot.api import logger
|
8
8
|
|
9
9
|
from OpenApiLibCore.dto_base import Dto
|
10
|
-
from OpenApiLibCore.protocols import
|
10
|
+
from OpenApiLibCore.protocols import (
|
11
|
+
GetDtoClassType,
|
12
|
+
GetIdPropertyNameType,
|
13
|
+
GetPathDtoClassType,
|
14
|
+
)
|
11
15
|
|
12
16
|
|
13
17
|
@dataclass
|
@@ -49,6 +53,30 @@ class GetDtoClass:
|
|
49
53
|
return DefaultDto
|
50
54
|
|
51
55
|
|
56
|
+
def get_path_dto_class(mappings_module_name: str) -> GetPathDtoClassType:
|
57
|
+
return GetPathDtoClass(mappings_module_name=mappings_module_name)
|
58
|
+
|
59
|
+
|
60
|
+
class GetPathDtoClass:
|
61
|
+
"""Callable class to return Dtos from user-implemented mappings file."""
|
62
|
+
|
63
|
+
def __init__(self, mappings_module_name: str) -> None:
|
64
|
+
try:
|
65
|
+
mappings_module = import_module(mappings_module_name)
|
66
|
+
self.dto_mapping: dict[str, Type[Dto]] = mappings_module.PATH_MAPPING
|
67
|
+
except (ImportError, AttributeError, ValueError) as exception:
|
68
|
+
if mappings_module_name != "no mapping":
|
69
|
+
logger.error(f"PATH_MAPPING was not imported: {exception}")
|
70
|
+
self.dto_mapping = {}
|
71
|
+
|
72
|
+
def __call__(self, path: str) -> Type[Dto]:
|
73
|
+
try:
|
74
|
+
return self.dto_mapping[path]
|
75
|
+
except KeyError:
|
76
|
+
logger.debug(f"No Dto mapping for {path}.")
|
77
|
+
return DefaultDto
|
78
|
+
|
79
|
+
|
52
80
|
def get_id_property_name(mappings_module_name: str) -> GetIdPropertyNameType:
|
53
81
|
return GetIdPropertyName(mappings_module_name=mappings_module_name)
|
54
82
|
|
@@ -86,11 +114,11 @@ class GetIdPropertyName:
|
|
86
114
|
|
87
115
|
|
88
116
|
@overload
|
89
|
-
def dummy_transformer(valid_id: str) -> str: ...
|
117
|
+
def dummy_transformer(valid_id: str) -> str: ... # pragma: no cover
|
90
118
|
|
91
119
|
|
92
120
|
@overload
|
93
|
-
def dummy_transformer(valid_id: int) -> int: ...
|
121
|
+
def dummy_transformer(valid_id: int) -> int: ... # pragma: no cover
|
94
122
|
|
95
123
|
|
96
124
|
def dummy_transformer(valid_id: Any) -> Any:
|
File without changes
|
OpenApiLibCore/models.py
CHANGED
@@ -234,7 +234,7 @@ class IntegerSchema(SchemaBase[int], frozen=True):
|
|
234
234
|
|
235
235
|
return randint(self._min_value, self._max_value)
|
236
236
|
|
237
|
-
def get_values_out_of_bounds(self, current_value: int) -> list[int]:
|
237
|
+
def get_values_out_of_bounds(self, current_value: int) -> list[int]: # pylint: disable=unused-argument
|
238
238
|
invalid_values: list[int] = []
|
239
239
|
|
240
240
|
if self._min_value > self._min_int:
|
@@ -333,7 +333,7 @@ class NumberSchema(SchemaBase[float], frozen=True):
|
|
333
333
|
|
334
334
|
return uniform(self._min_value, self._max_value)
|
335
335
|
|
336
|
-
def get_values_out_of_bounds(self, current_value: float) -> list[float]:
|
336
|
+
def get_values_out_of_bounds(self, current_value: float) -> list[float]: # pylint: disable=unused-argument
|
337
337
|
invalid_values: list[float] = []
|
338
338
|
|
339
339
|
if self._min_value > self._min_float:
|
@@ -643,21 +643,33 @@ class RequestBodyObject(BaseModel):
|
|
643
643
|
required: bool = False
|
644
644
|
description: str = ""
|
645
645
|
|
646
|
-
@
|
646
|
+
@cached_property
|
647
647
|
def schema_(self) -> SchemaObjectTypes | None:
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
648
|
+
if not self.mime_type:
|
649
|
+
return None
|
650
|
+
|
651
|
+
if len(self._json_schemas) > 1:
|
652
|
+
logger.info(
|
653
|
+
f"Multiple JSON media types defined for requestBody, "
|
654
|
+
f"using the first candidate from {self.content}"
|
655
|
+
)
|
656
|
+
return self._json_schemas[self.mime_type]
|
657
|
+
|
658
|
+
@cached_property
|
659
|
+
def mime_type(self) -> str | None:
|
660
|
+
if not self._json_schemas:
|
656
661
|
return None
|
657
662
|
|
658
|
-
|
659
|
-
|
660
|
-
|
663
|
+
return next(iter(self._json_schemas))
|
664
|
+
|
665
|
+
@cached_property
|
666
|
+
def _json_schemas(self) -> dict[str, SchemaObjectTypes]:
|
667
|
+
json_schemas = {
|
668
|
+
mime_type: media_type.schema_
|
669
|
+
for mime_type, media_type in self.content.items()
|
670
|
+
if "json" in mime_type and media_type.schema_ is not None
|
671
|
+
}
|
672
|
+
return json_schemas
|
661
673
|
|
662
674
|
|
663
675
|
class HeaderObject(BaseModel): ...
|
@@ -673,10 +685,6 @@ class ResponseObject(BaseModel):
|
|
673
685
|
links: dict[str, LinkObject] = {}
|
674
686
|
|
675
687
|
|
676
|
-
# class ComponentsObject(BaseModel):
|
677
|
-
# schemas: dict[str, SchemaObjectTypes]
|
678
|
-
|
679
|
-
|
680
688
|
class OperationObject(BaseModel):
|
681
689
|
operationId: str | None = None
|
682
690
|
summary: str = ""
|