swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

undefined model causes exception in schemaToHTML function in v2.1.1-M2

Open johnwiesel opened this issue 10 years ago • 2 comments

I am using swagger-ui in v2.1.1-M2.

My swagger.json is validated by swagger-tools 0.10.1 without errors. The swagger.json and externally referenced files can be found in the master branch in https://github.com/itembase/api-swagger

When opening the definition using the swagger-ui, the UI does not show up and the console shows

Uncaught TypeError: Cannot read property 'definition' of undefined in swagger-ui.js:2699

In line 2699 of swagger-ui.js it reads if (model !== null && model.definition.title !== null && typeof model.definition.title !== 'undefined') { replacing this with ` if (model != null && model.definition.title !== null && typeof model.definition.title !== 'undefined') {' seems to address this issue. It then seems to be rendered fine at https://developers.itembase.com/api/docs (this will be moved to https://api.itembase.com/api/docs soon btw.).

Not sure if model should ever be undefined though. Maybe I am doing something wrong in my api spec that is not caught by the validator? Thanks for your help!

johnwiesel avatar Mar 31 '16 10:03 johnwiesel

Try upgrading to the latest version. You're using what we'd refer to as an ancient version ;)

webron avatar Mar 31 '16 16:03 webron

Closing for no response.

webron avatar Jun 09 '16 22:06 webron