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.

Fields of format time or date default to "string"

See original GitHub issue
Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0.1
Which Swagger-Editor version? Online as of date of post
How did you install Swagger-Editor? Online
Which broswer & version? Chrome 63.0.3239.84
Which operating system? Windows 10

Demonstration API definition

https://gist.github.com/nkolban/fd6aa143ed10af5446fd2950c849e503

Configuration (browser query string, constructor, config.yaml)

Not applicable

Expected Behavior

Here is the example model produced for the operation:

{
  "action": "start",
  "params": {
    "input1": {
      "decimalField": 0,
      "boField": {
        "fieldA": "string",
        "fileB": 0,
        "fieldC": true,
        "anotherBO": {
          "x": "string",
          "y": "string",
          "z": "string"
        },
        "fieldD": [
          "string"
        ]
      },
      "booleanField": true,
      "integerField": 0,
      "timeField": "string",
      "dateField": "string",
      "anyField": "string",
      "stringField": "string"
    }
  }
}

Note the fields called timeField and dateField. These are defined in the JSON Schema as:

       timeField:
          type: string
          format: time
        dateField:
          type: string
          format: date

What I was expecting was that the example fields would be generated as ISO 8601 format strings and not the word string.

For example,

...
      "timeField": "2017-12-09T18:14:01Z",
      "dateField": "2017-12-09",
...

Current Behavior

See above.

Possible Solution

Detect that the field is a date or time format field and generate a default ISO 8601 string based on current time.

Context

Am generating OpenAPI descriptions by interrogating existing servers. Goal is for end user to query server which generates OpenAPI which is then copied into Swagger editor for testing. Generated sample data for the payload of the request should not be the word string.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nkolbancommented, Dec 12, 2017

Thank you sir. I had misread the time property … what I mean to use was date-time which does appear to be exposed by OAS.

0reactions
opendbacommented, Dec 3, 2019

Thank you very much. Everything works as expected!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date and Time Formats - IBM
Format Specifier Format Example %m/%d/%Y mm/dd/yyyy 02/21/2018 %m/%d/%y mm/dd/yy 02/21/18 %d/%m/%Y dd/mm/yyyy 21/02/2018
Read more >
Format a date and time field - Microsoft Support
(Default) Displays date values as numbers and time values as hours, minutes, and seconds followed by AM or PM. For both types of...
Read more >
Default Date Format - Informatica Documentation
uses a default date format to store and manipulate strings that represent dates. To specify the default date format, enter a date format...
Read more >
Java SimpleDateFormat - Java Date Format - DigitalOcean
DateFormat is used for formatting a date into String based on specific locale that is provided as input. The locale is used for...
Read more >
Global date and time field format
You define default date and time formats globally using system properties. Date format. The glide.sys.date_format property defines the date ...
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