Closed pdalfarr closed 1 week ago
Hi @pdalfarr, thank you for the report. For us it is difficult to reproduce this without the class for the schema. Please enable debug mode to finde the method that includes the problematic payload and share the code for the payload with us.
Hello, @sam0r040 I've found code that can generate the problematic payload:
public record MyRootObject(
MyEnumObject myEnumObject
) {
}
@Schema(enumAsRef = true)
public enum MyEnumObject {
VALUE1,
VALUE2
}
@Component
public class Producer {
@AsyncPublisher(operation = @AsyncOperation(channelName = "mychannel"))
public void produce(MyRootObject message) {
}
}
The problem is that schema name for MyEnumObject
is resolved to null
and thus DefaultShemaWalker
throws an exception here https://github.com/springwolf/springwolf-core/blob/master/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/components/examples/walkers/DefaultSchemaWalker.java#L61
Also, if you remove the wrapper class MyRootObject
and return MyEnumObject
itself in the produce()
method no exception is thrown but no example for MyEnumObject
is generated.
Hi @pdalfarr , @ruskaof, I reproduced it with your code in https://github.com/springwolf/springwolf-core/pull/887
I do see the (unexpected) exception: There is no name set...
MyRootObject
does have a valid example, MyEnumObject
is missing one.
Do you expect an example for MyEnumObject
and/or no exception?
Will keep looking into it.
I think that there should not be an exception thrown because schema name should be generated from a class name if it is not defined explicitly in the @Schema
annotation. Also, it would be nice to have the enum class with its values referenced in the Schemas
section of the UI. Something like springdoc generates with REST endpoints:
The change is staged for release and will be part of the next release.
If you want to try and verify it in your application today, use the latest 1.X.0-SNAPSHOT build as described in our README.md > Testing SNAPSHOT version
Thank you for the report/contribution!
The change is available in the latest release. 🎉
Thank you for the report/contribution and making Springwolf better!
Describe the bug Schema generation was working fine with SpringWolf 1.2.0. I changed version from 1.2.0 to 1.4.0: as a result, my Spring app is working fine, but Springwolf does not work. See log message and stack trace below.
Dependencies and versions used SpringWolf 1.2.0 :
SpringWolf 1.4.0: same as above plus:
Code example No code example
Stack trace and error logs
I see multiple log messages like this :