-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from p1c2u/refactor/shortcuts-refactor-and-va…
…lidators-explicit-usage Shortcuts refactor and validators explicit usage
- Loading branch information
Showing
5 changed files
with
31 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
"""OpenAPI spec validator shortcuts module.""" | ||
from typing import Any | ||
from typing import Callable | ||
from typing import Hashable | ||
from typing import Mapping | ||
|
||
from jsonschema_spec.handlers import all_urls_handler | ||
|
||
from openapi_spec_validator.validation import openapi_spec_validator_proxy | ||
from openapi_spec_validator.validation.protocols import SupportsValidation | ||
|
||
|
||
def validate_spec_factory( | ||
validator: SupportsValidation, | ||
) -> Callable[[Mapping[Hashable, Any], str], None]: | ||
def validate(spec: Mapping[Hashable, Any], spec_url: str = "") -> None: | ||
return validator.validate(spec, spec_url=spec_url) | ||
def validate_spec( | ||
spec: Mapping[Hashable, Any], | ||
spec_url: str = "", | ||
validator: SupportsValidation = openapi_spec_validator_proxy, | ||
) -> None: | ||
return validator.validate(spec, spec_url=spec_url) | ||
|
||
return validate | ||
|
||
|
||
def validate_spec_url_factory( | ||
validator: SupportsValidation, | ||
) -> Callable[[str], None]: | ||
def validate(spec_url: str) -> None: | ||
spec = all_urls_handler(spec_url) | ||
return validator.validate(spec, spec_url=spec_url) | ||
|
||
return validate | ||
def validate_spec_url( | ||
spec_url: str, | ||
validator: SupportsValidation = openapi_spec_validator_proxy, | ||
) -> None: | ||
spec = all_urls_handler(spec_url) | ||
return validator.validate(spec, spec_url=spec_url) |
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