You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ExampleJsonGenerator for objects always expects that the schema has non-null properties. This if often not the case, for example if a schema refers to another one, only the name and the $ref properties are set, all others, especially properties are null.
Caused by: java.lang.RuntimeException: Error occured during creation of AsyncAPI
at io.github.stavshamir.springwolf.asyncapi.DefaultAsyncApiService.getAsyncAPI(DefaultAsyncApiService.java:45)
at io.github.stavshamir.springwolf.asyncapi.SpringwolfInitApplicationListener.afterPropertiesSet(SpringwolfInitApplicationListener.java:39)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766)
... 16 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Map.entrySet()" because "properties" is null
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.handleObject(ExampleJsonGenerator.java:134)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.buildSchema(ExampleJsonGenerator.java:69)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.handleArraySchema(ExampleJsonGenerator.java:92)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.buildSchema(ExampleJsonGenerator.java:65)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.lambda$handleObject$0(ExampleJsonGenerator.java:140)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.handleObject(ExampleJsonGenerator.java:144)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.buildSchema(ExampleJsonGenerator.java:69)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.buildSchema(ExampleJsonGenerator.java:61)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.lambda$handleObject$0(ExampleJsonGenerator.java:140)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.handleObject(ExampleJsonGenerator.java:144)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.buildSchema(ExampleJsonGenerator.java:69)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.buildSchema(ExampleJsonGenerator.java:61)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.lambda$handleObject$0(ExampleJsonGenerator.java:140)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.handleObject(ExampleJsonGenerator.java:144)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.buildSchema(ExampleJsonGenerator.java:69)
at io.github.stavshamir.springwolf.schemas.example.ExampleJsonGenerator.fromSchema(ExampleJsonGenerator.java:39)
at io.github.stavshamir.springwolf.schemas.DefaultSchemasService.generateExampleWhenMissing(DefaultSchemasService.java:89)
at java.base/java.util.HashMap.forEach(HashMap.java:1421)
at io.github.stavshamir.springwolf.schemas.DefaultSchemasService.finalizeDefinitions(DefaultSchemasService.java:45)
at io.github.stavshamir.springwolf.schemas.DefaultSchemasService.getDefinitions(DefaultSchemasService.java:39)
at io.github.stavshamir.springwolf.asyncapi.DefaultAsyncApiService.initAsyncAPI(DefaultAsyncApiService.java:71)
at io.github.stavshamir.springwolf.asyncapi.DefaultAsyncApiService.getAsyncAPI(DefaultAsyncApiService.java:39)
... 19 common frames omitted
The text was updated successfully, but these errors were encountered:
Thank you for the bug report and technical details.
I addressed the NPE in #316 and also added a more complex example to close the test gap.
Based on this report as well as #315, I suspect there are more cases. Are you able to replicate/contribute a test case or provide your DTO structure? Based on the stacktrace, I am only able to see that there is an object -> object -> object -> array -> object relationship. Class and property names do not matter, feel free to have a look at the PR.
I am also happy to help and make the test green, but can only assume the class structure at this point.
Describe the bug
The
ExampleJsonGenerator
for objects always expects that the schema has non-nullproperties
. This if often not the case, for example if a schema refers to another one, only thename
and the$ref
properties are set, all others, especiallyproperties
are null.Dependencies and versions used
Springwolf 0.13.0
Code example
springwolf-core/springwolf-core/src/main/java/io/github/stavshamir/springwolf/schemas/example/ExampleJsonGenerator.java
Line 134 in 7b9c709
Stack trace and error logs
The text was updated successfully, but these errors were encountered: