Open
Description
openapi-typescript version
7.6.1
Node.js version
23.9.0
OS + version
win11
Description
Hey!
It seems that code that generates ApiPath enum incorrectly tries to deduplicate enum identifiers when paths differs on params. This is as well visible when path has multple params of various level of reusing parameter names.
Reproduction
Small open ap spec
{
"openapi": "3.0.4",
"info": { "title": "some api", "version": "1" },
"servers": [ { "url": "uri:some-api" } ],
"paths": {
"/api/block": {
"get": {
"summary": "whatever",
"tags": [ "Block" ],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": { "schema": { "type": "string" } }
}
}
}
}
},
"/api/block/{blockId}": {
"get": {
"summary": "whatever",
"tags": [ "Block" ],
"parameters": [
{ "name": "blockId", "in": "path", "schema": { "type": "string" } }
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": { "schema": { "type": "string" } }
}
}
}
}
}
},
"components": {
"securitySchemes": {
"awesome": {
"type": "oauth2",
"flows": {
"implicit": {
"authorizationUrl": "https://example.com/oauth2/authorize",
"scopes": { "awesome": "Awesome scope" }
}
}
}
}
},
"security": [ { "awesome": [ "awesome" ] } ]
}
command line:
npx openapi-typescript "C:\...\repro.json" -o ./repro.schema.d.ts --make-paths-enum
output:
(...)
export enum ApiPaths {
GetApiBlock = "/api/block",
GetApiBlock = "/api/block/:blockId"
}
Expected result
not have same enum member identifiers
Required
- My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint
)
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)