问题
I'm having difficulty understanding the correct way to include validation information in a swagger file, when the validation logic can be dynamic (default, minValue, maxValue, etc.).
Consider the following example:
In a banking application, we a have a REST API for withdrawals. The withdrawal amount cannot be greater than the account value of the person taking the withdrawal. This value is going to depend on the context (Who's bank account we are withdrawing from) to get that maximum value. What is the correct/standard way to represent this information in a Swagger file?
回答1:
The default/mininum/maximum/etc. values are static. OpenAPI/Swagger does not support parameter dependencies. You will need to document these restrictions verbally in the operation description and/or parameter description, and implement the logic yourself.
来源:https://stackoverflow.com/questions/45922917/swagger-dynamic-schema