swagger-api / swagger-api/swagger-codegen
java.lang.IllegalArgumentException: Invalid format Exception when using org.joda.time.DateTime
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
After getting below mentioned response from the API using the swagger-codegen generated JAR file.The GSON library is generating below mentioned Exception.
API Response for reference:
[
{
"SampleTime": "2018-09-25T22:25:07.036+00:00"
},
{
"SampleTime": "2018-09-26T02:44:20+00:00"
},
{
"SampleTime": "2018-09-26T16:20:57.289+00:00"
}
]
Exception for reference:
java.lang.IllegalArgumentException: Invalid format: "2018-09-26T02:44:20+00:00" is malformed at "+00:00"
org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:945)
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
com.google.gson.Gson.fromJson(Gson.java:888)
com.google.gson.Gson.fromJson(Gson.java:853)
com.google.gson.Gson.fromJson(Gson.java:802)
io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:171)
io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:283)
io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:707)
io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
Swagger-codegen version
swagger-codegen-cli-2.2.1.jar
Swagger declaration file content or url
Command line used for generation
java.exe -jar swagger-codegen-cli-2.2.1.jar generate -i swagger.json -l java -o C:\Jar --import-mappings Object=java.lang.Object
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
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 swagger-codegen-cli-2.2.1.jar generation command and the reported Gson parsing stack trace, using the two SampleTime values as the reproduction input. Check how the generated Java client handles these timestamps; done means both response formats can be parsed without the reported IllegalArgumentException.
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
- Needs clarification
- Newbie friendliness
- 25/100