Swagger/OpenAPI multiple security requirements and side effects?

ぃ、小莉子 提交于 2019-12-22 07:59:18

问题


I am implementing a code generator for Swagger/OpenAPI. However, I run into a problem implementing the security requirement. These requirements are defined as a list of objects. The list members are alternatives (or) and the object members are anded. For example:

 [ { a:[], b:{} }, { c:{}, d:{} } ]

This supposed to result in (a && b) || ( c && d)

However, implementing this I run into the problem that the actual security requirements have side effects:

  • OAuth2 - Must redirect if it fails
  • Basic – Must send a HTTP 401 Unauthorized status and a WWW-Authenticate header
  • ApiKey – whatever

However, since there is an or you cannot allow the first failure to set these side effects. It seems that you need to first try all combinations and then go back to the first and allow it to set the headers/result code?

Looking at the generators that are out there on http://editor.swagger.io/ I find most generators seem to ignore security and the Java generators seem to and the combined list. In my example I see a && b && c && d.

So my questions are:

  • Is there a generator that properly implements OpenAPI security?
  • How to handle these side effects?

来源:https://stackoverflow.com/questions/42679595/swagger-openapi-multiple-security-requirements-and-side-effects

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