mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-28 19:19:52 +00:00
21 lines
660 B
Python
21 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)
|