question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date example show incorrect result

See original GitHub issue

Q&A (please complete the following information)

  • OS: macOS
  • Browser:chrome
  • Version: 78
  • Method of installation: dist assets
  • Swagger-UI version: 3.24.3 and http://editor.swagger.io/
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

 properties:
        checkInDate:
          title: Date in ISO8201 format
          type: string
          format: date
          example: 2019-02-01

Describe the bug you’re encountering

Following the specification i should see correct example in UI "checkInDate": "2019-02-01" but instead i see "checkInDate": {}

In schema block i see: example: OrderedMap {}

Expected behavior

Correct property example in dto object in request body

"checkInDate": "2019-02-01"

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:13
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Zepryitcommented, Oct 26, 2022

For me it seems that the problem only occurs when a $ref is used

paths:
  /pet/{petId}:
    get:
      parameters:
        # does not work
        - $ref: components/parameters/date.yaml
        # does work
        - name: date
          in: query
          schema:
            title: Date
            type: string
            format: date
          examples:
            example1:
              value: 2022-10-12
      responses:
        '200':
          description: successful operation

components/parameters/date.yaml looks like:

name: date-ref
in: query
schema:
  title: Date
  type: string
  format: date
examples:
  example1:
    value: 2022-10-12

1reaction
ivenxucommented, May 28, 2021

You need to add quotes around the example value:

type: string
format: date
example: '2019-02-01'   # <----

Without the quotes, the value is parsed as a YAML timestamp which is a different data type than string.

Quotes solution doesn’t work, please fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert an Incorrect Date Format into a Real Date in Excel
Change an incorrectly formatted input date into the proper date format for Excel This tutorial is ... Here are examples of incorrect short...
Read more >
Javascript date displaying/returning incorrect date
I've hard coded a date string and I'm trying to create a javascript date object. After creating a string from the newly created...
Read more >
Excel "Short Date" format producing incorrect results when
Excel "Short Date" format producing incorrect results when brought in from another spreadsheet · Select File > Options. · Select Advanced in the ......
Read more >
Program to check if a date is valid or not - GeeksforGeeks
Given a date, check if it is valid or not. It may be assumed that the given date is in range from 01/01/1800...
Read more >
Use Excel Data Validation for Entering Dates - Contextures
This example shows two ways to set those dates, and prevent invalid data entry. Type start and end dates in the rules.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found