Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Support security settings openapi libcore #31

Merged
merged 4 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ Both a local openapi.json or openapi.yaml file or one hosted by the API server
can be checked using the `prance validate <reference_to_file>` shell command:

```shell
prance validate http://localhost:8000/openapi.json
prance validate --backend=openapi-spec-validator http://localhost:8000/openapi.json
Processing "http://localhost:8000/openapi.json"...
-> Resolving external references.
Validates OK as OpenAPI 3.0.2!

prance validate /tests/files/petstore_openapi.yaml
prance validate --backend=openapi-spec-validator /tests/files/petstore_openapi.yaml
Processing "/tests/files/petstore_openapi.yaml"...
-> Resolving external references.
Validates OK as OpenAPI 3.0.2!
Expand All @@ -70,8 +70,8 @@ You'll have to change the url or file reference to the location of the openapi
document for your API.

> Note: Although recursion is technically allowed under the OAS, tool support is limited
and changing the API to not use recursion is recommended.
At present OpenApiLibCore has limited support for parsing OpenAPI documents with
and changing the OAS to not use recursion is recommended.
OpenApiDriver has limited support for parsing OpenAPI documents with
recursion in them. See the `recursion_limit` and `recursion_default` parameters.

If the openapi document passes this validation, the next step is trying to do a test
Expand Down
2 changes: 1 addition & 1 deletion docs/openapidriver.html

Large diffs are not rendered by default.

443 changes: 235 additions & 208 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name="robotframework-openapidriver"
version = "4.0.0"
version = "4.1.0"
description = "A library for contract-testing OpenAPI / Swagger APIs."
license = "Apache-2.0"
authors = ["Robin Mackaij <r.a.mackaij@gmail.com>"]
Expand All @@ -24,7 +24,7 @@ include = ["*.libspec"]
[tool.poetry.dependencies]
python = "^3.8"
robotframework-datadriver = ">=1.6.1"
robotframework-openapi-libcore = "^1.8.5"
robotframework-openapi-libcore = "^1.9.0"

[tool.poetry.group.dev.dependencies]
fastapi = ">=0.95.0"
Expand Down
33 changes: 20 additions & 13 deletions src/OpenApiDriver/openapi_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
RequestsOpenAPIResponse,
)
from openapi_core.templating.paths.exceptions import ServerNotFound
from openapi_core.unmarshalling.schemas.exceptions import InvalidSchemaValue
from openapi_core.validation.schemas.exceptions import InvalidSchemaValue
from OpenApiLibCore import OpenApiLibCore, RequestData, RequestValues, resolve_schema
from requests import Response
from requests.auth import AuthBase
from requests.cookies import RequestsCookieJar as CookieJar
from robot.api import SkipExecution
from robot.api.deco import keyword, library
from robot.libraries.BuiltIn import BuiltIn
Expand Down Expand Up @@ -45,37 +46,43 @@ def __init__( # pylint: disable=too-many-arguments
source: str,
origin: str = "",
base_path: str = "",
response_validation: ValidationLevel = ValidationLevel.WARN,
disable_server_validation: bool = True,
mappings_path: Union[str, Path] = "",
invalid_property_default_response: int = 422,
default_id_property_name: str = "id",
faker_locale: Optional[Union[str, List[str]]] = None,
require_body_for_invalid_url: bool = False,
recursion_limit: int = 1,
recursion_default: Any = {},
username: str = "",
password: str = "",
security_token: str = "",
auth: Optional[AuthBase] = None,
cert: Optional[Union[str, Tuple[str, str]]] = None,
verify_tls: Optional[Union[bool, str]] = True,
extra_headers: Optional[Dict[str, str]] = None,
response_validation: ValidationLevel = ValidationLevel.WARN,
disable_server_validation: bool = True,
require_body_for_invalid_url: bool = False,
invalid_property_default_response: int = 422,
recursion_limit: int = 1,
recursion_default: Any = {},
faker_locale: Optional[Union[str, List[str]]] = None,
default_id_property_name: str = "id",
cookies: Optional[Union[Dict[str, str], CookieJar]] = None,
proxies: Optional[Dict[str, str]] = None,
) -> None:
super().__init__(
source=source,
origin=origin,
base_path=base_path,
mappings_path=mappings_path,
default_id_property_name=default_id_property_name,
faker_locale=faker_locale,
recursion_limit=recursion_limit,
recursion_default=recursion_default,
username=username,
password=password,
security_token=security_token,
auth=auth,
cert=cert,
verify_tls=verify_tls,
extra_headers=extra_headers,
recursion_limit=recursion_limit,
recursion_default=recursion_default,
faker_locale=faker_locale,
default_id_property_name=default_id_property_name,
cookies=cookies,
proxies=proxies,
)
self.response_validation = response_validation
self.disable_server_validation = disable_server_validation
Expand Down
Loading