Swagger-ui: Stuck at fetching resource list: http://localhost:9000/docs/swagger.json; Please wait.

Created on 19 Aug 2016  路  4Comments  路  Source: swagger-api/swagger-ui

I am a newbie to swagger and i am stuck after doing the following things on an error:
I am using the following dependencies:

  • "com.iheart" %% "play-swagger" % "0.2.1-PLAY2.5",
  • "org.webjars" % "swagger-ui" % "2.1.4"

Following are the routes:
image

Following is the expected response type:
case class Output(response: JsValue)

This is the screenshot of where i am getting struck:

image

This is what i get in the auto generated json file(where it gets struck with error : fetching resource list):

{"paths":{"/assets/{file}":{"get":{"tags":["routes"],"parameters":[{"name":"path","type":"string","required":true,"in":"query"},{"name":"file","type":"asset","required":true,"in":"path"}]}},"/docs/swagger.json":{"get":{"tags":["routes"],"summary":"swagger definition","description":"for swagger UI to consume"}},"/client/view":{"get":{"tags":["routes"],"responses":{"200":{"description":"success","schema":{"$ref":"#/definitions/models.Output"}}}}}},"definitions":{"models.Output":{"properties":{"response":{"type":"play.api.libs.json.jsvalue","required":true}},"required":["response"]}},"tags":[{"name":"routes"}]}

and this is my default swagger.json file(which i have created) :
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Weather API",
"description": "A sample API that uses a Mashape weather API as an example to demonstrate features in the swagger-2.0 specification",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "Tom Johnson",
"email": "[email protected]",
"url": "localhost:9000"
},
"license": {
"name": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
},
"host": "localhost:9000",
"basePath" : "localhost:9000",
"schemes": [
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/text"
]
}

I am refering to link : https://github.com/iheartradio/play-swagger

Most helpful comment

鎴戜篃閬囧埌浜嗗悓鏍风殑闂锛屾ゼ涓昏В鍐充簡涔堬紵

All 4 comments

Hi! It seems your swagger.json file is incomplete.
It should have a "definitions" property defining the types used by your REST operations.

Actually i am using iheartradio/play-swagger : (https://github.com/iheartradio/play-swagger)
It only ask for minimum swagger.json file:
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Weather API",
"description": "A sample API that uses a Mashape weather API as an example to demonstrate features in the swagger-2.0 specification",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "Tom Johnson",
"email": "[email protected]",
"url": "localhost:9000"
},
"license": {
"name": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
},
"host": "localhost:9000",
"basePath": "/docs",
"schemes": [
"https",
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
]
}

and automatically generates the paths and definitions using the routes file.
Following is the demo project which i have created using the same:

https://github.com/SangeetaGulia/testSwagger

in brief:
These are the routes: # Routes
image

and these are the paths and definitions generated for my routes :
{
"paths":{
"/":{
"get":{
"tags":["routes"],
"responses":{
"200":{
"description":"success",
"schema":{
"$ref":"#/definitions/models.Test"
}
}
}
}
},
"/docs/swagger.json":{
"get":{
"tags":["routes"],
"summary":"swagger definition",
"description":"for swagger UI to consume"
}
}
},
"definitions":{
"models.Test":{
"properties":{
"name":{"type":"string"}
},
"required":["name"]
}
},
"tags":[{"name":"routes"}]
}

It contains definitions, but still i am getting the same error. Am i missing on something??
Is there any other way to auto generate the spec from my routes.??

Please try the latest version.

鎴戜篃閬囧埌浜嗗悓鏍风殑闂锛屾ゼ涓昏В鍐充簡涔堬紵

Was this page helpful?
0 / 5 - 0 ratings