swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
786 stars 531 forks source link

NPE from SwaggerCompatConverter when required is missing from parameter #16

Closed TuomasKiviaho closed 9 years ago

TuomasKiviaho commented 9 years ago

2.0 Spec states that required may be missing and hence the use of unwrapped primitive Boolean as return value of io.swagger.models.apideclaration.Parameter#getParameter. Problem is that com.wordnik.swagger.models.parameters.Parameter takes in primitive and autoboxing fails due to null being present.

java.lang.NullPointerException
    at io.swagger.parser.SwaggerCompatConverter.convertParameter(SwaggerCompatConverter.java:183)
    at io.swagger.parser.SwaggerCompatConverter.convertOperation(SwaggerCompatConverter.java:314)
    at io.swagger.parser.SwaggerCompatConverter.convert(SwaggerCompatConverter.java:454)
    at io.swagger.parser.SwaggerCompatConverter.read(SwaggerCompatConverter.java:111)
    at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:34)
    at com.wordnik.swagger.codegen.Codegen.main(Codegen.java:87)
        ...

swagger-codegen hides this and other exceptions as well (issue swagger-api/swagger-codegen#448)

fehguy commented 9 years ago

thanks, this has been pushed to 1.0.2-SNAPSHOT