Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when using binary string response type #267

Open
jbaldassari opened this issue Jul 31, 2018 · 0 comments
Open

NPE when using binary string response type #267

jbaldassari opened this issue Jul 31, 2018 · 0 comments

Comments

@jbaldassari
Copy link

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: fge/jackson-coreutils#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant