teamcarma / swagger-jaxrs-doclet

This fork is no longer actively maintained, please switch to https://github.com/conorroche/swagger-doclet
Apache License 2.0
81 stars 38 forks source link

Map java.util.Calendar in model? #130

Closed skasten closed 8 years ago

skasten commented 8 years ago

Hello,

we provide services which are JAX-WS and JAX-RS enabled. One of our response classes holds a "timestamp" attribute, which is from the java.util.Calendar type. This is needed for the JAX-WS mapping.

We use Jersey for JAX-RS and it has no problem with the Calendar, it gives back a long-timestamp in the JSON-result.

The problem is that the swagger-jaxrs-doclet treats the Calendar as part of the result model. So in the model there is no simple '"timestamp" : long', it shows all fields of the Calendar class.

Is there any way to fix it via the options?

Best Regards, Sven

skasten commented 8 years ago

Here is an example of the model from the doclet:

[
  {
    "timestamp": {
      "fields": [
        {}
      ],
      "isSet": [
        {}
      ],
      "time": "2016-01-13T08:01:28.481Z",
      "isTimeSet": true,
      "areFieldsSet": true,
      "lenient": true,
      "zone": {
        "ID": "string",
        "rawOffset": 0,
        "iD": "string",
        "displayName": "string",
        "dSTSavings": 0
      },
      "firstDayOfWeek": 0,
      "minimalDaysInFirstWeek": 0,
      "nextStamp": 0,
      "serialVersionOnStream": 0,
      "timeInMillis": 0,
      "set": true,
      "calendarType": "string",
      "timeZone": {
        "ID": "string",
        "rawOffset": 0,
        "iD": "string",
        "displayName": "string",
        "dSTSavings": 0
      },
      "weekDateSupported": true,
      "weekYear": 0,
      "weekDate": {},
      "weeksInWeekYear": 0
    },
    "anotherFieldWithValue": 0
  }
]
skasten commented 8 years ago

And here is the real result from the service:

[
  {
    "timestamp": 1420211196000,
    "anotherFieldWithValue": 2
  }
]
conorroche commented 8 years ago

@skasten ive just committed a fix to support calendar, note it by default is treated as a string with format date-time, if you want it to be treated as a long then there is a new option you can use -longTypePrefixes java.util.Calendar

conorroche commented 8 years ago

closing assume fixed as havent head back