networknt / networknt/light-codegen

Date type generation inconsistent between object and array

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

Nobody has claimed this yet.

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

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

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

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.