Skip to content

Instantly share code, notes, and snippets.

@Markbnj
Created April 22, 2016 20:31
Show Gist options
  • Save Markbnj/998e198d1771e4d01943549d6e2f2287 to your computer and use it in GitHub Desktop.
Save Markbnj/998e198d1771e4d01943549d6e2f2287 to your computer and use it in GitHub Desktop.
import json
import os
from bravado_core.spec import Spec
from bravado_core.validate import validate_object
from yaml import load, Loader, dump, Dumper
def validate_car(car):
validate_object(spec, Car, car)
def get_swagger_spec():
with open(spec_path,'r') as spec:
return load(spec.read(), Loader)
bravado_config = {
'validate_swagger_spec': False,
'validate_requests': False,
'validate_responses': False,
'use_models': True,
}
dir_path = os.path.dirname(os.path.abspath(__file__))
spec_path = os.path.join(dir_path, "swagger-spec.yaml")
spec_dict = get_swagger_spec()
spec = Spec.from_dict(spec_dict, config=bravado_config)
Car = spec_dict['definitions']['Car']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment