You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue here shows a previous problem where OpenAPI was not respecting fields annotated with @JsonView. The applied fix seems to work for simple cases, but does not work when a class is annotated with @JsonView or if the ObjectMapper is set not to add fields to views by default. Examples are in Kotlin/Quarkus, using version 3.10.0 of smallrye-open-api via Quarkus 3.8.1.
Example 1 (works as expected):
@JsonView(View.Public::class)
@GET
@Path("/public")
funuserPublic(): User? {
returnUser().also {
it.id =123
it.name ="Person"
}
}
classUser {
@JsonView(View.Private::class)
var id =0
@JsonView(View.Public::class)
var name:String?=null
}
classView {
openclassPublicclassPrivate : Public()
}
Endpoint /public returns {"name":"Person"}
Generated type schema (as expected):
Thanks for the issue. I think the class-level annotation handling should be an easy fix for the next release. The ObjectMapper functionality will probably need to be handled as a configuration property since the scanner doesn't have knowledge of or a reference to the runtime mapper the application is using.
The issue here shows a previous problem where OpenAPI was not respecting fields annotated with
@JsonView
. The applied fix seems to work for simple cases, but does not work when a class is annotated with@JsonView
or if the ObjectMapper is set not to add fields to views by default. Examples are in Kotlin/Quarkus, using version 3.10.0 of smallrye-open-api via Quarkus 3.8.1.Example 1 (works as expected):
Endpoint /public returns
{"name":"Person"}
Generated type schema (as expected):
Example 2 (annotate class definition with
@JsonView
):Endpoint /public returns
{"name":"Person"}
(as expected)Generated type schema (Note: id field should not be shown here):
Example 3 (change ObjectMapper to exclude fields from
@JsonView
by default):ObjectMapper can be setup as follows to exclude fields by default from
@JsonView
:Neither the
id
field or theUser
class now need to be annotated to be ignored by Jackson:Endpoint /public returns
{"name":"Person"}
(as expected)Generated type schema (Note: id field should not be shown here):
The text was updated successfully, but these errors were encountered: