acacode / acacode/swagger-typescript-api

Getting error "An identifier or keyword cannot immediately follow a numeric literal" on api routes containing numbers (api/1/endpoint)

Aberta
#319 5 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
4.1k
Forks
436
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

Some of my API routes look like this: `/api/3/ContainerHistory/GetUserContainers`
This leads to the following error when generating types:
```
SyntaxError: An identifier or keyword cannot immediately follow a numeric literal. (1740:2)
1738 | * @request GET:/api/3/ContainerHistory/GetUserContainers
1739 | */
> 1740 | 3ContainerHistoryGetUserContainersList: (query?: { showCounts?: boolean, showActive?: boolean, showSold?: boolean, showReturned?: boolean, skip?: number, limit?: number }, params: RequestParams = {}) =>
| ^
1741 | this.request({
1742 | path: `/api/3/ContainerHistory/GetUserContainers`,
1743 | method: 'GET',
at e (/Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/parser-typescript.js:1:322)
at /Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/parser-typescript.js:22:3328487
at Object.parse (/Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/parser-typescript.js:22:3328520)
at Object.parse$a [as parse] (/Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/index.js:12513:19)
at coreFormat (/Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/index.js:14044:16)
at formatWithCursor$1 (/Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/index.js:14284:14)
at /Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/index.js:59304:12
at Object.format (/Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/node_modules/prettier/index.js:59324:12)
at prettierFormat (/Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/src/formatFileContent.js:68:19)
at /Users/sam/vytal/partner-app/node_modules/swagger-typescript-api/src/formatFileContent.js:74:50 {
loc: { start: { line: 1740, column: 2 } },
codeFrame: '\x1B[0m \x1B[90m 1738 |\x1B[39m \x1B[90m * @request GET:/api/3/ContainerHistory/GetUserContainers\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 1739 |\x1B[39m \x1B[90m */\x1B[39m\x1B[0m\n' +
'\x1B[0m\x1B[31m\x1B[1m>\x1B[22m\x1B[39m\x1B[90m 1740 |\x1B[39m \x1B[35m3\x1B[39m\x1B[33mContainerHistoryGetUserContainersList\x1B[39m\x1B[33m:\x1B[39m (query\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m { showCounts\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m boolean\x1B[33m,\x1B[39m showActive\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m boolean\x1B[33m,\x1B[39m showSold\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m boolean\x1B[33m,\x1B[39m showReturned\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m boolean\x1B[33m,\x1B[39m skip\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m number\x1B[33m,\x1B[39m limit\x1B[33m?\x1B[39m\x1B[33m:\x1B[39m number }\x1B[33m,\x1B[39m params\x1B[33m:\x1B[39m \x1B[33mRequestParams\x1B[39m \x1B[33m=\x1B[39m {}) \x1B[33m=>\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m |\x1B[39m \x1B[31m\x1B[1m^\x1B[22m\x1B[39m\x1B[0m\n' +
'\x1B[0m \x1B[90m 1741 |\x1B[39m \x1B[36mthis\x1B[39m\x1B[33m.\x1B[39mrequest\x1B[33m<\x1B[39m\x1B[33mVytalConsumerAppApiControllersV2ContainerHistoryControllerContainerHistoryResponse\x1B[39m\x1B[33m,\x1B[39m any\x1B[33m>\x1B[39m({\x1B[0m\n' +
'\x1B[0m \x1B[90m 1742 |\x1B[39m path\x1B[33m:\x1B[39m \x1B[32m`/api/3/ContainerHistory/GetUserContainers`\x1B[39m\x1B[33m,\x1B[39m\x1B[0m\n' +
"\x1B[0m \x1B[90m 1743 |\x1B[39m method\x1B[33m:\x1B[39m \x1B[32m'GET'\x1B[39m\x1B[33m,\x1B[39m\x1B[0m"
}
```

This is the command I'm using to run the script:

```
yarn swagger-typescript-api -p https://xxx.json -o ./src/helpers/ -n apiGenerated.ts"
```

After examining the `swagger-typescript-api` options, I don't see anything that would fix this. Any idea how to resolve this?

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.