swagger-ui: Boolean body parameters cause JS error

I’ve been working on generating swagger schemas and noticed that an operation that uses a boolean parameter in the body will cause a Javascript error Cannot read property 'toLowerCase' of undefined.

This seems to happen because the handlebars helper isArray (declared in ParameterView.prototype.initialize) is calling toLowerCase() on the parameter type without checking it isn’t undefined first. Since body parameters have the type defined in schema, I figure this is a bug. The validator badge shows that the schema itself is valid, but the UI will fail to render.

If I put a "type": "boolean" property onto the parameter (which is not valid) then it will render properly

I’ve attached two different schemas:

  • Error causing schema, this is the one that should work, but fails.
  • Working schema, this one renders properly, but is not a valid schema (due to the type property being directly on the schema).

Is it appropriate to make the handlebars function check the type is not undefined first? I suspect there’s something more going on here since it only seems to affect boolean parameters.

This is in Chrome Version 40.0.2214.115 (64-bit) on OS X 10.10.2

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 19 (8 by maintainers)

Most upvoted comments

Issue still exists, any roadmap on that ?