-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
unable to overwrite springdoc.model-converters.polymorphic-converter.enabled in JUnit test #2921
Comments
Hi, I am interpreting that your setup is trying to achieve the same thing as this test. When I run that test in conjunction with other tests (while also removing the static definition) I get different behavior between having the property defined as |
It is not clear to me what exactly the linked test is trying to “achieve”. |
I would suggest that you clone the repository so that you could see what the abstract test class defines. To summarize it parses a controller and generates a specification for it, and it is then matched against an expected specification definition. Thus the linked test verifies that the generated specification does not contain any structure that the polymorphic converter would generate. Since this test is ran together with tests that verify that the structure that the polymorphic converter would generate is present, then this would mean that the tests are achieving the case which you are looking for (some tests can have a converter disabled). Hence cloning the repo and looking at how the tests are realized might guide you in how to realize what you are looking for. |
Ahh, thanks for the explanation. I'm not looking for a workaround (I already have one), but wanted to report a faulty implementation here. As already recognizable from the first answer, the responsibility for static caching does not seem to lie with Springdoc, but in Swagger. Accordingly, I don't see any specific need for action here for the time being, except that the problems with unit tests could possibly be noted on https://springdoc.org/properties.html. Translated with DeepL.com (free version) |
Describe the bug
If you have multiple @SpringBootTests that start a web environment, the property springdoc.model-converters.polymorphic-converter.enabled is evaluated when starting the first test and the result / the io.swagger.v3.core.converter.ModelConverters to be used are apparently cached somewhere outside the Spring application context.
If you then try to set the property to a different value in subsequent unit tests (e.g. via org.springframework.boot.test.context.SpringBootTest.properties()), this has no effect.
(@DirtiesContext and other approaches also do not work as a workaround).
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The property springdoc.model-converters.polymorphic-converter.enabled may be overwritten in any test.
The text was updated successfully, but these errors were encountered: