这是indexloc提供的服务,不要输入任何密码
Skip to content

Maximum call stack size exceeded when using asClass: true #2377

@flow96

Description

@flow96

Description

There is an error when trying to generate the typescript client using the asClass: true option and when the schema contains the same keys in the tags array and the operationId.

The issue seems to be when both, the tag and the operationId contain the same (sub-) key.
In my attached example case the problem can be solved by removing the tag "TodoItem" for example.

It would be good if the tags would be ignored when there is a dot-notation in the operationId.
I already tried to play around with the operationId parameter in the config but that didn't have any impact on this problem.

The config I use:

import { defaultPlugins, defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
    input: 'schema.json',
    output: './resources/js/gen/client',
    plugins: [
        ...defaultPlugins,
        {
            asClass: true,
            name: '@hey-api/sdk'
        }
    ]
});

The problem

Twice the "key" todoitem

"operationId": "todoItem.index",
"tags": [
    "TodoItem"
],

How it works

"operationId": "todoItem.index",
"tags": [],

I attached a reproducable stackblitz example.
And thank you for the library, I really like it so far!

Reproducible example or configuration

https://stackblitz.com/edit/hey-api-client-fetch-example-qq6wsvzh

Simply run npm run generate-client or

npx @hey-api/openapi-ts \
  -i schema.json \
  -o src/client

OpenAPI specification (optional)

{
    "openapi": "3.1.0",
    "info": {
        "title": "Laravel",
        "version": "0.0.1"
    },
    "servers": [
        {
            "url": "http:\/\/localhost:8000\/api"
        }
    ],
    "paths": {
        "\/todo-items": {
            "get": {
                "operationId": "todoItem.index",
                "tags": [
                    "TodoItem"
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "enum": [
                                                "Hello World"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "message"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

System information (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions