Skip to content

Default date/time values generate invalid code #6251

@Clockwork-Muse

Description

@Clockwork-Muse

When generating an API with default time values, the defaults are strings, which causes invalid code to be generated.

The following segment:

"time": {
    "type": "string",
    "description": "The end time in ISO8601 (HH:mm:ss) format.",
    "format": "time",
    "default": "24:00:00",
    "example": "13:00:00"
}

generates the following:

public Time? Time { get; set; }

public ScheduledTimeSpan_end()
{
    Time = "24:00:00";
}

... which is a compile error.

repro.zip

.... also, date values don't have any defaults written at all...

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeCsharpPull requests that update .net codehelp wantedIssue caused by core project dependency modules or librarypriority:p2Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 daystype:bugA broken experience

    Type

    Projects

    Status

    New📃

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions