Skip to content
Merged
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
23 changes: 16 additions & 7 deletions base_rest_pydantic/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,28 @@
"required": prop in json_schema.get("required", []),
"allowEmptyValue": spec.get("nullable", False),
"default": spec.get("default"),
"schema": {},
}
if spec.get("schema"):
params["schema"] = spec.get("schema")
else:
params["schema"] = {"type": spec["type"]}
if spec.get("items"):
params["schema"]["items"] = spec.get("items")
if "anyOf" in spec:
params["schema"]["anyOf"] = spec["anyOf"]

Check warning on line 76 in base_rest_pydantic/restapi.py

View check run for this annotation

Codecov / codecov/patch

base_rest_pydantic/restapi.py#L76

Added line #L76 was not covered by tests
elif "oneOf" in spec:
params["schema"]["oneOf"] = spec["oneOf"]

Check warning on line 78 in base_rest_pydantic/restapi.py

View check run for this annotation

Codecov / codecov/patch

base_rest_pydantic/restapi.py#L78

Added line #L78 was not covered by tests
elif "type" in spec:
params["schema"]["type"] = spec["type"]

Check warning on line 80 in base_rest_pydantic/restapi.py

View check run for this annotation

Codecov / codecov/patch

base_rest_pydantic/restapi.py#L80

Added line #L80 was not covered by tests
if spec.get("nullable", False):
if "type" in params["schema"]:
params["schema"]["type"] = ["null", params["schema"]["type"]]

Check warning on line 83 in base_rest_pydantic/restapi.py

View check run for this annotation

Codecov / codecov/patch

base_rest_pydantic/restapi.py#L83

Added line #L83 was not covered by tests
elif "anyOf" in params["schema"]:
params["schema"]["anyOf"].append({"type": "null"})

Check warning on line 85 in base_rest_pydantic/restapi.py

View check run for this annotation

Codecov / codecov/patch

base_rest_pydantic/restapi.py#L85

Added line #L85 was not covered by tests
elif "oneOf" in params["schema"]:
params["schema"]["oneOf"].append({"type": "null"})

Check warning on line 87 in base_rest_pydantic/restapi.py

View check run for this annotation

Codecov / codecov/patch

base_rest_pydantic/restapi.py#L87

Added line #L87 was not covered by tests

if "enum" in spec:
params["schema"]["enum"] = spec["enum"]

parameters.append(params)

if spec["type"] == "array":
if spec.get("type") == "array":
# To correctly handle array into the url query string,
# the name must ends with []
params["name"] = params["name"] + "[]"
Expand Down