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.98k stars 6.03k forks source link

Identify specific operations #6787

Open RaulBarranquero opened 7 years ago

RaulBarranquero commented 7 years ago

Hello, for latest version we are using a custom mustache template to generate code for rest controller, using Swagget-Code-gen we identify GET, POST, etc with:"isRestfulCreate","isRestfulIndex","isRestfulShow" variables.

Using the command below: java -jar swagger-codegen-cli.jar generate -i customerManagement_v2.1.1.json -l spring -o samples/server/CustomerManager -t ../Templates/JavaSpring/ -DdateLibrary=joda

Swagger-Code-Gen mustache variables (isRestfulCreate,isRestfulIndex,isRestfulShow,etc) are not loading propertyly for this operations:

0) -Operation: GET /customers/{customerId}/creditInfo -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

1) -Operation: GET /accounts/{accountId}/productOrders -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

2) -Operation:POST /accounts/{accountId}/productOrders -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

3) -Operation:GET /accounts/{accountId}/productOrders/{orderId} -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

4) -Operation: PUT /accounts/{accountId}/productOrders/{orderId} -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

5) -Operation: GET /accounts/{accountId}/productOrders/{orderId}/status -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

6) -Operation: PUT /accounts/{accountId}/productOrders/{orderId}/status -Variables Resolved: isRestfulShow=false,isRestfulIndex=false,isRestfulCreate=false,isRestfulUpdate=false,isRestfulDestroy=false

As you can see all swagger code gen resolved all operations with false. We need to identify this suboperations of GET or PUT with new variables for aply custom templates. Is there any way of identify this operations from swagger code gen correctly and generate our own custom code in mustache via {{>subGet}} or {{>subPut}}.

THX for this great tool!!

manwithsteelnerves commented 6 years ago

@RaulBarranquero Did you find a solution? I see the same behavior as well.

morhei commented 3 years ago

I have the same problem, which yields problems when I try to autogenerate testcases.