204 代码状态的未知响应类型

Sli*_*lim 5 swagger

我需要描述我的应用程序的路线,因此我使用 swagger:

paths:
  /users:
    get:
      description: Returns all users
      responses:
        "204":
          description: No Content Found
          schema:
            $ref: "#/definitions/NoContentFound"
      
definitions:
 NoContentFound:
  required:
     - message
  properties:
     message:
       type: string
Run Code Online (Sandbox Code Playgroud)

我在 swagger UI 上收到此错误:

Unknown response type
Run Code Online (Sandbox Code Playgroud)

在 app.js 上:

Unknown response type
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

小智 8

有些响应(例如 204 No Content)没有正文。要指示响应正文为空,请不要指定响应内容:

参考:空响应正文