如何在 Azure Easy API 中启用 Swagger UI
How to enable Swagger UI in Azure Easy API
我正在使用 Azure 应用服务,并为我的手机 API 后端设置了 Easy API 和 Easy Table。
我想知道如何为 Azure 应用服务设置 Swagger UI。
当我尝试导航到 API(例如 https://xxxxxx.azurewebsites.net/swagger/ui)时,显示 "To access the swagger UI, you must enable swagger support by adding swagger: true to your configuration and installing the swagger-ui npm module"
当您没有 API 的源代码时,您如何准确地添加 swagger-ui npm(它是使用 Easy API 自动创建的)?
你的问题分两部分:
1) 目前无法在 EasyAPI 上启用 Swagger。也就是说,我们不合并也不生成EasyAPI的Swagger,因为所有参数都在代码中定义。
2) 如果要启用 Swagger,则需要将 'swagger: true' 添加到 app.js 文件中 API 上方级别的 Azure 移动应用程序的初始化程序。进入 Easy API 或 Easy Tables 并编辑任何 API/Table。这将调出编辑器。转到上面的目录(包含 api 和 tables 目录的目录)并在那里编辑 app.js 文件。
步骤:
- 在 Azure 门户上
- 打开您的应用程序应用服务
- 转到开发工具 -> 应用服务编辑器(预览版)- 单击 GO
- 内部 应用服务编辑器(预览版)-> 打开控制台 ( CTRL + Shift + C )
- 键入 npm install --save swagger-ui
- 等待安装
- 检查 node_modules 上是否存在文件夹 -> swagger-ui
- 现在在应用程序文件上启用 swagger /wwwroot/app.js
更改内容:
var mobile = azureMobileApps({
// 显式启用 Azure 移动应用程序主页
主页:真实,
// Explicitly enable swagger support. UI support is enabled by
// installing the swagger-ui npm module.
swagger: true
});
- 在 https://your-application.azurewebsites.net on Google Chrome click try it out or open https://your-application.azurewebsites.net/swagger/ui
上测试 Swagger
我正在使用 Azure 应用服务,并为我的手机 API 后端设置了 Easy API 和 Easy Table。
我想知道如何为 Azure 应用服务设置 Swagger UI。
当我尝试导航到 API(例如 https://xxxxxx.azurewebsites.net/swagger/ui)时,显示 "To access the swagger UI, you must enable swagger support by adding swagger: true to your configuration and installing the swagger-ui npm module"
当您没有 API 的源代码时,您如何准确地添加 swagger-ui npm(它是使用 Easy API 自动创建的)?
你的问题分两部分:
1) 目前无法在 EasyAPI 上启用 Swagger。也就是说,我们不合并也不生成EasyAPI的Swagger,因为所有参数都在代码中定义。
2) 如果要启用 Swagger,则需要将 'swagger: true' 添加到 app.js 文件中 API 上方级别的 Azure 移动应用程序的初始化程序。进入 Easy API 或 Easy Tables 并编辑任何 API/Table。这将调出编辑器。转到上面的目录(包含 api 和 tables 目录的目录)并在那里编辑 app.js 文件。
步骤:
- 在 Azure 门户上
- 打开您的应用程序应用服务
- 转到开发工具 -> 应用服务编辑器(预览版)- 单击 GO
- 内部 应用服务编辑器(预览版)-> 打开控制台 ( CTRL + Shift + C )
- 键入 npm install --save swagger-ui
- 等待安装
- 检查 node_modules 上是否存在文件夹 -> swagger-ui
- 现在在应用程序文件上启用 swagger /wwwroot/app.js
更改内容:
var mobile = azureMobileApps({ // 显式启用 Azure 移动应用程序主页 主页:真实,
// Explicitly enable swagger support. UI support is enabled by
// installing the swagger-ui npm module.
swagger: true
});
- 在 https://your-application.azurewebsites.net on Google Chrome click try it out or open https://your-application.azurewebsites.net/swagger/ui 上测试 Swagger