swagger-api / swagger-js

Javascript library to connect to swagger-enabled APIs via browser or nodejs
http://swagger.io
Apache License 2.0
2.62k stars 758 forks source link

fix(execute): fix encoding for stringified request body #3476

Closed glowcloud closed 5 months ago

glowcloud commented 5 months ago

Refs https://github.com/swagger-api/swagger-ui/issues/7810

With these changes we should now parse the string and then iterate through it only if it's actually an object.

The issue is that we are sending a stringified object and then iterating through it as if it were just an object. It happened even if I updated the examples in the specification provided in the issue, which seemed wronged to me, to:

examples:
  authorization_code grant type:
    description: authorization_code grant type
    value:
      grant_type: authorization_code
      code: xxxxxxxxxx
      client_id: xxxxxxxxxx
  client_credentials grant type:
    description: client_credentials grant type
    value: 
      grant_type: client_credentials
      client_id: xxxxxxxxxx
      client_secret: xxxxxxxxxx
  refresh_token grant type:
    description: refresh_token grant type
    value: 
      grant_type: refresh_token
      refresh_token: xxxxxxxxxx

so that it shows as an object in Swagger UI:

Screenshot 2024-04-22 at 14 38 52
swagger-bot commented 5 months ago

:tada: This PR is included in version 3.27.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: