node.js - 如何正确配置 swagger-jsdoc 以使用基本身份验证?
问题描述
我正在尝试在 swagger 中配置我的 express rest api 文档以使用基本身份验证。为此,我使用 swagger-jsdoc 和 swagger-express-ui 包。这是我目前的招摇配置:
swagger: {
swaggerDefinition: {
openapi: '3.0.0',
info: {
title: 'API Documentation',
version: 'v1',
description: 'A REST API Service.',
license: {
name: '',
url: '',
},
contact: {
name: '',
url: '',
email: '',
},
},
servers: [
{
url: 'http://localhost:3000/api/v1',
description: 'Development Server',
},
],
components: {
securitySchemes: {
basicAuth: {
type: 'http',
scheme: 'basic',
description: 'Basic Authroization header.',
},
},
},
security: [
{
basicAuth: [],
},
],
},
apis: ['./src/routes/api-v1/*.js'],
securityDefinitions: {
auth: {
type: 'basic',
},
},
security: [{ auth: [] }],
},
解决方案
推荐阅读
- jquery - 每个功能仅适用于偶数
- influxdb - 在 InfluxDB 中处理稀疏时间序列数据
- ruby-on-rails - 如何在作业和控制器之间共享代码
- angular - 如何在选择器 B Angular 中使用来自选择器 A 的 ng-template
- rest - 如何通过 REST API 自动运行 bin/elasticsearch-setup-passwords?
- java - 将测试数据从一个测试用例传递到另一个
- docker - 将本地存储库代码更改合并到正在运行的容器中
- android - 缓存图像并在 FirestoreRecyclerAdapter 中显示
- r - 如何在预测阶段使用 mlr3 包解码 JSON 数据?
- jupyter-notebook - 如何使 jupyter 能够启动 MS。边缘