The generated code in curl, Python, etc. is not well generated when we have query parameters with a list of values.
The query parameters in the sample code have the list of values separated by commas (",") and should be exploded instead, i.e., repeat the query parameter for each value separated by an "&".
This behavior is defined by the explode OpenAPI property (that defaults to true), which seems to be being ignored.
Even when we force explode to true, it is ignored.
See this example in the OpenAPI spec (you can download it with the Export button at https://developers.probely.com/api/reference/probely-developer-documentation):
Consider the explode property of the OpenAPI to generate the sample code.
If explode is not defined or is true the query parameters in the sample code should be repeated for each value that is inserted and separated by "&".
If explode is false the values of the query parameter in the sample code should be separated by a comma (",")
At the right hand side, in the REQUEST section, click on Show optional parameters
Add "field 1" and "field2" to the exclude query parameter
Add "t1" and "t2" to the exclude_targetquery parameter
Check the generated sample code in curl that is generated with query parameters separated by commas
Screenshots
Context
This provides a bad user experience for people trying to get the sample code to use the API endpoint since it will not work, and it's difficult to understand why.
Your Environment
Version used: docusaurus: 2.4.3, docusaurus-plugin-openapi-docs: 2.1.0
Describe the bug
The generated code in curl, Python, etc. is not well generated when we have query parameters with a list of values. The query parameters in the sample code have the list of values separated by commas (",") and should be exploded instead, i.e., repeat the query parameter for each value separated by an "&". This behavior is defined by the
explode
OpenAPI property (that defaults totrue
), which seems to be being ignored. Even when we forceexplode
totrue
, it is ignored. See this example in the OpenAPI spec (you can download it with the Export button at https://developers.probely.com/api/reference/probely-developer-documentation):See more about the
explode
property at https://swagger.io/docs/specification/serialization/#queryExpected behavior
In the endpoint https://developers.probely.com/api/reference/api-users-list, when adding values for query parameters
exclude
andexclude_target
like this:The generated curl should be:
Current behavior
Currently, the generated curl is wrong with the values of the query params
exclude
andexclude_target
separated by commas (","):Possible solution
Consider the
explode
property of the OpenAPI to generate the sample code.If
explode
is not defined or istrue
the query parameters in the sample code should be repeated for each value that is inserted and separated by "&". Ifexplode
isfalse
the values of the query parameter in the sample code should be separated by a comma (",")Steps to reproduce
exclude
query parameterexclude_target
query parameterScreenshots
Context
This provides a bad user experience for people trying to get the sample code to use the API endpoint since it will not work, and it's difficult to understand why.
Your Environment