Request sent from Swagger UI not resulting in Postman x-www-form-urlencoded response

690 Views Asked by At

I'm currently configuring a Swagger file to utilize OAuth to retrieve tokens from a site. For brevity, I have removed my schemes and most of my paths as those are fine.

{
  "openapi": "3.0.2",
  "info": {
    "title": "swagger",
    "version": "1.0.0",
    "description": ""
  },
  "servers": [
    {
      "url": "url"
    }
  ],
  "paths": {
    "/oauth_token.do": {
      "post": {
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object"
              }
            }
          }
        }
      }
    }
  },
  "components": {
     "securitySchemes": {
      "OAuth": {
        "type": "oauth2",
        "flows": {
          "password": {
            "tokenUrl": "/oauth_token.do",
            "refreshUrl": "/oauth_token.do",
            "scopes": {
              "useraccount": "utilize user account"
            }
          }
        }
      }
    }
   }
  "security": [
    {
      "OAuth": ["useraccount"]
    }
  ]
}

The endpoint for this API specifies that I should use x-www-form-urlencoded in the header as the Content-Type. When executing this request in Postman, it returns 200 with the desired response.

However, with https://editor.swagger.io I input the same postman request to get the fetch failed error with my Authorize button. To test for this, I created a custom path that specifies that the content should be x-www-form-urlencoded and this also fails.

So, what am I missing in this case? Any help would be appreciated.

1

There are 1 best solutions below

0
On

I believe the issue was I did not fill out some portions I added on the response for path. Instead I opted to only leave description for the 200 response.

The main error I'm getting now is CORS related which is unrelated to the original question. I'll mark this answered for now.