Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

fix: improper handling of application/x-www-form-urlencoded payloads #838

Merged
merged 1 commit into from
Jul 16, 2020

Conversation

erunion
Copy link
Member

@erunion erunion commented Jul 16, 2020

🧰 What's being changed?

This updates fetch-har to resolve some improper handling of application/x-www-form-urlencoded payloads where they would be sent as JSON through the "Try It" request instead of as URLencoded data.

See readmeio/fetch-har#69 for the fix, and https://app.asana.com/0/0/1183793140674162/f for background.

🧪 Testing

Here's a sample OAS you can test with to see it in action.

{
  "openapi": "3.0.0",
  "info": {
    "title": "urlencoded fix",
    "version": "2.0"
  },
  "servers": [
    {
      "url": "http://httpbin.org"
    }
  ],
  "security": [
    {
      "basicAuth": []
    }
  ],
  "paths": {
    "/post": {
      "post": {
        "operationId": "getToken",
        "security": [
          {
            "basicAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "grant_type": {
                    "enum": [
                      "client_credentials"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "basicAuth": {
        "type": "http",
        "scheme": "basic"
      }
    }
  }
}

Here's what the payloads looked like before the fix:

Screen Shot 2020-07-15 at 5 26 47 PM

And fixed:

Screen Shot 2020-07-15 at 5 27 18 PM

@erunion erunion added type:bug Something isn't working scope:dependency Pull requests that update a dependency file area:explorer labels Jul 16, 2020
@erunion erunion force-pushed the fix/x-www-form-urlencoded-issues branch from 73a412c to 0765ae0 Compare July 16, 2020 00:39
@erunion erunion merged commit 2c9b0ac into next Jul 16, 2020
@erunion erunion deleted the fix/x-www-form-urlencoded-issues branch July 16, 2020 00:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope:dependency Pull requests that update a dependency file type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants