Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger ui url with parameters

How to pass base url in the form http://localhost:3000/resources/api/?key=aslkdajd1323121lklakskdl to swagger ui ?

I was able to access http://localhost:3000/resources/api but when I add auth filter and pass key, it says, Unauthorized.

Using swagger 1.X

Pre-populating the parameter through apiKeyauthorization in index.html did not help, but when I type in the key in UI, it worked. Unable to understand the reason for this. Hope someone can help me make sense out of it.

like image 830
Jacaro Avatar asked Oct 31 '22 01:10

Jacaro


1 Answers

Try this swagger 2.0 file (use http://studio.restlet.com to downgrade to version 1.2) :

{
    "swagger": "2.0",
    "info": {
        "version": "0.0.1",
        "title": "Todo App"
    },
    "host": "localhost:3000",
    "schemes": [
    "http"
    ],
    "paths": {
        "/resources/api": {
            "post": {
                "parameters": [
                    {
                        "name": "key",
                        "in": "query",
                        "description": "key",
                        "required": true,
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response"
                    }
                }
            }
        }
    }
}
like image 158
Nelson G. Avatar answered Nov 15 '22 06:11

Nelson G.