swagger-ui
swagger-ui copied to clipboard
arrays cause the UI to fail if items aren't present in the schema
This function throws a null pointer error if items isn't present for an array type.
var Property = function(name, obj, required) {
this.schema = obj;
this.required = required;
if(obj['$ref']) {
var refType = obj['$ref'];
refType = refType.indexOf('#/definitions') === -1 ? refType : refType.substring('#/definitions').length;
this['$ref'] = refType;
}
else if (obj.type === 'array') {
if(obj.items['$ref'])
this['$ref'] = obj.items['$ref'];
else
obj = obj.items;
}
this.name = name;
this.obj = obj;
this.optional = true;
this.example = obj.example || null;
}
But json schema does not require items: http://json-schema.org/latest/json-schema-validation.html#anchor36
Is this a case of swagger-ui does require it, or just a bug?
We definitely need items if it's an array, we're not supporting anonymous inner types. Granted an error isn't the right way to handle it.
Btw you filed bug #666. Nice job :-/
Please track this here:
https://github.com/swagger-api/swagger-js/issues/190