swagger-api / swagger-api/swagger-codegen
[Urgent] [Help wanted]JacksonJSONProvider ObjectMapper() class generated through swagger-codegen is not able to deserialize the OffsetDateTime into ISO8601 format.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
JacksonJSONProvider ObjectMapper() class generated through swagger-codegen is not able to deserialize the OffsetDateTime into ISO8601 format.
@Provider
@Produces({MediaType.APPLICATION_JSON})
public class JacksonJsonProvider extends JacksonJaxbJsonProvider {
public JacksonJsonProvider() {
ObjectMapper objectMapper = new ObjectMapper()
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.registerModule(new JavaTimeModule())
// .findAndRegisterModules()
.setDateFormat(new RFC3339DateFormat());
setMapper(objectMapper);
}
}
Swagger-codegen version
1.5.18
Swagger declaration file content or url
java -jar swagger-codegen-cli.jar generate -i $file -c ${SWAGGER_CONFIG} -DdateLibrary=java8 -l jaxrs -o ${SWAGGER_OUTPUT}
Command line used for generation
swagger-generation-v1.sh
Actual Output
"offset": {
"totalSeconds": 0,
"id": "Z",
"rules": {
"transitions": [],
"transitionRules": [],
"fixedOffset": true
}
},
"dayOfYear": 312,
"year": 2006,
"month": "NOVEMBER",
"monthValue": 11,
"dayOfMonth": 8,
"hour": 15,
"minute": 57,
"second": 0,
"nano": 0,
"dayOfWeek": "WEDNESDAY"
Expected Output
"2006-11-08T21:27:00.000+0000"
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 with the generated JacksonJsonProvider class and the swagger-generation-v1.sh command using Swagger Codegen 1.5.18 and -DdateLibrary=java8. Reproduce the OffsetDateTime handling with the shown ObjectMapper configuration, then compare the generated JSON with the expected ISO8601 value. Done means the generated provider serializes or deserializes OffsetDateTime in the expected format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100