You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugin generates incorrect curl examples for array query parameters defined with style: form and explode: true. The plugin concatenates the array values into a single parameter with comma-separated values, which does not match the expected API format.
The plugin generates the following incorrect curl example:
curl -X GET 'https://api.example.com/customers?customerIds[]=cust789,cust123'
This example combines the array values into a single parameter customerIds[]=cust789,cust123, which does not work with the API.
Possible solution
Modify the plugin to correctly handle array query parameters with style: form and explode: true by generating separate parameters for each array item. The correct curl example should look like:
curl -X GET 'https://api.example.com/customers?customerIds%5B%5D=cust789&customerIds%5B%5D=cust123'
Steps to reproduce
Install docusaurus-plugin-openapi-docs version ^4.2.0.
Create an OpenAPI file with an array parameter as shown in the example above.
Generate the documentation using the plugin.
Notice that the generated curl example concatenates array values into a single parameter with commas.
How editor.swagger.io generates the curl command
When loading this OpenAPI file into editor.swagger.io, it generates the correct curl example:
curl -X GET "https://api.example.com/customers?customerIds%5B%5D=cust789&customerIds%5B%5D=cust123" -H "accept: application/json"
Editor.swagger.io correctly encodes each array item as a separate query parameter, using customerIds%5B%5D=cust789 and customerIds%5B%5D=cust123, which aligns with the OpenAPI specification and the expected API behavior.
Your Environment
Version used: docusaurus-plugin-openapi-docs^4.2.0
Environment name and version: Node.js v14.x
Operating System and version: Windows 10
Link to your project: Private project; the issue can be reproduced using the provided OpenAPI file.
The text was updated successfully, but these errors were encountered:
Current behavior
Plugin generates incorrect curl examples for array query parameters defined with
style: form
andexplode: true
. The plugin concatenates the array values into a single parameter with comma-separated values, which does not match the expected API format.For the simplified OpenAPI file:
The plugin generates the following incorrect curl example:
curl -X GET 'https://api.example.com/customers?customerIds[]=cust789,cust123'
This example combines the array values into a single parameter
customerIds[]=cust789,cust123
, which does not work with the API.Possible solution
Modify the plugin to correctly handle array query parameters with
style: form
andexplode: true
by generating separate parameters for each array item. The correct curl example should look like:curl -X GET 'https://api.example.com/customers?customerIds%5B%5D=cust789&customerIds%5B%5D=cust123'
Steps to reproduce
docusaurus-plugin-openapi-docs
version^4.2.0
.How editor.swagger.io generates the curl command
When loading this OpenAPI file into editor.swagger.io, it generates the correct curl example:
Editor.swagger.io correctly encodes each array item as a separate query parameter, using
customerIds%5B%5D=cust789
andcustomerIds%5B%5D=cust123
, which aligns with the OpenAPI specification and the expected API behavior.Your Environment
docusaurus-plugin-openapi-docs
^4.2.0
The text was updated successfully, but these errors were encountered: