Date type generation inconsistent between object and array

Open
#602 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, openapi
Domain
tooling

Research direction

No source files or tests are identified in the issue. Start by tracing OpenAPI date-format handling for scalar fields and array items in the Java code generator, then compare the generated model types; done means an array of format date generates java.util.List consistently with a scalar date field.

Written by the indexing model from the issue text.

Description

In openapi, if the field defined as date format:

    startDate:
      type: "string"
      format: "date"

Codegen will generate the field as LocalDate in the model.

@JsonProperty("startDate")
public java.time.LocalDate getStartDate() {
    return startDate;
}

But for the array (list) with same definition:

    datelist:
      type: "array"
      items:
        type: "string"
        format: "date"

Codegen will generate field as String List.

@JsonProperty("datelist")
public java.util.List<String> getDatelist() {
    return datelist;
}

We should make it consistent to be list of LocalDate

Dominant language
Java
Stars
49
Forks
25
PR merge metrics
No merged PRs in 30d

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.

More from networknt/light-codegen

All issues in networknt/light-codegen

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.