OpenAPITools / OpenAPITools/openapi-generator

enum_class_templates,0-based index

Open
#16,783 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

I want use my own templement to generate kotin enum class:
{{#gson}}
@SerializedName(value = {{#lambda.doublequote}}{{{@index}}}{{/lambda.doublequote}})
{{/gson}}

I want the SerializedName value to be an increasing string starting from 0。But the @index not work。
In the doc:https://openapi-generator.tech/docs/templating . I find that : If you'd like a 1-based index in your array traversal, you can use {{-index}}。
But what should i do if i want a 0-based index?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the templating documentation and the supplied Kotlin enum template, then generate an enum using the shown @index expression. Compare the generated SerializedName values with the requested sequence; done means the 0-based behavior is clarified or the documented template usage is corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.