mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-22 03:00:10 +00:00
Move create_spec shortcut
This commit is contained in:
parent
c407e960ca
commit
90060b9c8a
2 changed files with 22 additions and 20 deletions
|
@ -1,12 +1,6 @@
|
||||||
"""OpenAPI core shortcuts module"""
|
"""OpenAPI core shortcuts module"""
|
||||||
# backward compatibility
|
# backward compatibility
|
||||||
from jsonschema.validators import RefResolver
|
from openapi_core.spec.shortcuts import create_spec
|
||||||
from openapi_spec_validator import (
|
|
||||||
default_handlers, openapi_v3_spec_validator,
|
|
||||||
)
|
|
||||||
from openapi_spec_validator.validators import Dereferencer
|
|
||||||
|
|
||||||
from openapi_core.spec.paths import SpecPath
|
|
||||||
from openapi_core.validation.request.shortcuts import (
|
from openapi_core.validation.request.shortcuts import (
|
||||||
spec_validate_body as validate_body,
|
spec_validate_body as validate_body,
|
||||||
spec_validate_parameters as validate_parameters,
|
spec_validate_parameters as validate_parameters,
|
||||||
|
@ -21,16 +15,3 @@ __all__ = [
|
||||||
'create_spec', 'validate_body', 'validate_parameters', 'validate_data',
|
'create_spec', 'validate_body', 'validate_parameters', 'validate_data',
|
||||||
'RequestValidator', 'ResponseValidator',
|
'RequestValidator', 'ResponseValidator',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def create_spec(
|
|
||||||
spec_dict, spec_url='', handlers=default_handlers,
|
|
||||||
validate_spec=True,
|
|
||||||
):
|
|
||||||
if validate_spec:
|
|
||||||
openapi_v3_spec_validator.validate(spec_dict, spec_url=spec_url)
|
|
||||||
|
|
||||||
spec_resolver = RefResolver(
|
|
||||||
spec_url, spec_dict, handlers=handlers)
|
|
||||||
dereferencer = Dereferencer(spec_resolver)
|
|
||||||
return SpecPath.from_spec(spec_dict, dereferencer)
|
|
||||||
|
|
21
openapi_core/spec/shortcuts.py
Normal file
21
openapi_core/spec/shortcuts.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
"""OpenAPI core spec shortcuts module"""
|
||||||
|
from jsonschema.validators import RefResolver
|
||||||
|
from openapi_spec_validator import (
|
||||||
|
default_handlers, openapi_v3_spec_validator,
|
||||||
|
)
|
||||||
|
from openapi_spec_validator.validators import Dereferencer
|
||||||
|
|
||||||
|
from openapi_core.spec.paths import SpecPath
|
||||||
|
|
||||||
|
|
||||||
|
def create_spec(
|
||||||
|
spec_dict, spec_url='', handlers=default_handlers,
|
||||||
|
validate_spec=True,
|
||||||
|
):
|
||||||
|
if validate_spec:
|
||||||
|
openapi_v3_spec_validator.validate(spec_dict, spec_url=spec_url)
|
||||||
|
|
||||||
|
spec_resolver = RefResolver(
|
||||||
|
spec_url, spec_dict, handlers=handlers)
|
||||||
|
dereferencer = Dereferencer(spec_resolver)
|
||||||
|
return SpecPath.from_spec(spec_dict, dereferencer)
|
Loading…
Reference in a new issue