swagger-api / swagger-api/swagger-codegen
[codegen][JAVA] Missing @pattern in generated code for field with format date-time
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
If you try to define field with type string and with format: date-time like below the generator does not create any @pattern annotation. (target is "somehow" limit possible values of field with format date-time)
Swagger-codegen version
2.2.2
Input for codegen (YAML)
startDate:
type: string
format: date-time
pattern: '^(199\d{1}|20\d{2})'
Output from codegen
@JsonProperty("startDate")
@NotNull
private DateTime startDate = null;
Suggest a fix/enhancement
Codegen adds pattern (or another) annotation as ability to limit range of values in date-time format.
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
Reproduce the issue with the provided YAML input and inspect the Java code-generation path for string fields using the date-time format. Confirm the generated output currently omits the supplied pattern, then verify that the generated Java field includes an annotation or equivalent constraint preserving that pattern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100