Skip to content

Instantly share code, notes, and snippets.

@amard33p
Last active January 25, 2026 07:26
Show Gist options
  • Select an option

  • Save amard33p/4f35f3c6dd5529cad9d73a47b5f2fa75 to your computer and use it in GitHub Desktop.

Select an option

Save amard33p/4f35f3c6dd5529cad9d73a47b5f2fa75 to your computer and use it in GitHub Desktop.
openapi-ts [Cannot read properties of undefined (reading 'charAt')]
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)
},
},
],
})
{
"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"
}
}
}
}
}
}
}
}
}
}
}
{
"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