robotframework-openapitools 1.0.0b4__tar.gz → 1.0.1__tar.gz
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.
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/PKG-INFO +16 -98
- robotframework_openapitools-1.0.1/docs/README.md +15 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/pyproject.toml +10 -2
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiDriver/__init__.py +1 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiDriver/openapi_executors.py +32 -4
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiDriver/openapidriver.libspec +183 -80
- robotframework_openapitools-1.0.1/src/OpenApiDriver/openapidriver.py +98 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/__init__.py +26 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/data_generation/__init__.py +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/data_generation/body_data_generation.py +4 -4
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/data_generation/data_generation_core.py +18 -45
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/data_invalidation.py +1 -5
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/dto_base.py +31 -22
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/dto_utils.py +31 -3
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/localized_faker.py +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/models.py +26 -18
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/openapi_libcore.libspec +229 -121
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/openapi_libcore.py +45 -274
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/parameter_utils.py +3 -3
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/path_functions.py +5 -6
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/path_invalidation.py +5 -7
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/protocols.py +6 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/request_data.py +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/resource_relations.py +4 -2
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/validation.py +4 -9
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/value_utils.py +1 -1
- robotframework_openapitools-1.0.1/src/openapi_libgen/__init__.py +3 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/openapi_libgen/generator.py +2 -4
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/openapi_libgen/parsing_utils.py +9 -5
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/openapi_libgen/spec_parser.py +4 -4
- robotframework_openapitools-1.0.1/src/openapitools_docs/docstrings.py +891 -0
- robotframework_openapitools-1.0.1/src/openapitools_docs/documentation_generator.py +35 -0
- robotframework_openapitools-1.0.1/src/openapitools_docs/templates/documentation.jinja +209 -0
- robotframework_openapitools-1.0.0b4/docs/README.md +0 -102
- robotframework_openapitools-1.0.0b4/src/OpenApiDriver/openapidriver.py +0 -369
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/LICENSE +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiDriver/openapi_reader.py +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiDriver/py.typed +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/annotations.py +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/oas_cache.py +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/OpenApiLibCore/py.typed +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/openapi_libgen/command_line.py +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/openapi_libgen/templates/__init__.jinja +0 -0
- {robotframework_openapitools-1.0.0b4 → robotframework_openapitools-1.0.1}/src/openapi_libgen/templates/library.jinja +0 -0
- {robotframework_openapitools-1.0.0b4/src/openapi_libgen → robotframework_openapitools-1.0.1/src/openapitools_docs}/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: robotframework-openapitools
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.1
|
4
4
|
Summary: A set of Robot Framework libraries to test APIs for which the OAS is available.
|
5
5
|
License: Apache License
|
6
6
|
Version 2.0, January 2004
|
@@ -210,6 +210,9 @@ Maintainer-email: r.a.mackaij@gmail.com
|
|
210
210
|
Requires-Python: >=3.10, <4
|
211
211
|
Classifier: Programming Language :: Python :: 3
|
212
212
|
Classifier: Programming Language :: Python :: 3.10
|
213
|
+
Classifier: Programming Language :: Python :: 3.11
|
214
|
+
Classifier: Programming Language :: Python :: 3.12
|
215
|
+
Classifier: Programming Language :: Python :: 3.13
|
213
216
|
Classifier: License :: OSI Approved :: Apache Software License
|
214
217
|
Classifier: Operating System :: OS Independent
|
215
218
|
Classifier: Topic :: Software Development :: Testing
|
@@ -226,109 +229,24 @@ Requires-Dist: rich_click (>=1.7.0)
|
|
226
229
|
Requires-Dist: robotframework (>=6.0.0,!=7.0.0)
|
227
230
|
Requires-Dist: robotframework-datadriver (>=1.10.0)
|
228
231
|
Requires-Dist: rstr (>=3.2.0)
|
232
|
+
Project-URL: Documentation, https://marketsquare.github.io/robotframework-openapitools
|
229
233
|
Project-URL: Homepage, https://github.com/MarketSquare/robotframework-openapitools
|
234
|
+
Project-URL: Repository, https://github.com/MarketSquare/robotframework-openapitools.git
|
230
235
|
Description-Content-Type: text/markdown
|
231
236
|
|
232
|
-
|
233
|
-
|
234
|
-
OpenApiTools is a set of libraries centered around the OpenAPI Specification:
|
235
|
-
|
236
|
-
- [OpenApiDriver](./driver.md)
|
237
|
-
- [OpenApiLibCore](./libcore.md)
|
238
|
-
|
239
|
-
|
240
|
-
## New in OpenApiTools v1.0.0
|
241
|
-
|
242
|
-
Inspired by the work Bartlomiej and Mateusz did on #roboswag, I've created a CLI tool that generates a fully functional Robot Framework (Python) library that builds on OpenApiLibCore for automatic request data generation and request execution.
|
243
|
-
|
244
|
-
### So how does it work?
|
245
|
-
After installing / updating to the v1.0.0 beta (`pip install robotframework-openapitools==1.0.0b3`) , there's a new CLI command available in your (virtual) environment: `generate-library`. You'll have to provide a path to the openapi spec (json or yaml, can be a url or path to the file), provide a path to where to generate the library and (optionally) a name for the library:
|
246
|
-
|
247
|
-
```
|
248
|
-
$ generate-library
|
249
|
-
Please provide a source for the generation:
|
250
|
-
$ http://127.0.0.1:8000/openapi.json
|
251
|
-
Please provide a path to where the library will be generated:
|
252
|
-
$ ./generated
|
253
|
-
Please provide a name for the library [default: FastAPI]:
|
254
|
-
$ My Generated Library
|
255
|
-
generated/MyGeneratedLibrary/__init__.py created
|
256
|
-
generated/MyGeneratedLibrary/my_generated_library.py created
|
257
|
-
```
|
258
|
-
|
259
|
-
> Note: there's currently 2 environment variables that are taken into account by the generator; USE_SUMMARY_AS_KEYWORD_NAME can result in nicer keyword names (but: uniqueness is not guaranteed, so you might need to rename some of the generated keywords manually) and EXPAND_BODY_ARGUMENTS is what a recent poll in #api-testing was about.
|
260
|
-
|
261
|
-
If the location where the library is located is in your Python search path, you'll be able to use it like a regular Robot Framework library (in fact, it's a drop-in replacement for OpenApiLibCore):
|
237
|
+
[](https://github.com/MarketSquare/robotframework-openapitools/actions/workflows/on-push.yml)
|
238
|
+

|
262
239
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
... origin=${ORIGIN}
|
268
|
-
... base_path=${EMPTY}
|
269
|
-
... mappings_path=${ROOT}/tests/user_implemented/custom_user_mappings.py
|
270
|
-
Variables ${ROOT}/tests/variables.py
|
240
|
+

|
241
|
+

|
242
|
+

|
243
|
+

|
271
244
|
|
245
|
+
# OpenApiTools for Robot Framework
|
272
246
|
|
273
|
-
|
274
|
-
${ORIGIN}= http://localhost:8000
|
275
|
-
|
276
|
-
|
277
|
-
*** Test Cases ***
|
278
|
-
Test Generated Keywords: Get Employees
|
279
|
-
${response}= Get Employees
|
280
|
-
Should Be Equal As Integers ${response.status_code} 200
|
281
|
-
|
282
|
-
Test Generated Keywords: Post Employee
|
283
|
-
VAR &{body} name=Robin the Robot
|
284
|
-
${response}= Post Employee body=${body}
|
285
|
-
# ${response}= Post Employee name=Robin the Robot
|
286
|
-
Should Be Equal As Integers ${response.status_code} 201
|
287
|
-
Should Be Equal ${response.json()}[name] Robin the Robot
|
288
|
-
|
289
|
-
Test Generated Keywords: Get Employee
|
290
|
-
${response}= Get Employee
|
291
|
-
Should Be Equal As Integers ${response.status_code} 200
|
292
|
-
|
293
|
-
Test Generated Keywords: Patch Employee
|
294
|
-
${employee_id}= Get Valid Id For Path path=/employees/{employee_id}
|
295
|
-
VAR &{body} date_of_birth=2021-12-31
|
296
|
-
${response}= Patch Employee employee_id=${employee_id} body=${body}
|
297
|
-
# ${response}= Patch Employee employee_id=${employee_id} date_of_birth=2021-12-31
|
298
|
-
Should Be Equal As Integers ${response.status_code} 403
|
299
|
-
|
300
|
-
Test Generated Keywords: Post WageGroup
|
301
|
-
VAR &{body} hourly_rate=99.99
|
302
|
-
${response}= Post Wagegroup body=${body}
|
303
|
-
# ${response}= Post Wagegroup hourly_rate=99.99
|
304
|
-
Should Be Equal As Integers ${response.status_code} 201
|
305
|
-
Should Be Equal As Numbers ${response.json()}[hourly-rate] 99.99
|
306
|
-
|
307
|
-
Test Generated Keywords: Get Energy Label
|
308
|
-
${response}= Get Energy Label
|
309
|
-
... zipcode=1111AA
|
310
|
-
... home_number=10
|
311
|
-
... extension=too long to be acceptable
|
312
|
-
... validate_against_schema=${FALSE}
|
313
|
-
Should Be Equal As Integers ${response.status_code} 422
|
314
|
-
|
315
|
-
VAR @{omit} extension
|
316
|
-
${response}= Get Energy Label
|
317
|
-
... zipcode=1111AA
|
318
|
-
... home_number=10
|
319
|
-
... extension=too long to be acceptable
|
320
|
-
... omit_parameters=${omit}
|
321
|
-
Should Be Equal As Integers ${response.status_code} 200
|
322
|
-
```
|
323
|
-
|
324
|
-
### Contributions and feedback
|
247
|
+
If you're testing an API for which an OpenAPI specification is available (if you have a Swagger UI available, you are), OpenApiTools is for you!
|
325
248
|
|
326
|
-
|
327
|
-
Things I'd like to address / improve before an official release:
|
328
|
-
- parameters with union types (e.g. int or float) are currently annotated as Any.
|
329
|
-
- support for lists / arrays is limited (i.e. not supported as body)
|
330
|
-
- objects / dicts are currently only typed as dict; I'm looking into TypedDict annotation for better auto-complete / auto-conversion
|
331
|
-
- a documentation rework
|
249
|
+
To read everything about it, see the [html documentation](https://marketsquare.github.io/robotframework-openapitools).
|
332
250
|
|
333
|
-
|
251
|
+
The latest release notes can be found [here](./release_notes/1.0.1.md).
|
334
252
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
[](https://github.com/MarketSquare/robotframework-openapitools/actions/workflows/on-push.yml)
|
2
|
+

|
3
|
+
|
4
|
+

|
5
|
+

|
6
|
+

|
7
|
+

|
8
|
+
|
9
|
+
# OpenApiTools for Robot Framework
|
10
|
+
|
11
|
+
If you're testing an API for which an OpenAPI specification is available (if you have a Swagger UI available, you are), OpenApiTools is for you!
|
12
|
+
|
13
|
+
To read everything about it, see the [html documentation](https://marketsquare.github.io/robotframework-openapitools).
|
14
|
+
|
15
|
+
The latest release notes can be found [here](./release_notes/1.0.1.md).
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name="robotframework-openapitools"
|
3
|
-
version = "1.0.
|
3
|
+
version = "1.0.1"
|
4
4
|
description = "A set of Robot Framework libraries to test APIs for which the OAS is available."
|
5
5
|
authors = [
|
6
6
|
{name = "Robin Mackaij", email = "r.a.mackaij@gmail.com"},
|
@@ -13,6 +13,9 @@ license = { file = "LICENSE"}
|
|
13
13
|
classifiers = [
|
14
14
|
"Programming Language :: Python :: 3",
|
15
15
|
"Programming Language :: Python :: 3.10",
|
16
|
+
"Programming Language :: Python :: 3.11",
|
17
|
+
"Programming Language :: Python :: 3.12",
|
18
|
+
"Programming Language :: Python :: 3.13",
|
16
19
|
"License :: OSI Approved :: Apache Software License",
|
17
20
|
"Operating System :: OS Independent",
|
18
21
|
"Topic :: Software Development :: Testing",
|
@@ -42,6 +45,7 @@ dev = [
|
|
42
45
|
"fastapi >= 0.109.0",
|
43
46
|
"coverage[toml] >= 7.2.0",
|
44
47
|
"robotcode-runner >= 1.0.3",
|
48
|
+
"genbadge[coverage] >= 1.1.2",
|
45
49
|
]
|
46
50
|
type-checking = [
|
47
51
|
"mypy >= 1.14.1",
|
@@ -58,7 +62,9 @@ lint-and-format = [
|
|
58
62
|
]
|
59
63
|
|
60
64
|
[project.urls]
|
61
|
-
|
65
|
+
Homepage = "https://github.com/MarketSquare/robotframework-openapitools"
|
66
|
+
Documentation = "https://marketsquare.github.io/robotframework-openapitools"
|
67
|
+
Repository = "https://github.com/MarketSquare/robotframework-openapitools.git"
|
62
68
|
|
63
69
|
[project.scripts]
|
64
70
|
generate-library = 'openapi_libgen.command_line:main'
|
@@ -69,6 +75,7 @@ packages = [
|
|
69
75
|
{include = "OpenApiDriver", from = "src"},
|
70
76
|
{include = "OpenApiLibCore", from = "src"},
|
71
77
|
{include = "openapi_libgen", from = "src"},
|
78
|
+
{include = "openapitools_docs", from = "src"}
|
72
79
|
]
|
73
80
|
include = ["*.libspec", "*.jinja"]
|
74
81
|
|
@@ -79,6 +86,7 @@ uvicorn = ">=0.27.0"
|
|
79
86
|
fastapi = ">=0.109.0"
|
80
87
|
coverage = {version = ">=7.2.0", extras = ["toml"]}
|
81
88
|
robotcode-runner = ">=1.0.3"
|
89
|
+
genbadge = {version = ">=1.1.2", extras = ["coverage"]}
|
82
90
|
|
83
91
|
[tool.poetry.group.lint-and-format.dependencies]
|
84
92
|
ruff = ">=0.9.0"
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
from collections.abc import Mapping, MutableMapping
|
4
4
|
from http import HTTPStatus
|
5
|
+
from os import getenv
|
5
6
|
from pathlib import Path
|
6
7
|
from random import choice
|
7
8
|
from types import MappingProxyType
|
@@ -14,13 +15,29 @@ from robot.api.deco import keyword, library
|
|
14
15
|
from robot.api.exceptions import SkipExecution
|
15
16
|
from robot.libraries.BuiltIn import BuiltIn
|
16
17
|
|
17
|
-
from OpenApiLibCore import
|
18
|
+
from OpenApiLibCore import (
|
19
|
+
KEYWORD_NAMES as LIBCORE_KEYWORD_NAMES,
|
20
|
+
)
|
21
|
+
from OpenApiLibCore import (
|
22
|
+
OpenApiLibCore,
|
23
|
+
RequestData,
|
24
|
+
RequestValues,
|
25
|
+
ValidationLevel,
|
26
|
+
)
|
18
27
|
from OpenApiLibCore.annotations import JSON
|
19
28
|
|
20
29
|
run_keyword = BuiltIn().run_keyword
|
21
30
|
default_str_mapping: Mapping[str, str] = MappingProxyType({})
|
22
31
|
|
23
32
|
|
33
|
+
KEYWORD_NAMES = [
|
34
|
+
"test_unauthorized",
|
35
|
+
"test_forbidden",
|
36
|
+
"test_invalid_url",
|
37
|
+
"test_endpoint",
|
38
|
+
]
|
39
|
+
|
40
|
+
|
24
41
|
@library(scope="SUITE", doc_format="ROBOT")
|
25
42
|
class OpenApiExecutors(OpenApiLibCore):
|
26
43
|
"""Main class providing the keywords and core logic to perform endpoint validations."""
|
@@ -133,11 +150,15 @@ class OpenApiExecutors(OpenApiLibCore):
|
|
133
150
|
"""
|
134
151
|
valid_url: str = run_keyword("get_valid_url", path)
|
135
152
|
|
136
|
-
|
137
|
-
url
|
153
|
+
try:
|
154
|
+
url = run_keyword(
|
138
155
|
"get_invalidated_url", valid_url, path, expected_status_code
|
139
156
|
)
|
140
|
-
|
157
|
+
except Exception as exception:
|
158
|
+
message = getattr(exception, "message", "")
|
159
|
+
if not message.startswith("ValueError"):
|
160
|
+
raise exception # pragma: no cover
|
161
|
+
|
141
162
|
raise SkipExecution(
|
142
163
|
f"Path {path} does not contain resource references that "
|
143
164
|
f"can be invalidated."
|
@@ -301,3 +322,10 @@ class OpenApiExecutors(OpenApiLibCore):
|
|
301
322
|
if response.ok:
|
302
323
|
original_data = response.json()
|
303
324
|
return original_data
|
325
|
+
|
326
|
+
@staticmethod
|
327
|
+
def get_keyword_names() -> list[str]:
|
328
|
+
"""Curated keywords for libdoc and libspec."""
|
329
|
+
if getenv("HIDE_INHERITED_KEYWORDS") == "true":
|
330
|
+
return KEYWORD_NAMES
|
331
|
+
return KEYWORD_NAMES + LIBCORE_KEYWORD_NAMES
|
@@ -1,11 +1,13 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<keywordspec name="OpenApiDriver" type="LIBRARY" format="HTML" scope="SUITE" generated="2025-
|
3
|
-
<version>1.0.
|
4
|
-
<doc
|
2
|
+
<keywordspec name="OpenApiDriver" type="LIBRARY" format="HTML" scope="SUITE" generated="2025-09-12T09:00:23+00:00" specversion="6" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapidriver.py" lineno="24">
|
3
|
+
<version>1.0.1</version>
|
4
|
+
<doc>The OpenApiDriver library provides the keywords and logic for execution of generated test cases based on an OpenAPI document.
|
5
|
+
|
6
|
+
Visit the <a href="./index.html" target="_blank">OpenApiTools documentation</a> for an introduction.</doc>
|
5
7
|
<tags>
|
6
8
|
</tags>
|
7
9
|
<inits>
|
8
|
-
<init name="__init__" lineno="
|
10
|
+
<init name="__init__" lineno="25">
|
9
11
|
<arguments repr="source: str, origin: str = , base_path: str = , included_paths: Iterable[str] = frozenset(), ignored_paths: Iterable[str] = frozenset(), ignored_responses: Iterable[int] = frozenset(), ignored_testcases: Iterable[tuple[str, str, int]] = frozenset(), response_validation: ValidationLevel = WARN, disable_server_validation: bool = True, mappings_path: str | Path = , invalid_property_default_response: int = 422, default_id_property_name: str = id, faker_locale: str | list[str] = , require_body_for_invalid_url: bool = False, recursion_limit: int = 1, recursion_default: JSON = {}, username: str = , password: str = , security_token: str = , auth: AuthBase | None = None, cert: str | tuple[str, str] = , verify_tls: bool | str = True, extra_headers: Mapping[str, str] = {}, cookies: MutableMapping[str, str] | RequestsCookieJar | None = None, proxies: MutableMapping[str, str] | None = None">
|
10
12
|
<arg kind="POSITIONAL_OR_NAMED" required="true" repr="source: str">
|
11
13
|
<name>source</name>
|
@@ -180,74 +182,150 @@
|
|
180
182
|
<default>None</default>
|
181
183
|
</arg>
|
182
184
|
</arguments>
|
183
|
-
<doc><
|
184
|
-
|
185
|
-
<
|
186
|
-
|
187
|
-
<
|
188
|
-
|
189
|
-
|
190
|
-
<h3>
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
<
|
196
|
-
|
197
|
-
|
198
|
-
<
|
199
|
-
|
200
|
-
|
185
|
+
<doc><h2>Test case generation and execution</h2>
|
186
|
+
|
187
|
+
<h3>included_paths</h3>
|
188
|
+
A list of paths that will be included when generating the test cases.
|
189
|
+
The <code>*</code> character can be used at the end of a partial path to include all paths
|
190
|
+
starting with the partial path (wildcard include).
|
191
|
+
|
192
|
+
<h3>ignored_paths</h3>
|
193
|
+
A list of paths that will be ignored when generating the test cases.
|
194
|
+
The <code>*</code> character can be used at the end of a partial path to ignore all paths
|
195
|
+
starting with the partial path (wildcard ignore).
|
196
|
+
|
197
|
+
<h3>ignored_responses</h3>
|
198
|
+
A list of responses that will be ignored when generating the test cases.
|
199
|
+
|
200
|
+
<h3>ignored_testcases</h3>
|
201
|
+
A list of specific test cases that, if it would be generated, will be ignored.
|
202
|
+
Specific test cases to ignore must be specified as a <code>tuple</code> or
|
203
|
+
<code>list</code> of <code>path</code>, <code>method</code> and <code>response</code>.
|
204
|
+
|
205
|
+
|
206
|
+
<h2>Base parameters</h2>
|
207
|
+
|
208
|
+
<h3>source</h3>
|
209
|
+
An absolute path to an openapi.json or openapi.yaml file or an url to such a file.
|
210
|
+
|
211
|
+
<h3>origin</h3>
|
212
|
+
The server (and port) of the target server. E.g. <code>https://localhost:8000</code>
|
213
|
+
|
214
|
+
<h3>base_path</h3>
|
215
|
+
The routing between <code>origin</code> and the paths as found in the <code>paths</code>
|
216
|
+
section in the openapi document.
|
217
|
+
E.g. <code>/petshop/v2</code>.
|
218
|
+
|
219
|
+
<h2>Test case execution</h2>
|
220
|
+
|
221
|
+
<h3>response_validation</h3>
|
222
|
+
By default, a <code>WARN</code> is logged when the Response received after a Request
|
223
|
+
does not comply with the schema as defined in the OpenAPI document for the given operation.
|
224
|
+
The following values are supported:
|
201
225
|
<ul>
|
202
226
|
<li><code>DISABLED</code>: All Response validation errors will be ignored</li>
|
203
227
|
<li><code>INFO</code>: Any Response validation erros will be logged at <code>INFO</code> level</li>
|
204
228
|
<li><code>WARN</code>: Any Response validation erros will be logged at <code>WARN</code> level</li>
|
205
229
|
<li><code>STRICT</code>: The Test Case will fail on any Response validation errors</li>
|
206
230
|
</ul>
|
207
|
-
|
208
|
-
<
|
209
|
-
<
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
<
|
214
|
-
|
215
|
-
|
216
|
-
<
|
217
|
-
|
218
|
-
<
|
219
|
-
|
220
|
-
|
221
|
-
<h3>
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
<
|
228
|
-
|
229
|
-
|
230
|
-
<
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
<
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
<
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
231
|
+
|
232
|
+
<h3>disable_server_validation</h3>
|
233
|
+
If enabled by setting this parameter to <code class="language-robotframework">${TRUE}</code>,
|
234
|
+
the Response validation will also include possible errors for Requests made to a server
|
235
|
+
address that is not defined in the list of servers in the OpenAPI document.
|
236
|
+
This generally means that if there is a mismatch, every Test Case will raise this error.
|
237
|
+
Note that <code>localhost</code> and <code>127.0.0.1</code> are not considered the same
|
238
|
+
by Response validation.
|
239
|
+
|
240
|
+
<h2>API-specific configurations</h2>
|
241
|
+
|
242
|
+
<h3>mappings_path</h3>
|
243
|
+
See the Advanced Use tab for an in-depth explanation.
|
244
|
+
|
245
|
+
<h3>invalid_property_default_response</h3>
|
246
|
+
The default response code for requests with a JSON body that does not comply
|
247
|
+
with the schema.
|
248
|
+
Example: a value outside the specified range or a string value
|
249
|
+
for a property defined as integer in the schema.
|
250
|
+
|
251
|
+
<h3>default_id_property_name</h3>
|
252
|
+
The default name for the property that identifies a resource (i.e. a unique
|
253
|
+
entity) within the API.
|
254
|
+
The default value for this property name is <code>id</code>.
|
255
|
+
If the target API uses a different name for all the resources within the API,
|
256
|
+
you can configure it globally using this property.
|
257
|
+
|
258
|
+
If different property names are used for the unique identifier for different
|
259
|
+
types of resources, an <code>ID_MAPPING</code> can be implemented using the <code>mappings_path</code>.
|
260
|
+
|
261
|
+
<h3>faker_locale</h3>
|
262
|
+
A locale string or list of locale strings to pass to the Faker library to be
|
263
|
+
used in generation of string data for supported format types.
|
264
|
+
|
265
|
+
<h3>require_body_for_invalid_url</h3>
|
266
|
+
When a request is made against an invalid url, this usually is because of a "404" request;
|
267
|
+
a request for a resource that does not exist. Depending on API implementation, when a
|
268
|
+
request with a missing or invalid request body is made on a non-existent resource,
|
269
|
+
either a 404 or a 422 or 400 Response is normally returned. If the API being tested
|
270
|
+
processes the request body before checking if the requested resource exists, set
|
271
|
+
this parameter to True.
|
272
|
+
|
273
|
+
<h2>Parsing parameters</h2>
|
274
|
+
|
275
|
+
<h3>recursion_limit</h3>
|
276
|
+
The recursion depth to which to fully parse recursive references before the
|
277
|
+
<code>recursion_default</code> is used to end the recursion.
|
278
|
+
|
279
|
+
<h3>recursion_default</h3>
|
280
|
+
The value that is used instead of the referenced schema when the
|
281
|
+
<code>recursion_limit</code> has been reached.
|
282
|
+
The default <code class="language-python">{}</code> represents an empty object in JSON.
|
283
|
+
Depending on schema definitions, this may cause schema validation errors.
|
284
|
+
If this is the case <code class="language-robotframework">${NONE}</code> or an empty list
|
285
|
+
can be tried as an alternative.
|
286
|
+
|
287
|
+
<h2>Security-related parameters</h2>
|
288
|
+
<blockquote><i>Note: these parameters are equivalent to those in the <code>requests</code> library.</i></blockquote>
|
289
|
+
|
290
|
+
<h3>username</h3>
|
291
|
+
The username to be used for Basic Authentication.
|
292
|
+
|
293
|
+
<h3>password</h3>
|
294
|
+
The password to be used for Basic Authentication.
|
295
|
+
|
296
|
+
<h3>security_token</h3>
|
297
|
+
The token to be used for token based security using the <code>Authorization</code> header.
|
298
|
+
|
299
|
+
<h3>auth</h3>
|
300
|
+
A <a href="https://requests.readthedocs.io/en/latest/api/#authentication" target="_blank">requests <code>AuthBase</code> instance</a> to be used for authentication instead of the <code>username</code> and <code>password</code>.
|
301
|
+
|
302
|
+
<h3>cert</h3>
|
303
|
+
The SSL certificate to use with all requests.
|
304
|
+
If string: the path to ssl client cert file (<code>.pem</code>).
|
305
|
+
If tuple: the <code class="language-python">("cert", "key")</code> pair.
|
306
|
+
|
307
|
+
<h3>verify_tls</h3>
|
308
|
+
Whether or not to verify the TLS / SSL certificate of the server.
|
309
|
+
If boolean: whether or not to verify the server TLS certificate.
|
310
|
+
If string: path to a CA bundle to use for verification.
|
311
|
+
|
312
|
+
<h3>extra_headers</h3>
|
313
|
+
A dictionary with extra / custom headers that will be send with every request.
|
314
|
+
This parameter can be used to send headers that are not documented in the
|
315
|
+
openapi document or to provide an API-key.
|
316
|
+
|
317
|
+
<h3>cookies</h3>
|
318
|
+
A dictionary or
|
319
|
+
<a href="https://docs.python.org/3/library/http.cookiejar.html#http.cookiejar.CookieJar" target="_blank"><code>CookieJar</code> object</a>
|
320
|
+
to send with all requests.
|
321
|
+
|
322
|
+
<h3>proxies</h3>
|
323
|
+
A dictionary of <code>"protocol": "proxy url"</code> to use for all requests.</doc>
|
324
|
+
<shortdoc><h2>Test case generation and execution</h2></shortdoc>
|
247
325
|
</init>
|
248
326
|
</inits>
|
249
327
|
<keywords>
|
250
|
-
<kw name="Test Endpoint" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="
|
328
|
+
<kw name="Test Endpoint" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="183">
|
251
329
|
<arguments repr="path: str, method: str, status_code: int">
|
252
330
|
<arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
|
253
331
|
<name>path</name>
|
@@ -262,12 +340,17 @@
|
|
262
340
|
<type name="int" typedoc="integer"/>
|
263
341
|
</arg>
|
264
342
|
</arguments>
|
265
|
-
<doc
|
266
|
-
<
|
267
|
-
|
343
|
+
<doc>Validate that performing the <span class="name">method</span> operation on <a href="#type-Path" class="name">path</a> results in a
|
344
|
+
<span class="name">status_code</span> response.
|
345
|
+
|
346
|
+
This is the main keyword to be used in the <span class="name">Test Template</span> keyword when using
|
347
|
+
the OpenApiDriver.
|
348
|
+
|
349
|
+
The keyword calls other keywords to generate the neccesary data to perform
|
350
|
+
the desired operation and validate the response against the openapi document.</doc>
|
268
351
|
<shortdoc>Validate that performing the `method` operation on `path` results in a `status_code` response.</shortdoc>
|
269
352
|
</kw>
|
270
|
-
<kw name="Test Forbidden" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="
|
353
|
+
<kw name="Test Forbidden" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="115">
|
271
354
|
<arguments repr="path: str, method: str">
|
272
355
|
<arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
|
273
356
|
<name>path</name>
|
@@ -278,12 +361,17 @@
|
|
278
361
|
<type name="str" typedoc="string"/>
|
279
362
|
</arg>
|
280
363
|
</arguments>
|
281
|
-
<doc
|
282
|
-
|
283
|
-
|
364
|
+
<doc>Perform a request for <span class="name">method</span> on the <a href="#type-Path" class="name">path</a>, with the provided authorization.
|
365
|
+
|
366
|
+
This keyword only passes if the response code is 403: Forbidden.
|
367
|
+
|
368
|
+
For this keyword to pass, the authorization parameters used to initialize the
|
369
|
+
library should grant insufficient access rights to the target endpoint.
|
370
|
+
> Note: No headers or (json) body are send with the request. For security
|
371
|
+
reasons, the access rights validation should be checked first.</doc>
|
284
372
|
<shortdoc>Perform a request for `method` on the `path`, with the provided authorization.</shortdoc>
|
285
373
|
</kw>
|
286
|
-
<kw name="Test Invalid Url" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="
|
374
|
+
<kw name="Test Invalid Url" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="132">
|
287
375
|
<arguments repr="path: str, method: str, expected_status_code: int = 404">
|
288
376
|
<arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
|
289
377
|
<name>path</name>
|
@@ -299,13 +387,23 @@
|
|
299
387
|
<default>404</default>
|
300
388
|
</arg>
|
301
389
|
</arguments>
|
302
|
-
<doc
|
303
|
-
|
304
|
-
|
305
|
-
|
390
|
+
<doc>Perform a request for the provided 'path' and 'method' where the url for
|
391
|
+
the <a href="#type-Path" class="name">path</a> is invalidated.
|
392
|
+
|
393
|
+
This keyword will be <span class="name">SKIPPED</span> if the path contains no parts
|
394
|
+
that can be invalidated and there is no mapping for a
|
395
|
+
PathPropertiesConstraint for the <span class="name">expected_status_code</span>.
|
396
|
+
|
397
|
+
The optional <span class="name">expected_status_code</span> parameter (default: 404) can be set to the
|
398
|
+
expected status code for APIs that do not return a 404 on invalid urls.
|
399
|
+
|
400
|
+
> Note: Depending on API design, the url may be validated before or after
|
401
|
+
validation of headers, query parameters and / or (json) body. By default, no
|
402
|
+
parameters are send with the request. The <span class="name">require_body_for_invalid_url</span>
|
403
|
+
parameter can be set to <span class="name">True</span> if needed.</doc>
|
306
404
|
<shortdoc>Perform a request for the provided 'path' and 'method' where the url for the `path` is invalidated.</shortdoc>
|
307
405
|
</kw>
|
308
|
-
<kw name="Test Unauthorized" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="
|
406
|
+
<kw name="Test Unauthorized" source="/workspaces/robotframework-openapitools/src/OpenApiDriver/openapi_executors.py" lineno="94">
|
309
407
|
<arguments repr="path: str, method: str">
|
310
408
|
<arg kind="POSITIONAL_OR_NAMED" required="true" repr="path: str">
|
311
409
|
<name>path</name>
|
@@ -316,9 +414,14 @@
|
|
316
414
|
<type name="str" typedoc="string"/>
|
317
415
|
</arg>
|
318
416
|
</arguments>
|
319
|
-
<doc
|
320
|
-
|
321
|
-
|
417
|
+
<doc>Perform a request for <span class="name">method</span> on the <a href="#type-Path" class="name">path</a>, with no authorization.
|
418
|
+
|
419
|
+
This keyword only passes if the response code is 401: Unauthorized.
|
420
|
+
|
421
|
+
Any authorization parameters used to initialize the library are
|
422
|
+
ignored for this request.
|
423
|
+
> Note: No headers or (json) body are send with the request. For security
|
424
|
+
reasons, the authorization validation should be checked first.</doc>
|
322
425
|
<shortdoc>Perform a request for `method` on the `path`, with no authorization.</shortdoc>
|
323
426
|
</kw>
|
324
427
|
</keywords>
|
@@ -421,7 +524,7 @@
|
|
421
524
|
</usages>
|
422
525
|
</type>
|
423
526
|
<type name="ValidationLevel" type="Enum">
|
424
|
-
<doc
|
527
|
+
<doc>The available levels for the response_validation parameter.</doc>
|
425
528
|
<accepts>
|
426
529
|
<type>string</type>
|
427
530
|
</accepts>
|