swagger-editor
swagger-editor copied to clipboard
Swagger Editor Incorrectly Renders Examples for `deepObject` `explode:true` Parameters
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:
- Open the Swagger Editor at https://editor-next.swagger.io/
- Paste the provided spec in the editor
- Refer to the example or
Try it out
feature in the right panel for thelistCustomers
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