fix: make usefqn threadsafe#1709
Conversation
✅ Deploy Preview for springwolf-ui canceled.
|
9667b9e to
6f9a757
Compare
6f9a757 to
d21c260
Compare
|
I took a look, there is something wrong in combination with Protobuf or how the ObjectMapper is used to generated the examples. @tvahrst Can you confirm, that the updated schema with openapi31 matches your expectation? |
|
Hi @timonback , the Spring class I've provided a separate, small ModelConverter class for the Kafka test suite that explicitly reacts to While I was at it, I also made a small adjustment to the error output during example schema generation to display the name of the schema in case of exceptions. I was wondering why the test for OpenAPI 3.1 changed so much compared to the master version due to this pull request. The reason was this: On the master version, a ModelConverter bean, specifically a ModelResolver, is created in the ProtobufStandAloneConfiguration. Firstly, this is internally set to OpenAPI 3.0. Secondly, this is an 'additionalModelConverter', which is collected in the |
|
Good catch, so adding the ConsumerMetaData in general could be seen as wrong and could be omitted (in a future adjustment). Adding more debug output is good. Ill have to check that that cannot raise a nullpointer exception. Thank you for the explanation. Just to confirm, there was a bug before and it is corrected now? Or do you see another issue with the modelresolvers for protobuf? |
|
Yes, the new |
One example is ConsumerRecordMetadata in kafka, which contains metadata via the @Header annotation. But it is not part of the transport protocol and should not be part of AsyncApi
Unfortunately, using the static 'std' instance of Swagger's
TypeNameResolveris not thread-safe. This can lead to unwanted race conditions and side effects (see Issue #635).To fix this, code sections using
TypeNameResolvermust utilize a dedicated, properly configured instance (with usefqn set correctly). This requires the ability to create a custom instance ofTypeNameResolver. Since the constructor is protected, a simple subclassSpringWolfTypeNameResolverwas introduced to make the constructor public.A custom
TypeNameResolvermust be implemented in the following locations:SwaggerSchemaService: TwoTypeNameResolverinstances are required—one to generate simple names and a second instance based on the 'useFqn' property.ModelConverters: Internally, this uses aModelResolver, which in turn relies on the global, static instance ofTypeNameResolver. To correct this, the internalModelResolverinstance must be replaced with a properly initialized one during the creation ofModelConverters. SeeModelConvertersProvider.