Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MULTIPLE_BODY_PARAMETERS error for application/x-www-form-urlencoded #1057

Open
kevinoid opened this issue Nov 14, 2024 · 0 comments
Open

MULTIPLE_BODY_PARAMETERS error for application/x-www-form-urlencoded #1057

kevinoid opened this issue Nov 14, 2024 · 0 comments

Comments

@kevinoid
Copy link

If an OpenAPI 2.0 document contains an operation which contains multiple parameters in formData and consumes application/x-www-form-urlencoded, validation fails with MULTIPLE_BODY_PARAMETERS. If consumes is changed to multipart/form-data, validation succeeds without error. For example:

{
  "swagger": "2.0",
  "info": {
    "title": "Title",
    "version": "1.0"
  },
  "paths": {
    "/": {
      "post": {
        "operationId": "test",
        "consumes": [
          "application/x-www-form-urlencoded"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "first_name",
            "in": "formData",
            "type": "string"
          },
          {
            "name": "last_name",
            "in": "formData",
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "Example response"
          }
        }
      }
    }
  }
}

The OpenAPI document validates and Autorest generates correct code, but oav validation fails.

This issue is similar to #805.

I believe it could be fixed by checking for application/x-www-form-urlencoded in addition to multipart/form-data at

consumes.includes("multipart/form-data")

Thanks for considering,
Kevin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant