swagger-api / swagger-api/swagger-codegen

[Android] Client doesn't call setDateFormat() on GsonBuilder object correctly

Open
#3,590 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Android help wanted Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I get ApiException when Swagger tries to retrieve the following JSON:
{"apiVersion":1,"providerID":9999999999,"timeStamp":"2016-08-15T14:38:36.172Z"}

The root cause is that JsonUtil.java calls

gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

instead of calling it with single quotes around the "Z"

gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

2.0
Swagger declaration file content or url
Command line used for generation
Steps to reproduce

Specify the format of a yaml field to "date-time"

Related issues
Suggest a Fix

Add single quotes around the "Z" character in the String argument to gsonBuilder.setDateFormat()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open JsonUtil.java and inspect the gsonBuilder.setDateFormat() call used for fields formatted as "date-time". Reproduce the issue with the supplied JSON and a date-time field, then verify that the generated Android client handles the trailing Z timestamp correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.