Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Schema annotation is not picked up when using @JsonValue from Jackson #3904

Closed
martin-tarjanyi opened this issue Feb 25, 2021 · 1 comment
Closed

Comments

@martin-tarjanyi
Copy link
Contributor

See: springdoc/springdoc-openapi#1077

I debugged the code and I found the issue at the following place:

AnnotatedType aType = new AnnotatedType()
.type(jsonValueType)
.parent(annotatedType.getParent())
.name(annotatedType.getName())
.schemaProperty(annotatedType.isSchemaProperty())
.resolveAsRef(annotatedType.isResolveAsRef())
.jsonViewAnnotation(annotatedType.getJsonViewAnnotation())
.propertyName(annotatedType.getPropertyName())
.skipOverride(true);

Unlike in other places, at this point the .ctxAnnotations(schemaAnnotations) method is not called which results in the loss of data coming from @Schema annotation.

@frantuma
Copy link
Member

Thanks for reporting and investigating! Fixed in #3930

sgrimm added a commit to terraware/terraware-server that referenced this issue Sep 2, 2021
Previously, if we wanted to include an ID value in the URL path, we had to declare
the path variable as `Long` in the controller and then explicitly create an ID
wrapper object.

This was needed because Spring MVC didn't know how to convert a string to an
instance of an ID wrapper class. So the simple fix is to add a constructor to the
wrapper classes that takes a string argument. If the client uses a non-numeric
value, it will fail with HTTP 400 the same way it fails with `Long` parameters.

Update all the controller methods that used to take `Long` arguments to instead
use the appropriate wrapper classes.

This caused us to hit swagger-api/swagger-core#3904 so
upgrade the OpenAPI library to get the fix for that.
sgrimm added a commit to terraware/terraware-server that referenced this issue Sep 2, 2021
Previously, if we wanted to include an ID value in the URL path, we had to declare
the path variable as `Long` in the controller and then explicitly create an ID
wrapper object.

This was needed because Spring MVC didn't know how to convert a string to an
instance of an ID wrapper class. So the simple fix is to add a constructor to the
wrapper classes that takes a string argument. If the client uses a non-numeric
value, it will fail with HTTP 400 the same way it fails with `Long` parameters.

Update all the controller methods that used to take `Long` arguments to instead
use the appropriate wrapper classes.

This caused us to hit swagger-api/swagger-core#3904 so
upgrade the OpenAPI library to get the fix for that.
sgrimm added a commit to terraware/terraware-server that referenced this issue Sep 2, 2021
Previously, if we wanted to include an ID value in the URL path, we had to declare
the path variable as `Long` in the controller and then explicitly create an ID
wrapper object.

This was needed because Spring MVC didn't know how to convert a string to an
instance of an ID wrapper class. So the simple fix is to add a constructor to the
wrapper classes that takes a string argument. If the client uses a non-numeric
value, it will fail with HTTP 400 the same way it fails with `Long` parameters.

Update all the controller methods that used to take `Long` arguments to instead
use the appropriate wrapper classes.

This caused us to hit swagger-api/swagger-core#3904 so
upgrade the OpenAPI library to get the fix for that.
sgrimm added a commit to terraware/terraware-server that referenced this issue Sep 2, 2021
Previously, if we wanted to include an ID value in the URL path, we had to declare
the path variable as `Long` in the controller and then explicitly create an ID
wrapper object.

This was needed because Spring MVC didn't know how to convert a string to an
instance of an ID wrapper class. So the simple fix is to add a constructor to the
wrapper classes that takes a string argument. If the client uses a non-numeric
value, it will fail with HTTP 400 the same way it fails with `Long` parameters.

Update all the controller methods that used to take `Long` arguments to instead
use the appropriate wrapper classes.

This caused us to hit swagger-api/swagger-core#3904 so
upgrade the OpenAPI library to get the fix for that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants