Open AlanSage11 opened 6 months ago
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):