Skip to content
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

Respect schema annotations when using spring mvc with kotlin #2443

Merged
merged 1 commit into from Feb 25, 2024

Conversation

viktor-berglund-mw
Copy link
Contributor

@viktor-berglund-mw viktor-berglund-mw commented Dec 4, 2023

This PR fixes a bug when using kotlin and spring mvc. The field noRequiredNoNullableDefault in springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt will be marked as required when it should not, it has a default value in the swagger annotation.

When adding AnnotationIntrospectors, the order matters. The fact that the SpringDocJacksonKotlinModuleConfiguration was dependent on ObjectMapperProvider and SpringDocConfiguration made it so that the SpringDocRequiredModule was added before the KotlinModule.

To fix this bug we create a primary bean for the ObjectMapperProvider when KotlinModule is on the class path to ensure that this module is added before SpringDocRequiredModule.

Tests are added for spring mvc using kotlin

Co-authored-by: Ola Petersson olbpetersson@gmail.com
Co-authored-by: Simon Lindhen simon.lindhen@gmail.com

This PR fixes a bug when using kotlin and spring mvc. The field `noRequiredNoNullableDefault` in `springdoc-openapi-tests/springdoc-openapi-kotlin-mvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt` will be marked as required when it should not, it has a default value in the swagger annotation.

When adding `AnnotationIntrospectors`, the order matters. The fact that the `SpringDocJacksonKotlinModuleConfiguration` was dependent on `ObjectMapperProvider` and `SpringDocConfiguration` made it so that the `SpringDocRequiredModule` was added before the `KotlinModule`.

To fix this bug we create a primary bean for the `ObjectMapperProvider` when `KotlinModule` is on the class path to ensure that this module is added before `SpringDocRequiredModule`.

Tests are added for spring mvc using kotlin

Co-authored-by: Ola Petersson <olbpetersson@gmail.com>
Co-authored-by: Simon Lindhen <simon.lindhen@gmail.com>
@viktor-berglund-mw
Copy link
Contributor Author

@bnasslahsen do you think you will accept this PR for the next release? If not, is there something we can do to make that happen?

@bnasslahsen
Copy link
Contributor

@viktor-berglund-mw,

i will add you PR for the next release.

@bnasslahsen bnasslahsen merged commit 65ace1a into springdoc:main Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants