Swagger: Dynamic Schema

允我心安 提交于 2020-12-12 07:33:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!