acacode / swagger-typescript-api

Generate the API Client for Fetch or Axios from an OpenAPI Specification
MIT License
3.08k stars 338 forks source link

Wrong function name generated for endpoints ending in `nav` #762

Open 0re5ama opened 3 weeks ago

0re5ama commented 3 weeks ago

I am working on a project that uses .NET for the backend and React for the frontend. To generate TypeScript types, I am using the swagger-typescript-api tool. However, I am encountering an inconsistency in the generated function names for certain endpoints.

Endpoints:

/api/something/other
/api/something/nav

For the first endpoint (/api/something/other), the generated functions are named as expected:

otherList
otherCreate
otherDetail

However, for the second endpoint (/api/something/nav), the generated function names are unexpected and inconsistent:

getSomething
postSomething
getSomething2

This issue occurs specifically when the endpoint ends with "nav". And if "nav" is replaced with something else, it works as expected. Command Used:

Here is the command I used to generate the types:

swagger-typescript-api --modular --no-client --axios -p http://localhost:3002/swagger/v1/swagger.json -o ./types/api --clean-output

Expected Behavior:

I expect the function names for the /api/something/nav endpoint to follow the same naming convention as the /api/something/other endpoint, such as:

navList
navCreate
navDetail

Actual Behavior:

The function names for the /api/something/nav endpoint do not follow the expected naming convention and appear as:

getSomething
postSomething
getSomething2

Steps to Reproduce:

Use `swagger-typescript-api` with a Swagger file that includes the above endpoints.
Compare the generated function names for endpoints ending with "`other`" and "`nav`".

Request:

Please investigate why the function names are inconsistent for endpoints ending with "nav" and provide a solution or workaround.