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.

Support "format" in ApiModelProperty and correct default Date format

See original GitHub issue

See specification for Data Types

Primitives have an optional modifier property: format

This would be very usefull for Date as it will be transported as “string”. So please add format property to ApiModelProperty.

Example class:

class Event {
    @ApiModelProperty({ format: 'password' })
    mySecret: string;

    @ApiModelProperty()
    myDate: Date;
}

should generate:

"definitions": {
  "Event": { 
    "type": "object",
    "properties": {
      "mySecret": { "type": "string", "format": "password" },
      "myDate": { "type": "string", "format": "date-time" } // Date schould get this format by default
    }
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
AlexFreemcommented, Jan 31, 2019

@xmlking try to use

@ApiModelProperty({type: 'string', format: 'date-time'}) dateField: Date;

4reactions
xmlkingcommented, Nov 26, 2018

@ApiModelProperty({ type: Date, format: 'date-time'}) still generate Object !

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - swagger date field vs date-time field - Stack Overflow
Date is that it's really a date-time, and swagger correctly ... Then, when scanning, swagger will detect this as a date formatted string....
Read more >
ApiModelProperty (swagger-annotations 1.5.0 API)
A sample value for the property. ... To set a minimum/maximum value, use the same format for range but use "infinity" or "-infinity"...
Read more >
Setting Example and Description with Swagger - Baeldung
If our models contain fields like date, time, or price, an exact value format is necessary. Defining the format beforehand makes the development ......
Read more >
Default Date Format? - ServiceNow Community
Hi Shoeb,. If you want different different time formats for 2 different profiles then you can go to Profile A under Self Service...
Read more >
OpenAPI 3 Library for spring-boot
To default set parameters to form data when specifying api to accept form data. 5.2. swagger-ui properties. The support of the swagger-ui ...
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