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

NPE from missing model id when encountering @XmlTransient class #39

Closed TuomasKiviaho closed 9 years ago

TuomasKiviaho commented 9 years ago

ApiModelParser.parseModel might a null modelId from translator but at this point nothing happens. Next pass via alreadyStoredType causes NPE at location seen below.

This was caused by @XmlTransient class that yields to OptionalName{status=IGNORED, name=null} which is translated as null modelId. I am using this class as a subresource (#38) so it shouldn't just be ignored.

[ERROR] java.lang.NullPointerException
[ERROR] at com.carma.swagger.doclet.parser.ApiModelParser$1.apply(ApiModelParser.java:868)
[ERROR] at com.carma.swagger.doclet.parser.ApiModelParser$1.apply(ApiModelParser.java:865)
[ERROR] at com.google.common.collect.Iterators$7.computeNext(Iterators.java:702)
[ERROR] at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
[ERROR] at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
[ERROR] at com.google.common.collect.Iterators.size(Iterators.java:183)
[ERROR] at com.google.common.collect.Collections2$FilteredCollection.size(Collections2.java:254)
[ERROR] at com.carma.swagger.doclet.parser.ApiModelParser.alreadyStoredType(ApiModelParser.java:865)
[ERROR] at com.carma.swagger.doclet.parser.ApiModelParser.parseModel(ApiModelParser.java:153)
[ERROR] at com.carma.swagger.doclet.parser.ApiModelParser.parseNestedModels(ApiModelParser.java:804)
[ERROR] at com.carma.swagger.doclet.parser.ApiModelParser.parseModel(ApiModelParser.java:262)
[ERROR] at com.carma.swagger.doclet.parser.ApiModelParser.parse(ApiModelParser.java:128)
[ERROR] at com.carma.swagger.doclet.parser.ApiMethodParser.parse(ApiMethodParser.java:235)
[ERROR] at com.carma.swagger.doclet.parser.CrossClassApiParser.parse(CrossClassApiParser.java:133)
[ERROR] at com.carma.swagger.doclet.parser.JaxRsAnnotationParser.run(JaxRsAnnotationParser.java:89)
[ERROR] at com.carma.swagger.doclet.ServiceDoclet.start(ServiceDoclet.java:20)
conorroche commented 9 years ago

have just committed fix for this to the latest 1.0.4-SNAPSHOT

conorroche commented 9 years ago

can you confirm if this issue is resolved for you now?

conorroche commented 9 years ago

closing as i believe this is fixed and have not heard otherwise for a while