Try it out not working - Incorrect cURL with Swagger 2.0
I am using SwaggerHub and local hosted Swagger 2.0 swagger files (using swagger ui) to create interactive API documentation on our site, but the code generated by the Try it out feature is malformed or not working - specifically around the headers.
With SwaggerHub, the cURL created is formatted like so:
curl -X 'POST' \ 'https://api.bigpanda.io/data/v2/alerts' \ -H 'accept: application/json' \ -H 'Authorization: 0925209385' \ -H 'Content-Type: application/json' \ -d '{
But in order to make a successful call to our api, it must be formatted as:
curl -X POST \ --url https://api.bigpanda.io/data/v2/alerts \ -H 'accept: application/json' \ -H 'Authorization: Bearer 0925209385' \ -H 'Content-Type: application/json' \ -d '{
(the changes are: no quotes around post or url, url command explicit, "Bearer" string added to apiKey authorization)
Is there something I can change to get these to format correctly? We can ask our users to make these changes manually, but it severely limits the usefulness of the try it out, and we might just have to turn it off.
Hello there! The URL is always generated with quotes, there's no way to change it. To add bearer token you can try to modify the securitySchemes section of your OpenAPI document to explicitly define Bearer authentication. You can find more details in OAS documentation below:
https://swagger.io/docs/specification/v3_0/authentication/bearer-authentication/