swagger-api / swagger-api/swagger-codegen

Spring-MVC: Date and Date-Time format when returning a JSON

Open
#1,275 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature Server: Java
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm having an issue close to this one #1235..

The problem is that when you return a Date format, the format is unix-time.. I found a way to override the format.. You can use this:

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'")
private Date sessionStart = null;

The thing is that I don't want to add this after my files are generated.. So, can you tell me where the files in the model are generated such that I'll be able to add this line depending on the type from the json file..

Thanks

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

Start by tracing the Spring-MVC model-generation templates and the JSON type information used for generated model fields. Confirm how Date and date-time properties are currently rendered, then define the expected generated annotation behavior and verify it with the relevant generator tests, if present.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, json, spring
Domain
backend, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.