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

Generated TS definitions don't contain any path/query parameters. #1983

Open
1 task done
Rattlyy opened this issue Oct 31, 2024 · 1 comment
Open
1 task done

Generated TS definitions don't contain any path/query parameters. #1983

Rattlyy opened this issue Oct 31, 2024 · 1 comment
Assignees
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library

Comments

@Rattlyy
Copy link

Rattlyy commented Oct 31, 2024

Description

The generated TS definitions don't contain any path/query parameters.

export interface operations {
    "TripRoutes.flights": {
        parameters: {
            query?: never;
            header?: never;
            path?: never;
            cookie?: never;
        };
        requestBody?: never;
        responses: {
/** removed **/
        };
    };
}

OpenAPI Schema:

{
  "openapi": "3.1.0",
  "servers": [
    {
      "url": "http://localhost:8080/api"
    }
  ],
  "tags": [
    {
      "name": "TripRoutes"
    },
  ],
  "paths": {
    "/flights": {
      "get": {
        "operationId": "TripRoutes.flights",
        "tags": [
          "TripRoutes"
        ],
        "parameters": [
          {
            "name": "sourceAirports",
            "required": true,
            "in": "QUERY",
            "schema": {
              "type": "object",
              "properties": {
                "additionals": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "code": {
                  "type": "string"
                },
                "id": {
                  "type": "integer",
                  "format": "int32"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "name"
              ]
            }
          },
          {
            "name": "destinationAirports",
            "required": true,
            "in": "QUERY",
            "schema": {
              "type": "object",
              "properties": {
                "additionals": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "code": {
                  "type": "string"
                },
                "id": {
                  "type": "integer",
                  "format": "int32"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "name"
              ]
            }
          },
          {
            "name": "adults",
            "required": true,
            "in": "QUERY",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "children",
            "required": true,
            "in": "QUERY",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "infants",
            "required": true,
            "in": "QUERY",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "startDate",
            "required": true,
            "in": "QUERY",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "required": true,
            "in": "QUERY",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "direct",
            "required": false,
            "in": "QUERY",
            "schema": {
              "type": "boolean"
            }
          }
        ]
      }
    }
  }
}

Reproduction

Just download latest lib, plug my schema and run the command.

Checklist

@Rattlyy Rattlyy added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Oct 31, 2024
@gzm0
Copy link
Contributor

gzm0 commented Nov 6, 2024

Can reproduce with this schema. The issue is that "QUERY" is uppercase. Lower-casing to " query".

Note that the parameter object in field needs to be lower case:
https://swagger.io/specification/#parameter-object

So this is not a bug per se, but arguably, the failure behavior could be better (report bad in, rather than ignore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library
Projects
Status: No status
Development

No branches or pull requests

3 participants