Skip to content

Instantly share code, notes, and snippets.

@davetransom
Created July 14, 2015 10:34
Show Gist options
  • Save davetransom/1f2bf02c63a4922fca33 to your computer and use it in GitHub Desktop.
Save davetransom/1f2bf02c63a4922fca33 to your computer and use it in GitHub Desktop.
Display model descriptions in swagger-ui.
// This needs to be injected into swagger-ui's index.html file after 'swagger-ui.js' (where getMockSignature is defined)
// but _before_ it is used to render parts of the page. A horrible dirty hack.
var _originalGetMockSignature = window.Model.prototype.getMockSignature;
window.Model.prototype.getMockSignature = function newModelGetMockSignature(modelsToIgnore) {
var model = this;
var signature = _originalGetMockSignature.apply(this, arguments);
if (model.definition && model.definition.description)
signature = "<span class=\"hacked-in-model-summary\">" + model.definition.description + "</span>\n" + signature;
return signature;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment