Skip to content

Behavior change in 0.17.0 for array and prefixItems #2632

@panwauu

Description

@panwauu

openapi-fetch version

0.17.0

Description

I am no expert with openapi so be understanding if i formulate or understand something wrong.

I am generating a openapi.json file from my python backend and using this to generate a client in typescript to ensure compatability. With the update to version 0.17.0 i get some typescript errors. The generated code does not change but the types in frontend does. The response.data was typed as [string, string][] before and is string[][] now.

Does anyone else have this problem?

Reproduction

My openapi definition looks like this:

          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "prefixItems": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "string"
                      }
                    ],
                    "minItems": 2,
                    "maxItems": 2
                  },
                  "title": "Response Get Personal By Substring Api Get Personal By Substring Get"
                }
              }
            }
          },

The generated ts code looks like this:

            200: {
                headers: {
                    [name: string]: unknown;
                };
                content: {
                    "application/json": [
                        string,
                        string
                    ][];
                };
            };

With version 0.17.0 i get a more generic type even though the type in the generated code is fine and what i would expect:

data: string[][]

Expected result

With version 0.16.0 i get the expected type for my response.data:

data: [string, string][]

I would expect 0.17.0 to behave the same way

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-fetchRelevant to the openapi-fetch library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions