diff --git a/swagger_py_codegen/templates/sanic/schemas.tpl b/swagger_py_codegen/templates/sanic/schemas.tpl index fd90c23..6d1f7f9 100644 --- a/swagger_py_codegen/templates/sanic/schemas.tpl +++ b/swagger_py_codegen/templates/sanic/schemas.tpl @@ -4,6 +4,7 @@ {% include '_do_not_change.tpl' %} import six +from jsonschema import RefResolver base_path = '{{base_path}}' @@ -58,4 +59,3 @@ security = Security() {{ merge_default }} {{ normalize }} - diff --git a/swagger_py_codegen/templates/sanic/validators.tpl b/swagger_py_codegen/templates/sanic/validators.tpl index c5edc4d..e295418 100644 --- a/swagger_py_codegen/templates/sanic/validators.tpl +++ b/swagger_py_codegen/templates/sanic/validators.tpl @@ -95,6 +95,13 @@ class SanicValidatorAdaptor(object): for k, values in obj.items(): prop = self.validator.schema['properties'].get(k, {}) type_ = prop.get('type') + if type_ is None and '$ref' in prop: + ref = prop.get('$ref') + if not ref: + continue + type_ = self.validator.resolver.resolve(prop.get('$ref'))[1].get('type') + if not type_: + continue fun = convert_funs.get(type_, lambda v: v[0]) if type_ == 'array': item_type = prop.get('items', {}).get('type') @@ -189,4 +196,4 @@ def response_filter(view): headers=headers, ) - return wrapper + return wrapper \ No newline at end of file