An example of OpenAPI 3 is based on document here:
https://swagger.io/docs/specification/data-models/data-types/
An optional format modifier serves as a hint at the contents and format of the string. OpenAPI defines the following built-in string formats:
date – full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21
date-time – the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z
BookingNoteRequest:
type: object
properties:
note:
type: string
postedDate:
type: string
format: date
example: '2022-07-01'
postedTime:
type: string
format: date-time
example: '2017-07-21T17:32:28Z'
If the date or date-time format does not follow the standard as defined by RFC 3339, then the format field should be removed and the pattern field added with a regular expression defining the format.
pattern
is useful for documentation UI (like Swagger) end-users because the formatdate
is not explicitly displayed (contrary todate-time
). – Secretion