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

OAS 3.0.1 Dictionaries are parsed incorrectly #27

Open
TheMatrix97 opened this issue May 10, 2022 · 0 comments
Open

OAS 3.0.1 Dictionaries are parsed incorrectly #27

TheMatrix97 opened this issue May 10, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@TheMatrix97
Copy link

Steps to reproduce

Define a OAS with the following definition endpoint definition:

"/price/getprice": {
      "get": {
        "tags": [
          "price-controller"
        ],
        "summary": "Get the price of data",
        "operationId": "getPrice",
        "parameters": [
          {
            "name": "parameters",
            "in": "query",
            "description": "characteristic parameters of the data",
            "required": true,
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "price of data",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },

Current Behavior

It generates the following service

export interface PriceControllerService {
  getPrice(parameters: {
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
    [additionalProperty: string]: any;
  }): Promise<string>;
}

This result is wrong! Based on the documentation https://swagger.io/docs/specification/data-models/dictionaries/ it should pass all the query attributes directly, instead of trying nest them under parameters: {}.
So when calling the endpoint -> /price/getprice?a=1&b=2 it throws the error MISSING_REQUIRED_PARAMETERS

{
    "error": {
        "statusCode": 400,
        "name": "BadRequestError",
        "message": "Required parameter parameters is missing!",
        "code": "MISSING_REQUIRED_PARAMETER"
    }
}

Expected Behavior

It should support Maps and Dictionaries and somehow allow dynamic parameters throught the query. Is there any solution implemented? Thanks!

Link to reproduction sandbox

Additional information

Related Issues

See Reporting Issues for more tips on writing good issues

@TheMatrix97 TheMatrix97 added the bug Something isn't working label May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Icebox
Development

No branches or pull requests

1 participant