swagger-api / swagger-api/swagger-codegen
spring: add annotation if property name endsWith("FOO")>
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Swagger-codegen version
2.2.2-SNAPSHOT
Help/feature request
I'm writing a new generator for Spring and JSON-API. I'm using the https://github.com/jasminb/jsonapi-converter to generate JSON-API from our models.
JSON-API requires an ID in the payload, the jsonapi-converter uses its @Id annotation to specify which field should be used as the ID in the payload.
Currently I have this hacked solution in place:
if( property.baseName.endsWith("FOO") ) {
property.example = "true";
}
{{#example}}@Id{{/example}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};
Is there a better way to do this?
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Spring generator template shown in the issue and how property.baseName and property.example are populated. Determine whether the generator can conditionally emit @Id for names ending in "FOO" without the example-value hack; done means the annotation is generated for the intended properties while other fields remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend-api-design, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100