Hi and thanks for a cool product!
I have a related problem.
Using Jersey + Spring.
I'm about to upgrader from Swagger 1.0.1 to 1.2.1 to get rid of extending JavaHelp / custom listing classes.
But after upgrading I get the following errors when listing all api's. (Swagger "frontpage")
2013-03-13 10:14:56,733 INFO com.wordnik.swagger.jsonschema.ApiModelParser : Class no.tine.api.jersey.DateTimeParam is not annotated with a @XmlRootElement annotation, using DateTimeParam
2013-03-13 10:14:56,735 INFO com.wordnik.swagger.jsonschema.ApiModelParser : Class java.util.Date is not annotated with a @XmlRootElement annotation, using Date
2013-03-13 10:14:56,735 INFO com.wordnik.swagger.jsonschema.ApiModelParser : Class java.util.Date is not annotated with a @XmlRootElement annotation, using Date
2013-03-13 10:14:56,736 ERROR com.wordnik.swagger.jaxrs.HelpApi : Unable to load model documentation for no.tine.api.jersey.DateTimeParam
java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at com.wordnik.swagger.core.ApiPropertiesReader$.getDataType(SpecReader.scala:91)
at com.wordnik.swagger.jsonschema.ApiModelParser.parsePropertyAnnotations(SwaggerJsonSchemaProvider.scala:150)
The DateTimeParam class looks like this
public class DateTimeParam extends AbstractParam<DateTime> {
public DateTimeParam(String param) {
super(param);
}
protected DateTime parse(String param) {
return DateConverter.convertToDateTime(param);
}
public Date getValueAsDate() {
return getValue() == null ? null : getValue().toDate();
}
public static Date getValueAsDate(DateTimeParam dateTimeParam) {
return dateTimeParam == null ? null : dateTimeParam.getValueAsDate();
}
}
This class converts String inputs to joda-time DateTime instances for further use in our ReST api.
Examples of use:
public List<ResultFeedback> historical(@QueryParam("ownerId") Long ownerId,
@ApiParam(value = "YYYY-MM-DD") @QueryParam("fromDate") DateTimeParam fromDate) {
public Response findEvents(
@PathParam("ownerId") Long ownerId,
@PathParam("registrationType") RegistrationTypeParam registrationType,
@ApiParam(required = false) @QueryParam("status") AnimalExt.EnrollmentStatusCombination esc,
@ApiParam(required = false) @QueryParam("unenrollmentDate") DateTimeParam unenrollmentDate,
@ApiParam(required = false) @QueryParam("fromDate") DateTimeParam fromDate,
@HeaderParam("If-Modified-Since") String modified) {
This did not occur when running version 1.0.1 of Swagger.
However, the API listing and the invocation of the the methods all seems to work correctly, but given that this problem is logged as "ERROR",
I am not willing to push this into production.
This problem occurs for all methods using a parameter whose class is using generics.
public class RegistrationTypeParam extends AbstractParam<Registration.Type> {
public class RegistrationParam extends AbstractJsonParam<String> {
public class ClassParam extends AbstractParam<Class> {
There is also a problem with Enums
2013-03-13 10:14:56,776 ERROR com.wordnik.swagger.jaxrs.HelpApi : Skipping model no.tine.api.internal.v1.core.domain.ext.AnimalExt$EnrollmentStatusCombination. Could not load the model.
2013-03-13 10:14:57,037 ERROR com.wordnik.swagger.jaxrs.HelpApi : Skipping model no.tine.api.internal.v1.i18n.I18n. Could not load the model.
2013-03-13 10:14:57,037 ERROR com.wordnik.swagger.jaxrs.HelpApi : Skipping model no.tine.api.user.domain.Feature$Type. Could not load the model.
Examples
Enum defined in own file
public enum I18n {
ClawTrimmingNotification("i18n.clawTrimming.clawNotification"),
ClawTrimmingCodes("i18n.clawTrimming.code"),
Breed("i18n.breed"),
UnenrollmentReason("i18n.unenrollment.reason"),
UnenrollmentCause("i18n.unenrollment.cause"),
EnrollmentReason("i18n.enrollment.reason"),
HealthCodes("i18n.healthRecording.healthCodes"),
HealthRecording("i18n.healthRecording"),
TreatmentCodes("i18n.healthRecording.treatmentCodes"),
TreatedBy("i18n.treatedBy");
public class AnimalExt implements Serializable {
.
.
.
.
public static enum EnrollmentStatusCombination implements DomainEnum {
All,
AllEnrolled,
OnlyUnenrolled,
OnlyAwaitingUnenrollment
}
.
.
}
This problem is also new after the upgrade.
I have no Scale experience what so ever, so hopefully you guys can have a look at it.
Is there a bug tracker where I can register this as a bug?
regards
Rune