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

UI doesn't show Data Type -selector for Models in arrays

Open ikitommi opened this issue 12 years ago • 4 comments

this kind of body-parameter:

{
   "name": "body",
   "description": "List of user object",
   "required": true,
   "type": "array",
   "items": {
      "$ref": "User"
}

has a Data Type of array in the UI, instead of the blown model wrapped in a array.

Tried the latest master & seems to work the same way in the public demo: http://swagger.wordnik.com/#!/user/createUsersWithArrayInput_post_1

regards,

Tommi

ikitommi avatar Feb 19 '14 12:02 ikitommi

Hi Tommy, I'm certain we addressed this in master, which is not uploaded to the petstore sample. See below, which is simply swagger-ui from master running locally:

screen shot 2014-02-19 at 8 43 37 am

fehguy avatar Feb 19 '14 16:02 fehguy

my bad, from master it works beautifully.

thanks!

Tommi

ikitommi avatar Feb 19 '14 19:02 ikitommi

What is the file or files that I need to update to have this fix? I have this same issue with a swagger ui that I downloaded like 3 months ago, I've been doing some customization in the code so I cannot just replace all the files. Thanks.

raspacorp avatar Sep 09 '14 15:09 raspacorp

I found the part that needs to be updated in my version of swagger.js:

SwaggerOperation = (function() { ... for (_i = 0, _len = _ref1.length; _i < _len; _i++) { parameter = _ref1[_i]; parameter.name = parameter.name || parameter.type || parameter.dataType; type = parameter.type || parameter.dataType; // ++++ Add this:
if(type === 'array') { type = 'array[' + parameter.items.$ref + ']'; } // ++++
if (type.toLowerCase() === 'boolean') { parameter.allowableValues = {}; parameter.allowableValues.values = ["true", "false"]; } ...

raspacorp avatar Sep 09 '14 21:09 raspacorp