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
I'm currently using Jackson's @JsonView annotation to include/exclude class properties based on the API operation that is being performed (e.g., create, update, read, etc.).
I have a specific need where I must annotate a class with @SchemaProperties, @SchemaProperty, and @Schema. However, the ModelResolver (Jackson-specific implementation of ModelConverter) ends up not propagating the @JsonView annotation when resolving the classes of the properties defined with @SchemaProperties. This causes the resulting schema to include properties that should be excluded for certain operations.
I'm using Swagger Core via Springdoc (which can be assumed based on the example above)
In case it is helpful, I'm using @SchemaProperties/@SchemaProperty/@Schema in a class that allows dynamic properties to be provided by consumers via the @JsonAnySetter/@JsonAnyGetter annotations. @SchemaProperties/... allow me to provide some examples in the generated schema to our consumers.
The text was updated successfully, but these errors were encountered:
I'm currently using Jackson's
@JsonView
annotation to include/exclude class properties based on the API operation that is being performed (e.g., create, update, read, etc.).I have a specific need where I must annotate a class with
@SchemaProperties
,@SchemaProperty
, and@Schema
. However, theModelResolver
(Jackson-specific implementation ofModelConverter
) ends up not propagating the@JsonView
annotation when resolving the classes of the properties defined with@SchemaProperties
. This causes the resulting schema to include properties that should be excluded for certain operations.swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java
Line 881 in e6d3fa3
swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java
Line 1775 in e6d3fa3
Example
Alternative Solution
I was able to overcome the problem for now by defining a "dummy" setter method, causing the schema to be generated the way I'd expected:
Additional Context
@SchemaProperties
/@SchemaProperty
/@Schema
in a class that allows dynamic properties to be provided by consumers via the@JsonAnySetter
/@JsonAnyGetter
annotations.@SchemaProperties
/... allow me to provide some examples in the generated schema to our consumers.The text was updated successfully, but these errors were encountered: