Issue #1423: responses containing references to definitions were not being fully resolved when the spec was pulled in over AJAX but was working locally. OperationView.render()'s parsing of the responses was just checking if the ref _started_ with '#/definitions/', not whether it contained it, and when pulled in over AJAX the refs have the URL prepended to them

This commit is contained in:
Aaron Baker
2015-08-05 12:42:47 +01:00
parent c7c697206e
commit ed41c336a3

View File

@@ -139,8 +139,8 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
schemaObj = this.model.responses[code].schema; schemaObj = this.model.responses[code].schema;
if (schemaObj && schemaObj.$ref) { if (schemaObj && schemaObj.$ref) {
schema = schemaObj.$ref; schema = schemaObj.$ref;
if (schema.indexOf('#/definitions/') === 0) { if (schema.indexOf('#/definitions/') !== -1) {
schema = schema.substring('#/definitions/'.length); schema = schema.replace(/^.*#\/definitions\//, '');
} }
} }
this.model.responseMessages.push({ this.model.responseMessages.push({