-
-
Notifications
You must be signed in to change notification settings - Fork 528
Schema annotation not working in Kotlin super class (has workaround) #3010
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
Comments
just with |
Hi @mymx2 thanks for the screenshots. I'm aware of these use-site targets. This was the workaround mentioned in my original post and indeed fixes the issue. The interesting thing is that the annotation works without explicit use-site target in the subclass, but not in the superclass. |
Class introspection comes from swagger-core. You can play around with how they introspect a class by using ResolvedSchema resolvedSchema = ModelConverters.getInstance(true)
.resolveAsResolvedSchema(
new AnnotatedType(YourClazz.class).resolveAsRef(false)); I discuss my experiences regarding the introspection here (I have not myself found any resource that describes exactly how it is done and why). So my understanding is that if you feel like this is a behavior that should exist, then it is something that you will have to raise and discuss with the maintainers of swagger-core. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When using Kotlin, annotating a field with
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
does not work on the super class. It does however work on the "main" entity. This inconsistency could be addressed.To Reproduce
Steps to reproduce the behavior:
Actual:
Expected:
Expected behavior
@Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
are not required in the generated OpenApi spec.Workaround:
Add
get:
before the annotation in the super class to make the annotation explicitly attached to the getter.@get:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED)
The text was updated successfully, but these errors were encountered: