You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have defined custom Mustache templates to generate a Java application using a swagger file and by extending the AbstractJavaCodegen class in a custom Codegen generator.
I aim to generate a custom ServiceImpl.java file and include conditional logic within the method body based on the operationId. The operationId could be following: "createOrder", "patchOrder", "deleteOrder", "retrieveOrder", or "listOrder" defined in a swagger specification file (all the above operationId's are present in the swagger json).
I would like the corresponding logic for each operation to be included, while skipping irrelevant logic for other operations.
For example, here is the structure of my template:
{{#operations}}
public class {{classname}}ServiceImpl implements {{classname}}Service {
{{#operation}}
@ Override
public ResponseEntity<{{>returnTypes}}> {{operationId}}({{#allParams}}{{>optionalDataType}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) {
{{#create-operation}}
// Logic for createOrder operation and skip other operation's logic
{{/create-operation}}
{{#patch-operation}}
// Logic for patchOrder operation and skip other operation's logic
{{/patch-operation}}
{{#delete-operation}}
// Logic for deleteOrder operation and skip other operation's logic
{{/delete-operation}}
{{#retrieve-operation}}
// Logic for retrieveOrder operation and skip other operation's logic
{{/retrieve-operation}}
{{#list-operation}}
// Logic for listOrder operation and skip other operation's logic
{{/list-operation}}
return new ResponseEntity<>(HttpStatus.OK);
}
{{/operation}}
I have tried to preprocess the data in custom codegen before passing it to the Mustache template, but it did not work as per my above requirement.
I believe this is not achievable using conditional logic in the Mustache template, specifically to ensure that only the relevant operation logic is included for each method based on the operationId
It would be great, if there is a way to do it.
The text was updated successfully, but these errors were encountered:
I have defined custom Mustache templates to generate a Java application using a swagger file and by extending the AbstractJavaCodegen class in a custom Codegen generator.
I aim to generate a custom ServiceImpl.java file and include conditional logic within the method body based on the operationId.
The operationId could be following: "createOrder", "patchOrder", "deleteOrder", "retrieveOrder", or "listOrder" defined in a swagger specification file (all the above operationId's are present in the swagger json).
I would like the corresponding logic for each operation to be included, while skipping irrelevant logic for other operations.
For example, here is the structure of my template:
I have tried to preprocess the data in custom codegen before passing it to the Mustache template, but it did not work as per my above requirement.
I believe this is not achievable using conditional logic in the Mustache template, specifically to ensure that only the relevant operation logic is included for each method based on the operationId
It would be great, if there is a way to do it.
The text was updated successfully, but these errors were encountered: