Closed
Description
Here's my situation:
- We are building a a REST API and we want to document it with SpringDoc/Swagger
- Some of the APIs return
ProductDto
which is defined in a jar file and we have no access to the codebase ofProductDto
. - The
ProductDto
has a field of typeMonetaryAmount
and we have registered a jackson module to deal with serialization/de-serialization ofMonetaryAmount
. So when the API is invoked we see this in the response:
"price": {
"amount": "5.00",
"currency": "USD"
},
however, the Swagger-UI and the generated schema shows this as an example:
"price": {
"code": "string",
"defaultPaymentInfo": true,
"subscriptionCode": "string",
"saved": true,
"paymentMode": {
"id": "string",
"code": "string",
"name": "string",
"description": "string",
"method": {},
"hopChargeUrl": "string",
"cost": {
"negativeOrZero": true,
"positiveOrZero": true,
"negative": true,
"zero": true,
"positive": true,
"context": {
"precision": 0,
"fixedScale": true,
"maxScale": 0,
"empty": true,
"providerName": "string"
},
"currency": {
"defaultFractionDigits": 0,
"numericCode": 0,
"currencyCode": "string",
"context": {
"empty": true,
"providerName": "string"
}
},
"number": {
"amountFractionNumerator": 0,
"amountFractionDenominator": 0,
"precision": 0,
"scale": 0
}
}
},
Is there a possibility to register something like SchemaCustomizer
to provide custom snippet for fields of type MonetaryAmount
?
We can't add annotations because we don't have access to the source-code and my wish was to actually deal with this in a central place, rather than going through all of our DTOs and adding custom annotations every time I see a field of type MonetaryAmount
.
Metadata
Metadata
Assignees
Labels
No labels