swagger-codegen generates APIControllers based on pathname.
Let's say you have these paths on your swagger.yaml:
/pet/findByStatus: /user/{userId} /store/inventory
Then codegen is going to generate PetAPIController, UserAPIController, StoreApiController.
But my API is something like:
/private/pet/findByStatus: /private/user/{userId} /public/store/inventory
so I end up with two main controllers: PrivateAPI and PublicAPI
Is there any way to avoid this? Using tags, or just with the second path word.
Thanks
Swagger Codegen's spring
generator has the useTags
option (true/false) that tells the codegen to use tags to name the interface and controller classes. When using the Swagger Codegen Maven plugin, you can specify this option in the <configOptions>
section:
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
<language>spring</language>
<configOptions>
<useTags>true</useTags>
</configOptions>
</configuration>
When useTags
= true
, operations with a specific tag, say admin
, will be placed into AdminApi.java and AdminApiController.java .
Make sure to tag all operations in your API definition appropriately:
paths:
/foo:
get:
tags: # <-----
- admin
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.