mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 03:00:11 +00:00
22 lines
660 B
Python
22 lines
660 B
Python
|
"""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)
|