swagger-inflector
swagger-inflector copied to clipboard
NPE when using binary string response type
This issue was originally reported here: https://groups.google.com/forum/#!topic/swagger-swaggersocket/j-fJzrDLICQ
I have a similar issue using swagger-inflector v1 and swagger-codegen with okhttp. I have a response section that looks like:
responses:
'200':
schema:
type: string
format: binary
When I send a byte[] response back I see this stack trace:
[ERROR] io.swagger.inflector.schema.SchemaValidator - can't validate model against schema
java.lang.NullPointerException: unhandled token type VALUE_EMBEDDED_OBJECT
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787)
at com.github.fge.jackson.NodeType.getNodeType(NodeType.java:144)
at com.github.fge.jsonschema.processors.data.SchemaContext.<init>(SchemaContext.java:50)
at com.github.fge.jsonschema.processors.validation.InstanceValidator.process(InstanceValidator.java:103)
at com.github.fge.jsonschema.processors.validation.ValidationProcessor.process(ValidationProcessor.java:56)
at com.github.fge.jsonschema.processors.validation.ValidationProcessor.process(ValidationProcessor.java:34)
at com.github.fge.jsonschema.core.processing.ProcessingResult.of(ProcessingResult.java:79)
at com.github.fge.jsonschema.main.JsonSchemaImpl.doValidate(JsonSchemaImpl.java:77)
at com.github.fge.jsonschema.main.JsonSchemaImpl.validate(JsonSchemaImpl.java:100)
at com.github.fge.jsonschema.main.JsonSchemaImpl.validate(JsonSchemaImpl.java:110)
at io.swagger.inflector.schema.SchemaValidator.validate(SchemaValidator.java:32)
at io.swagger.inflector.controllers.SwaggerOperationController.doValidation(SwaggerOperationController.java:808)
at io.swagger.inflector.controllers.SwaggerOperationController.validate(SwaggerOperationController.java:711)
at io.swagger.inflector.controllers.SwaggerOperationController.apply(SwaggerOperationController.java:542)
at io.swagger.inflector.controllers.SwaggerOperationController.apply(SwaggerOperationController.java:89)
On the client side I get:
com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
The client-side error may actually be due to an errant Content-Type: application/json header somewhere. I haven't had time to dig too deeply into that yet, but the schema validation error on the server definitely seems like an issue.
I also came across this related issue: https://github.com/fge/jackson-coreutils/issues/14