openAPI 3.0未显示API端点的“试用"按钮 [英] openAPI 3.0 is not showing try it out button for API endpoints
本文介绍了openAPI 3.0未显示API端点的“试用"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不幸的是,我已经使用swagger openapi3.0配置了我的api,不幸的是,它没有显示我的API端点的try it out按钮.我是否缺少swagger文件中的任何配置?谁能帮我解决这个错误?
I've configured my api with swagger openapi3.0, unfortunately, it is not showing try it out button for my API endpoints. am I missing any configuration in the swagger file? can anyone help me how to solve this error?
注意:我正在使用开放式API3.0 这是我使用的配置:
Note: I'm using swagger open API3.0 here is the configuration I've used:
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Reinvent-API",
"description": "Reusable and minimalistic API for Hyperledger-fabric Networks",
"contact": {
"name": "Dev",
"email": "dev@gmail.com",
"url": "https://dev.github.io/"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
},
"servers": [
{
"url": "http://localhost:3000/api"
}
],
"paths": {
"/invoke": {
"post": {
"tags": [
"API Explorer"
],
"description": "invoke chaincode function",
"operationId": "invoke",
"requestBody": {
"description": "body parameters should be passed as the order defined in chaincode function. First argument must be function name to call.",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/invoke"
}
}
}
},
"responses": {
"200": {
"description": "Chaincode Invoke Succesfull.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/invoke"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"invoke": {
"properties": {
"fcn": {
"type": "string"
},
"arg1": {
"type": "string"
},
"arg2": {
"type": "string"
}
}
}
}
}
}
这是我使用的明确配置.
Here is the express configuration I've used.
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
swaggerUi = require('swagger-ui-express')
swaggerDocument = require('./swagger.json');
app.use(bodyParser.urlencoded({ extended: true }));
var options = {
swaggerOptions: {
supportedSubmitMethods:["get", "post"]
}
};
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
还是应该将其作为错误发布到swagger-ui github?
Or maybe it should be posted to swagger-ui github as a bug?
推荐答案
我认为您还需要向服务器添加description
.像这样
I think you also need to add a description
to the server. Something like this
"servers": [
{
"description": "Local env",
"url": "http://localhost:3000/api"
}
]
这篇关于openAPI 3.0未显示API端点的“试用"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文