*`I have below schema definition to represent commission amount in my openapi contract.`*
"properties": {
"Amount": {
"type": "number",
"description": "The amount of tnx",
"pattern" : "^-?[0-9]*(\\.([0-9]{1,2}))?$",
"format": "big-decimal",
"minimum": 0.01,
"maximum": 49999.99,
"exclusiveMinimum": false,
"exclusiveMaximum": false,
"example" : "9999.99"
},
сгенерированный код:
@NotNull @Valid @DecimalMin("0.01") @DecimalMax("49999.99")
@Schema(name = "amount", example = "9999.99", description = "The amount of tnx", required = true)
public BigDecimal getAmount() {
return amount;
}
когда я дал значение выше 50000 или ниже 0,01, через почтового ящика было получено правильное сообщение проверки
{
"errors": [
{
"code": "DecimalMax",
"message": "must be less than or equal to 49999.99",
"field": "Amount"
}
]
}
{
"errors": [
{
"code": "DecimalMin",
"message": "must be greater than or equal to 0.01",
"field": "Amount"
}
]
}
but i want override the code with some some number to represent the error code like 100,101 etc
{
"errors": [
{
"code": "100",
"message": "must be less than or equal to 49999.99",
"field": "Amount"
}
]
}
{
"errors": [
{
"code": "101",
"message": "must be greater than or equal to 0.01",
"field": "Amount"
}
]
}
can i specify any annotation on swagger to achieve this
Подробнее здесь: https://stackoverflow.com/questions/750 ... annotation