swagger-api / swagger-api/swagger-codegen
[JAVA] OffsetDateTime, LocalDateTime parameter format broken usingGet API
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I want send LocalDateTime parameter using get method.
DateTimeFormatter formater = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
LocalDateTime localDateTime = LocalDateTime.parse("2018-02-21'T'18:11:00.000Z", formatter);
but, swagger generate code like this.
public String parameterToString(Object param) {
if (param == null) {
return "";
} else if (param instanceof Date) {
return formatDatetime((Date) param);
} else if (param instanceof Collection) {
StringBuilder b = new StringBuilder();
for (Object o : (Collection)param) {
if (b.length() > 0) {
b.append(",");
}
b.append(String.valueOf(o));
}
return b.toString();
} else { //LocalDateTime and OffsetDateTIme task here!
return String.valueOf(param);
}
}
Expected : 2018-02-21'T'18:11:00.000Z
Actual : 2018-02-21'T'18:11
Swagger-codegen version
2.2.3
How can I catch instanceOf LocalDateTime and OffsetDateTime?
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 at the generated Java parameterToString(Object param) method and trace the template or generator entry point that produces it. Check how LocalDateTime and OffsetDateTime are serialized for GET parameters, then verify that the output preserves the expected timestamp format rather than truncating it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100