Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NancyFx] date field mapped to ZonedDateTime #7024

Closed
craffael opened this issue Nov 22, 2017 · 0 comments
Closed

[NancyFx] date field mapped to ZonedDateTime #7024

craffael opened this issue Nov 22, 2017 · 0 comments

Comments

@craffael
Copy link
Contributor

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.

wing328 pushed a commit that referenced this issue Nov 27, 2017
)

* add support for async routes/endpoints

you can now set --optional-properties async=true to generate
a nancyfx server stub that uses asynchronous programming.

(cherry picked from commit 126869c)

* add nancyfx-petstore-server-async.sh to generate sample of async nancyfx.

* Rename async => asyncServer

* update bin/nancyfx-petstore-server-async.sh

* rename async => asyncServer in api.mustache + small bugfix

* run ./bin/nancyfx-petstore-server.sh and ./bin/nancyfx-petstore-server-async.sh

* remove additional new line in api.mustache + add space after if

* run ./bin/nancyfx-petstore-server.sh and ./bin/nancyfx-petstore-server-async.sh

* Map `date` fields to LocalDate c# type + add a JsonConverter for LocalDate.
@wing328 wing328 closed this as completed Nov 27, 2017
@wing328 wing328 added this to the v2.3.0 milestone Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants