swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.91k stars 6.03k forks source link

[Jaxrs]Is it possible to use part of the tag value? #8415

Open richada opened 6 years ago

richada commented 6 years ago

Hi Team,

I am integrating my project with the codegen tool. It is all good but for one feature, I am stuck and trying to seek help from you.

Background Description: The swagger currently scans my entire project and put everything inside one single json file. However, my basic CRUD methods share the same method name and thus the OperationId in json is the same for all of them, which I believe is a violation against the rules as operationId cannot be the same? (Some online editors like restlet reports this as an error). Also, When testing generation with the json, they are all re-named with a counter number. My current solution is trying to rename my methods with a pattern "get_Foo", so that the operationId will be unique.

Actual question: The operationId (get_Foo) will goes to {{nickname}} in the api.mustache, is it possible to take only "get" instead of the entire string?

Thanks for the time reading this.

richada commented 6 years ago

One alternative solution I achieve is to use customised parser and create an x-field. Afterwards, use {{#VendorExtensions}} instead of {{nickname}} to generate the method name. I am not sure whether this is the only solution I could approach with the case.