format date with specific pattern

To format date with specific pattern in OpenAPI, is necessary to include x-field-extra-annotation in yaml.

Example:

creationDate:
  type: string
  format: date
  x-field-extra-annotation: '@com.fasterxml.jackson.annotation.JsonFormat(shape = com.fasterxml.jackson.annotation.JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")'

Is only necessary to change the pattern to adapt it to your needs and recompile.

Source: documentation

For more interesting tutorials & guides just check them HERE.

Leave a Reply

Your email address will not be published. Required fields are marked *