Skip to content

[NancyFx] date field mapped to ZonedDateTime #7024

@craffael

Description

@craffael
Description

If a definition in a swagger spec contains a field with format: date, the corresponding c# field is of type NodaTime.ZonedDateTime. This is wrong as a date field itself does not carry any time/time-zone information. One particular problem with this is that the corresponding field is serialized wrongly as a RFC3339 full-time instead of a full-date.

Swagger-codegen version

2.3.0-Snapshot

Swagger declaration file content or url
swagger: "2.0"
info:
  version: "1.0.0"
  title: Demo


paths:
  /foo:
    get:
      summary: "foo"
      responses:
        200:
          description: successful
          schema:
            $ref: '#/definitions/bar'
          
definitions:
  bar:
    type: object
    properties:
      createdOn:
        type: string
        format: date
Command line used for generation
generate -i dummy.yaml -o . -l nancyfx --additional-properties packageContext=v1,interfacePrefix=I,useDateTimeOffset=true
Steps to reproduce

Generate the nancy client with the above command line and open Bar.cs

Related issues/PRs

There is no related issue that I'm aware of.

Suggest a fix/enhancement

Use NodaTime.LocalDate instead and add a Nancy.Json.JavaScriptPrimitiveConverter that uses the RFC3339 full-date pattern.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions