如何更改Strapi API文档插件中的属性

时间:2019-11-11 04:32:22

标签: swagger strapi

我已经创建了一个名为auth / google的自定义API,用于验证Google tokenId并为前端反应生成JWT令牌。

现在,我希望在swagger API中具有自定义属性。当前,它在请求正文和所有响应中包含{foo:“ string”}

要更改此设置,请按照以下步骤操作:

  1. 在projectfolder / extensions / users-permissions / documentations / 1.0.0 / overrides / users-permissions-User.json中创建了users-permissions-User.json文件

,然后在内容下方添加

{
  "paths": {
    "/auth/google": {
      "post": {
        "deprecated": false,
        "description": "Login a user using the identifiers email and password",
        "responses": {
          "200": {
            "description": "response",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "tokenId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "summary": "",
        "tags": [
          "Users-Permissions - User"
        ],
        "requestBody": {
          "description": "",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "tokenId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
  "tags": [
    {
      "name": "Users-Permissions - User"
    }
  ]
}
}
  1. 然后http://localhost:1337/admin/plugins/documentation单击重新生成按钮
  2. 单击打开按钮

文档中没有任何更改。任何人都可以帮助我做到这一点

0 个答案:

没有答案