Last active
January 25, 2026 07:26
-
-
Save amard33p/4f35f3c6dd5529cad9d73a47b5f2fa75 to your computer and use it in GitHub Desktop.
openapi-ts [Cannot read properties of undefined (reading 'charAt')]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { defineConfig } from "@hey-api/openapi-ts" | |
| export default defineConfig({ | |
| client: "legacy/axios", | |
| input: "./openapi.json", | |
| output: "./src/client", | |
| // exportSchemas: true, | |
| plugins: [ | |
| { | |
| name: "@hey-api/sdk", | |
| // NOTE: this doesn't allow tree-shaking | |
| asClass: true, | |
| operationId: true, | |
| methodNameBuilder: (operation) => { | |
| // @ts-expect-error | |
| let name: string = operation.name | |
| // @ts-expect-error | |
| const service: string = operation.service | |
| if (service && name.toLowerCase().startsWith(service.toLowerCase())) { | |
| name = name.slice(service.length) | |
| } | |
| return name.charAt(0).toLowerCase() + name.slice(1) | |
| }, | |
| }, | |
| ], | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "openapi": "3.0.0", | |
| "info": { | |
| "title": "Test API", | |
| "version": "1.0.0" | |
| }, | |
| "paths": { | |
| "/test": { | |
| "get": { | |
| "summary": "Test endpoint", | |
| "operationId": "testEndpoint", | |
| "responses": { | |
| "200": { | |
| "description": "Success", | |
| "content": { | |
| "application/json": { | |
| "schema": { | |
| "type": "object", | |
| "properties": { | |
| "message": { | |
| "type": "string" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "test-reproduce", | |
| "version": "1.0.0", | |
| "scripts": { | |
| "generate-client": "openapi-ts" | |
| }, | |
| "devDependencies": { | |
| "@hey-api/openapi-ts": "^0.90.10" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment