Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open api3.0 not showing try it out button for end points #2186

Closed
Salmandabbakuti opened this issue Mar 30, 2020 · 1 comment
Closed

open api3.0 not showing try it out button for end points #2186

Salmandabbakuti opened this issue Mar 30, 2020 · 1 comment

Comments

@Salmandabbakuti
Copy link

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? I've already posted the same on stackoverflow for help. but some stupid people are closing it as a duplicate by not knowing whether the question is having accepted answer or not.

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));

Or maybe it should be posted to swagger-ui github as a bug?

@MikeRalphson
Copy link
Member

I can't see anything wrong with your OpenAPI document, and it behaves fine with the online editor.swagger.io and the swagger-ui instance at http://petstore.swagger.io.

If you still have problems with swagger-ui, you are right, this should be raised as an issue on that repo, not here (which is for the specification itself only).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants