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
When Schema#implementation is defined on a property, all information specified through @Schema is propagated to the schema created for the type defined in Schema#implementation. However this information should only be used when generating the property schema. I am using Open API 3.1. This problem was introduced after upgrading from 2.2.22 to 2.2.25.
Expected behavior
@Schema annotation is processed on the property level, but not used in schema generation for the class specified in Schema#implementation of that property.
For example if I have the following DTO
public class Example {
@Schema(implementation = MyEnum.class, description = "My description", defaultValue = "yes")
private String whyYes;
//getters, setters
}
and MyEnum class looks like this
enum MyEnum {
yes, no
}
the generated contract for the two components is expected to look like this
However current behavior propagates the schema annotation (and the properties from that schema annotation, in this case description and defaultValue) to the underlying object, which is incorrect
Note that if @Schema#implementation was not specified this problem would not occur.
Reproducer
Add something similar to the provided example above (if using enum, set enums to be resolved as references) to this test class (which was created to test the solutions for this issue).
Investigation
While previously @Schema and @ArraySchema annotations were not added to the annotation list, which is then added to the type of the property to be processed, this change introduced the behavior where it actually gets added to the list of annotations which are passed to the underlying object. This does not seem to be the right solution, since the class for the property should be agnostic of the @Schema/@ArraySchema annotations on the field where it is used.
The text was updated successfully, but these errors were encountered:
OllieKosh
changed the title
BUG @Schema annotation is propagated to the class of the field on which it is annotated when @Schema#implementation is defined
BUG @Schema annotation is propagated from a property to the class defined in @Schema#implementation
Nov 28, 2024
Problem
When
Schema#implementation
is defined on a property, all information specified through@Schema
is propagated to the schema created for the type defined inSchema#implementation
. However this information should only be used when generating the property schema. I am using Open API 3.1. This problem was introduced after upgrading from 2.2.22 to 2.2.25.Expected behavior
@Schema
annotation is processed on the property level, but not used in schema generation for the class specified inSchema#implementation
of that property.For example if I have the following DTO
and MyEnum class looks like this
the generated contract for the two components is expected to look like this
However current behavior propagates the schema annotation (and the properties from that schema annotation, in this case
description
anddefaultValue
) to the underlying object, which is incorrectNote that if
@Schema#implementation
was not specified this problem would not occur.Reproducer
Add something similar to the provided example above (if using enum, set enums to be resolved as references) to this test class (which was created to test the solutions for this issue).
Investigation
While previously
@Schema
and@ArraySchema
annotations were not added to the annotation list, which is then added to the type of the property to be processed, this change introduced the behavior where it actually gets added to the list of annotations which are passed to the underlying object. This does not seem to be the right solution, since the class for the property should be agnostic of the@Schema
/@ArraySchema
annotations on the field where it is used.The text was updated successfully, but these errors were encountered: