swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.47k stars 8.96k forks source link

Format:date with example renders time in addition to date #5215

Open ilya-spv opened 5 years ago

ilya-spv commented 5 years ago

Q&A (please complete the following information)

Content & configuration

I use a visual studio extension to render things on the fly (openapi-designer) and have checked that it uses the latest version of swagger-ui

Example Swagger/OpenAPI definition:

startDate:
   type: string
   format: date
   example: 2018-12-25

Describe the bug you're encountering

There was recently a pull request to make automatic example if it is not present. That works fine, but when I have my own example, then the rendered date for some reason includes timestamp as well:

"startDate": "2018-12-25T00:00:00.000Z",

To reproduce...

  1. Render YAML with type: string and format: date
  2. Open an example value in the browser

Expected behavior

Expected to see only date in example

"startDate": "2018-12-25",
shockey commented 5 years ago

Indeed, the specification is pretty clear on this.