Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger Editor Incorrectly Renders Examples for deepObject explode:true Parameters #4781

Open
ckoegel opened this issue Jan 23, 2024 · 0 comments

Comments

@ckoegel
Copy link

ckoegel commented Jan 23, 2024

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome, firefox
  • Swagger-Editor version: 5.0.0-alpha.87
  • Swagger/OpenAPI version: OpenAPI 3.0.3/3.1.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: Customers API
  version: 1.0.0
servers:
  - url: 'https://api.customers.com/'
    description: Production
paths:
  /customers:
    get:
      summary: List All Customers
      operationId: listCustomers
      description: This operation returns a list of all customers.
      tags:
        - Customers
      parameters:
        - $ref: '#/components/parameters/firstName'
      responses:
        '200':
           description: OK
components:
  schemas:
    nameQueryParameter:
      title: Name Query Parameter
      description: Base model for a name query parameter.
      properties:
        eq:
          type: string
        ne:
          type: string
        regex:
          type: string
        contains:
          type: string
        sort:
          $ref: '#/components/schemas/sort'
      example:
        ne: 'David'
        contains: 'Da'
        sort: ASC
    sort:
      type: string
      enum:
        - ASC
        - DESC
  parameters:
    firstName:
      name: firstName
      in: query
      description: Sorting and filtering parameters for `firstName`.
      style: deepObject
      explode: true
      schema:
        $ref: '#/components/schemas/nameQueryParameter'
  securitySchemes:
    Token:
      type: http
      scheme: bearer
      bearerFormat: JWT
security:
  - Token: []
tags:
  - name: Customers

Describe the bug you're encountering

According to the Official Swagger Docs, when a query parameter is defined with the style deepObject and has the explode field set to true, each property of the object is expanded into its own query parameter as such: paramName[property]=value. When using the combination of deepObject and explode: true for a parameter and viewing it in the Swagger Editor, the example for the parameter shows as an object in the form paramName={property: value} instead of the exploded form. In the example spec provided above, the firstName parameter is defined as a deepObject with explode set to true. Instead of each property being their own parameter, the example shows one single firstName object as a query parameter, and using the Try it out function sends the request using the unexploded form. This happens for both v3.0.3 and v3.1.0 of OAS.

To reproduce...

Steps to reproduce the behavior:

  1. Open the Swagger Editor at https://editor-next.swagger.io/
  2. Paste the provided spec in the editor
  3. Refer to the example or Try it out feature in the right panel for the listCustomers endpoint

Expected behavior

The editor should render the provided example as a series of exploded query parameters and the Try it out request should use the exploded form instead of object form for the provided properties.

Additional context or thoughts

This is in the alpha version of the editor, so there may be plans to support this in the future I'm unaware of

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant