swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

"Try It Out" request wrong path : not including app base path

Open toshim45 opened this issue 12 years ago • 2 comments

Hello!! I have an apps which use Spring MVC 3.2.8, Swagger-springmvc 0.8.5 & Swagger UI. I successully setup all of those and open the UI from browser. I have a controller called home, it has GET request method, and just return string screen shot 2014-08-15 at 8 14 05 am But when I executed it from "try it out" screen shot 2014-08-15 at 8 20 42 am the request url is wrong.

This is my api-docs :

http://localhost:8080/my-app/api-docs
{
    "apiVersion": "1.0",
    "swaggerVersion": "1.2",
    "apis": [
        {
            "path": "/default/home-controller",
            "description": "Home Controller"
        }
    ],
    "info": {
        "title": "default Title",
        "description": "Api Description",
        "termsOfServiceUrl": "Api terms of service",
        "contact": "Contact Email",
        "license": "Licence Type",
        "licenseUrl": "License URL"
    }
}

I can open the swagger api home controller

http://localhost:8080/my-app/api-docs/default/home-controller
{
    "apiVersion": "1.0",
    "swaggerVersion": "1.2",
    "basePath": "/",
    "resourcePath": "fix this",
    "apis": [
        {
            "path": "/home",
            "description": "home",
            "operations": [
                {
                    "method": "GET",
                    "summary": "home",
                    "notes": "home",
                    "type": "string",
                    "nickname": "home",
                    "parameters": [ ],
                    "responseMessages": [
                        {
                            "code": 404,
                            "message": "Not Found"
                        },
                        {
                            "code": 403,
                            "message": "Forbidden"
                        },
                        {
                            "code": 401,
                            "message": "Unauthorized"
                        },
                        {
                            "code": 200,
                            "message": "OK",
                            "responseModel": "string"
                        }
                    ],
                    "deprecated": "false"
                }
            ]
        }
    ]
}

I use xml spring configuration screen shot 2014-08-15 at 8 53 24 am

My questions are

  1. where should I set the basePath "my-app" ? so the "try it out" will executed to the right URL
  2. is the "default" word in "path": "/default/home-controller", is normal ?
  3. where can I set API info on the api-docs ?

Thanks in advance.

toshim45 avatar Aug 15 '14 01:08 toshim45

I'd strongly recommend reading the documentation of https://github.com/martypitt/swagger-springmvc and see how to set up the basePath (which is missing) and possibly understand why the /default is added to your path.

This is not really a swagger-ui problem but rather one related with swagger-springmvc, so if you still have an issue after reading their docs, please open an issue on their repository.

webron avatar Aug 15 '14 06:08 webron

thx @webron sorry for false post :)

toshim45 avatar Aug 15 '14 23:08 toshim45