[openAPI 3.0未显示API端点的试用按钮

问题描述 投票:0回答:1

不幸的是,我已经使用swagger openapi3.0配置了我的api,但没有显示我的API端点的try it out按钮。我是否缺少swagger文件中的任何配置?谁能帮我解决这个错误?here is the link to screenshot

注意:我正在使用开放式API3.0这是我使用的配置:


{
  "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": "[email protected]",
      "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"
          }
        }
      }
    }
   }
}

这是我使用的明确配置。

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?

node.js api swagger swagger-ui openapi
1个回答
0
投票

我认为您还需要向服务器添加description。像这样的东西

"servers": [
 {
  "description": "Local env",
  "url": "http://localhost:3000/api"
 }
]
© www.soinside.com 2019 - 2024. All rights reserved.