Open requiel20 opened 1 year ago
/cc @EricWittmann (openapi), @Ladicek (smallrye), @MikeEdgar (openapi), @evanchooly (kotlin), @geoand (kotlin), @jmartisk (smallrye), @phillip-kruger (openapi,smallrye), @radcortez (smallrye)
@requiel20 , the Long
type is represented in the byte-code as a primitive long
when it is non-nullable [1]. The scanner sees this and assumes it will be defaulted to 0
when missing.
You can work around this by adding @field:Schema(required = true)
to the property.
[1] https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/
@MikeEdgar is there anything we can do on our end? If not, would a note in the docs make sense?
As far as I can tell there's nothing we can do. It amounts to loss of information from the Kotlin source to the bytecode used by Jandex. A note would probably make sense since it's not exactly intuitive (to me).
Which doc would it make the most sense to be included?
We have a guide for OpenAPI in Quarkus don't we? I'm thinking of a section on Kotlin that we can use to add such workarounds
Yeah, that makes sense. I was thinking it would be in the Kotlin guide (maybe just a link to the Kotlin section of the OpenAPI guide)
Works for me!
Describe the bug
I have a simple data class being returned by one of my routes.
Data class:
Route:
Expected behavior
The schema generated by the quarkus-smallrye-openapi extension has the
id
field as required:Actual behavior
The schema generated by the quarkus-smallrye-openapi extension does not have the
id
as required:How to Reproduce?
No response
Output of
uname -a
orver
Darwin lbattist-macOS 21.6.0 Darwin Kernel Version 21.6.0: Thu Mar 9 20:12:21 PST 2023; root:xnu-8020.240.18.700.8~1/RELEASE_ARM64_T6000 arm64
Output of
java -version
openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08) OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.0.4.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.1.1
Additional information
This can be fixed by adding
@Schema(requiredProperties = ["id", "name", "createdAt"])
to the class, but it shouldn't be necessary.