-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This accommodates for a change in pulpcore that will effect the CI. pulp/pulpcore#1102 [noissue]
- Loading branch information
Showing
8 changed files
with
96 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Customizing OpenAPI validation. | ||
OpenAPI requires paths to start with slashes: | ||
https://spec.openapis.org/oas/v3.0.3#patterned-fields | ||
But some pulp paths start with curly brackets e.g. {artifact_href} | ||
This script modifies drf-spectacular schema validation to accept slashes and curly brackets. | ||
""" | ||
import json | ||
from drf_spectacular.validation import JSON_SCHEMA_SPEC_PATH | ||
|
||
with open(JSON_SCHEMA_SPEC_PATH) as fh: | ||
openapi3_schema_spec = json.load(fh) | ||
|
||
properties = openapi3_schema_spec["definitions"]["Paths"]["patternProperties"] | ||
# Making OpenAPI validation to accept paths starting with / and { | ||
if "^\\/|{" not in properties: | ||
properties["^\\/|{"] = properties["^\\/"] | ||
del properties["^\\/"] | ||
|
||
with open(JSON_SCHEMA_SPEC_PATH, "w") as fh: | ||
json.dump(openapi3_schema_spec, fh) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters