Skip to content

deepObject query parameter doesn't work #4216

@jfboismenu

Description

@jfboismenu
Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0
Which Swagger-UI version? 3.10
How did you install Swagger-UI? git clone
Which browser & version? Chrome 64
Which operating system? macOS

The webui doesn't seem to handle deepObject correctly. For example:

openapi: 3.0.0
servers:
  - url: https://localhost
info:
  description: |
    This is a sample API that allows to reproduce the deepObject UX issue
  version: "1.0.0"
  title: deepObject UX issue
paths:
  /:
    get:
      parameters:
        - in: query
          name: param
          schema:
            type: object
            properties:
              first:
                type: integer
                example: 1
              second:
                type: string
                example: "this is a string"
          style: deepObject
          explode: true
      responses:
        '200':
          description: OK

Here's what the web-ui gives:

screen shot 2018-02-12 at 15 50 47

If I were to type first=1 in that box for example, the generated URL would be

https://localhost/?param[0]=f&param[1]=i&param[2]=r&param[3]=s&param[4]=t&param[5]=%3D&param[6]=1

As you can see, it simply iterates over each character, uses it's position at the argument name and the letter as the value.

This code from swagger-js expects an object to be passed as a parameter and wants to iterate over the keys of an object.

It seems like deepObject fields in swagger-ui should be treated as a JSON document and be unserialized into an object before being passed to swagger-jss parameter-builds.js:query.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions