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

ClassCastException while parsing #442

Closed
gionn opened this Issue Apr 19, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@gionn

gionn commented Apr 19, 2017

When I try to parse this api-docs.json.zip, I get a ClassCastException:

java.lang.ClassCastException: java.lang.Double cannot be cast to java.math.BigDecimal
	at io.swagger.models.properties.PropertyBuilder$Processor.mergeNumeric(PropertyBuilder.java:673)
	at io.swagger.models.properties.PropertyBuilder$Processor$6.merge(PropertyBuilder.java:211)
	at io.swagger.models.properties.PropertyBuilder$Processor.build(PropertyBuilder.java:743)
	at io.swagger.models.properties.PropertyBuilder.build(PropertyBuilder.java:42)
	at io.swagger.util.PropertyDeserializer.propertyFromNode(PropertyDeserializer.java:276)
	at io.swagger.util.PropertyDeserializer.deserialize(PropertyDeserializer.java:131)
	at io.swagger.util.PropertyDeserializer.deserialize(PropertyDeserializer.java:38)
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3454)
	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3378)
	at io.swagger.parser.util.SwaggerDeserializer.property(SwaggerDeserializer.java:929)
	at io.swagger.parser.util.SwaggerDeserializer.definition(SwaggerDeserializer.java:702)
	at io.swagger.parser.util.SwaggerDeserializer.definitions(SwaggerDeserializer.java:614)
	at io.swagger.parser.util.SwaggerDeserializer.parseRoot(SwaggerDeserializer.java:110)
	at io.swagger.parser.util.SwaggerDeserializer.deserialize(SwaggerDeserializer.java:36)
	at io.swagger.parser.Swagger20Parser.convertToSwagger(Swagger20Parser.java:128)
	at io.swagger.parser.Swagger20Parser.read(Swagger20Parser.java:97)
	at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:64)
	at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:52)
	at com.liberologico.cloudesire.cmw.test.integration.SwaggerIT.parse(SwaggerIT.java:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
java.lang.ClassCastException: java.lang.Double cannot be cast to java.math.BigDecimal
	at io.swagger.models.properties.PropertyBuilder$Processor.mergeNumeric(PropertyBuilder.java:673)
	at io.swagger.models.properties.PropertyBuilder$Processor$6.merge(PropertyBuilder.java:211)
	at io.swagger.models.properties.PropertyBuilder$Processor.build(PropertyBuilder.java:743)
	at io.swagger.models.properties.PropertyBuilder.build(PropertyBuilder.java:42)
	at io.swagger.util.PropertyDeserializer.propertyFromNode(PropertyDeserializer.java:276)
	at io.swagger.util.PropertyDeserializer.deserialize(PropertyDeserializer.java:131)
	at io.swagger.util.PropertyDeserializer.deserialize(PropertyDeserializer.java:38)
	at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3454)
	at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3378)
	at io.swagger.parser.util.SwaggerDeserializer.property(SwaggerDeserializer.java:929)
	at io.swagger.parser.util.SwaggerDeserializer.definition(SwaggerDeserializer.java:702)
	at io.swagger.parser.util.SwaggerDeserializer.definitions(SwaggerDeserializer.java:614)
	at io.swagger.parser.util.SwaggerDeserializer.parseRoot(SwaggerDeserializer.java:110)
	at io.swagger.parser.util.SwaggerDeserializer.deserialize(SwaggerDeserializer.java:36)
	at io.swagger.parser.Swagger20Parser.convertToSwagger(Swagger20Parser.java:128)
	at io.swagger.parser.Swagger20Parser.read(Swagger20Parser.java:97)
	at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:72)
	at io.swagger.parser.SwaggerParser.read(SwaggerParser.java:52)
	at com.liberologico.cloudesire.cmw.test.integration.SwaggerIT.parse(SwaggerIT.java:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
@webron

This comment has been minimized.

Member

webron commented Apr 19, 2017

Haven't tested it, but you have:

        "trialLength": {
          "type": "integer",
          "format": "int32",
          "minimum": 1.0,
          "exclusiveMinimum": false
        }

Which is... meh. Should be:

        "trialLength": {
          "type": "integer",
          "format": "int32",
          "minimum": 1,
          "exclusiveMinimum": false
        }

There's at least one other occurence of that in the spec. Try fixing those and parsing again.

@gionn

This comment has been minimized.

gionn commented Apr 19, 2017

Fixed two of them, can't find any other reference to non-integers in spec. Problem still there.

Forgot to mention that the spec is generated via latest master of https://github.com/springfox/springfox, I will report upstream any findings if needed.

Thanks!

@webron

This comment has been minimized.

Member

webron commented Apr 19, 2017

It's likely the issue is with the parser, just need to spot the location.

@fehguy

This comment has been minimized.

Contributor

fehguy commented Apr 19, 2017

You have conflicting versions of swagger-core and swagger-parser. Please report your dependencies here and it should be obvious

@gionn

This comment has been minimized.

gionn commented Apr 20, 2017

You were right @fehguy, I got swagger 1.5.12 as a transitive dep after updating springfox, now I have updated swagger-parser from 1.0.24 to 1.0.27 and parsing is fine.

Thanks guys!

[INFO] +- io.springfox:springfox-swagger2:jar:2.7.0-SNAPSHOT:compile
[INFO] |  +- io.swagger:swagger-annotations:jar:1.5.12:compile
[INFO] |  +- io.swagger:swagger-models:jar:1.5.12:compile
[INFO] |  |  \- (io.swagger:swagger-annotations:jar:1.5.12:compile - omitted for duplicate)
[INFO] |  +- io.springfox:springfox-swagger-common:jar:2.7.0-SNAPSHOT:compile
[INFO] |  |  +- (io.swagger:swagger-annotations:jar:1.5.12:compile - omitted for duplicate)
[INFO] |  |  +- (io.swagger:swagger-models:jar:1.5.12:compile - omitted for duplicate)
[INFO] +- io.swagger:swagger-parser:jar:1.0.24:test
[INFO] |  +- io.swagger:swagger-core:jar:1.5.10:test
[INFO] |  |  +- (io.swagger:swagger-models:jar:1.5.10:test - omitted for conflict with 1.5.12)
[INFO] +- io.springfox:springfox-swagger2:jar:2.7.0-SNAPSHOT:compile
[INFO] |  +- io.swagger:swagger-annotations:jar:1.5.12:compile
[INFO] |  +- io.swagger:swagger-models:jar:1.5.12:compile
[INFO] |  |  \- (io.swagger:swagger-annotations:jar:1.5.12:compile - omitted for duplicate)
[INFO] |  +- io.springfox:springfox-swagger-common:jar:2.7.0-SNAPSHOT:compile
[INFO] |  |  +- (io.swagger:swagger-annotations:jar:1.5.12:compile - omitted for duplicate)
[INFO] |  |  +- (io.swagger:swagger-models:jar:1.5.12:compile - omitted for duplicate)
[INFO] +- io.swagger:swagger-parser:jar:1.0.27:test
[INFO] |  +- io.swagger:swagger-core:jar:1.5.12:test
[INFO] |  |  +- (io.swagger:swagger-models:jar:1.5.12:test - omitted for duplicate)

@gionn gionn closed this Apr 20, 2017

@fehguy fehguy modified the milestone: v1.0.29 May 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment