0

I'm trying to use a mustache file to generate my API using the swagger codegen tool (maven plugin: https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen-maven-plugin) I've created the .mustache file, and I have the following values generated from my .yaml file:

"responses" : [ {
        "code" : "200",
        "message" : "Success"
        },{
        "code" : "500",
        "message" : "Internal server error"
        }]

I'm currently trying to write it in a .mustache file as:

@ApiResponses(value = {
{{#responses}}
@ApiResponse(code={{code}}, message="{{message}}"),
{{/responses}}
})

The problem is I have a trailing comma that causes the compilation to fail once the file is generated. Does anyone know of a way to get rid of the last comma?

user7999116
  • 169
  • 1
  • 9
  • Does this answer your question? [In Mustache templating is there an elegant way of expressing a comma separated list without the trailing comma?](https://stackoverflow.com/q/6114435/113116) – Helen Jan 30 '20 at 08:02
  • I actually used {{-last}}{{/-last}} and it works in my application. I tried to do the same in the mustache online editor (https://mustache.github.io/#demo) and it wouldn't work. – user7999116 Jan 31 '20 at 02:06

0 Answers0