Skip to content

Unexpected error occurred. e.replace is not a function #1874

@sneko

Description

@sneko

Hi,

I wanted to generate a specific client that seems to have a valid OpenAPI schema:

openapi-ts -i https://docapi.weezevent.com/weezticket.json -o src/client/weezevent -c @hey-api/client-fetch

But I end up with the error Unexpected error occurred. e.replace is not a function.

By default the stacktrace is minified so I run it inside a script to benefit from sourcemaps:

import { createClient } from '@hey-api/openapi-ts';

createClient({
  input: 'https://docapi.weezevent.com/weezticket.json',
  output: 'src/client/weezevent',
  plugins: ['@hey-api/client-fetch'],
});

The result:

🔥 Unexpected error occurred. e.replace is not a function
node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

TypeError: e.replace is not a function
    at value (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/utils/escape.ts:25:6)
    at parseSchemaJsDoc (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts:26:27)
    at objectTypeToIdentifier (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts:453:16)
    at schemaTypeToIdentifier (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts:639:14)
    at schemaToType (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts:945:12)
    at callbackFn (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts:1039:5)
    at <anonymous> (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/ir/context.ts:113:28)
    at Array.map (<anonymous>)
    at Dr.broadcast (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/ir/context.ts:110:29)
    at _s (xxxxxxxxxxxxxxxxxx/node_modules/@hey-api/openapi-ts/src/ir/parser.ts:18:21)

I wanted to debug more to find the cause (since here it's just sourcemaps so it's hard to debug in the code), but after cloning openapi-ts and having it all installed, I didn't understand how to simply mimic openapi-ts -i https://docapi.weezevent.com/weezticket.json -o src/client/weezevent -c @hey-api/client-fetch.

I tried pnpm run openapi-ts ... but with no success, nor directly into the package folder. Maybe https://heyapi.dev/contributing could tell a bit more how to use the "CLI" directly when developing.

Thank you,

Note: I'm using:

    "@hey-api/client-fetch": "^0.8.3",
    "@hey-api/openapi-ts": "^0.64.14",

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Broken or incorrect behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions