3

We are using Swagger (1.5.15) to visualize our rest api.

To represent time we use org.joda.LocalTime (can not use java8 time for legacy reasons). The api works as expected with time formatted as "HH:MM:SS", however, swagger shows this as

"LocalTime": {
  "type": "object",
  "properties": {
    "chronology": {
      "$ref": "#/definitions/Chronology"
    },
    "millisOfDay": {
      "type": "integer",
      "format": "int32"
    },
    "hourOfDay": {
      "type": "integer",
      "format": "int32"
    },
...

Which (if I'm not gravely mistaken) means that the problem is not in the Swagger-UI.

We have tried different versions of Swagger together with

@ApiModelProperty(dataType = "org.joda.time.LocalTime", example = "10:11:12")

without luck.

Any help would be greatly appreciated.

  • See if [this answer](https://stackoverflow.com/a/34750537/113116) helps. – Helen Jun 19 '17 at 10:41
  • That answer suggests using org.joda.LocalTime (instead of old java time classes), and that that would fix the problem. However, we still see the problem even though we use the suggested class. – ChristianJohansen Jun 19 '17 at 12:41

1 Answers1

1

I have not resolved the original issue of using joda LocalTime in swagger. However, since the date & time api in java is now (finally) updated as of java 8, the problem was resolved for us when we moved to these instead of using joda time.