I am trying to generate the server side code using Swagger Editor V 2.10.3. I have specified path in my yaml as countries/{countryName}/states.
When i generate the server code for Spring, it is giving me as the CountryApi and CountryApiController. I would prefer to have it in StateApi and StateAPIController. Is there a way i can have custom controller name while generating the server side code.
Swagger Editor
Version 2.10.3
@srinivas795 likely those endpoints in your spec are tagged with "country" or "Country". To customize it, you will need to change the name of the tags to "State"
Here is an example of tags: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml#L32
a) I have updated the tags to State. it is still generating the code as CountryController.
b) I have moved the Countries to the base path. and had /{countryName}/states as the method path.
With this approach it is generating the code with CountryNameController.
Can you please suggest, how we can get this working
a) have you tried generating the code in a different folder? (some files will not be overwritten when regenerating the code)
Closing this as there's no update.
I ran into this same issue. Generating for "java" would work correctly. Generating for "spring" would not with the same yaml. Half a day later, I tracked down the solution...
SpringCodegen has a class variable named useTags that is set to false by default. In order to set this variable to true, you need to set additional parameters. Once I added "--additional-properties=useTags=true" to the command line, it used the tags as expected. Why the SpringCodegen class allows you to turn tags off and why it would turn them off by default is baffling to me, but it looks like this resolved my issue.
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate --additional-properties=useTags=true -i /c/pathtoyamlfile/swagger.yaml -l spring -o ./tmp
Most helpful comment
I ran into this same issue. Generating for "java" would work correctly. Generating for "spring" would not with the same yaml. Half a day later, I tracked down the solution...
SpringCodegen has a class variable named useTags that is set to false by default. In order to set this variable to true, you need to set additional parameters. Once I added "--additional-properties=useTags=true" to the command line, it used the tags as expected. Why the SpringCodegen class allows you to turn tags off and why it would turn them off by default is baffling to me, but it looks like this resolved my issue.
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate --additional-properties=useTags=true -i /c/pathtoyamlfile/swagger.yaml -l spring -o ./tmp