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

Stuck at fetching resource list: http://localhost:9000/docs/swagger.json; Please wait. #101

Closed
SangeetaGulia opened this issue Aug 19, 2016 · 12 comments

Comments

@SangeetaGulia
Copy link
Contributor

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": "tomjohnson1492@gmail.com",
"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"
]
}

@kailuowang
Copy link
Member

Hmm, it's not obvious to me why you are getting that error from swagger ui. Do you want to click into that js error to see the code that throws the "cannot read property definitions of null"?

@SangeetaGulia
Copy link
Contributor Author

SangeetaGulia commented Aug 19, 2016

Heres the js statements which is throwing this error :
image

Can you please share the controllers code which you have mentioned in the documentation:
-> /api/cards cards.Routes
-> POST /users/:profileId/contexts/:contextName/cards controllers.api.Cards.createCard(profileId: Int, contextName: Option[String])

It will be very helpful.

@kailuowang
Copy link
Member

I can't tell from this code where the error "the property definitions of null" comes from
in your screenshot it was swagger-ui.js?
The controller code doesn't matter (plus I don't have that code available). PlaySwagger doesn't try to parse controller.

@SangeetaGulia
Copy link
Contributor Author

Yes the error is coming from swagger-ui.js. For more reference i have created a simple demo project to use swagger. Following is the link to the repository:

https://github.com/SangeetaGulia/testSwagger

and i am getting the same error in this code too when i try to hit the url to get swagger-ui.
Any help will be appreciated.

@kailuowang
Copy link
Member

from your example, I noticed that you are using an old version of play swagger, would you mind update to the 0.4.0 first? No need for the PLAY2.5 suffix any more.

@SangeetaGulia
Copy link
Contributor Author

Updated the version, but the same problem still persists :(
Anything else that i need to do???

@kailuowang
Copy link
Member

kailuowang commented Aug 20, 2016

Can you try with a minimum swagger base json? Keep only the required fields, like swagger version and host.

@kailuowang
Copy link
Member

I am going to setup an example project in the next couple of days. If you can wait that might help too.

@SangeetaGulia
Copy link
Contributor Author

In the demo project : https://github.com/SangeetaGulia/testSwagger (this is the same project whose link i have mentioned earlier),

I have used only :
{
"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",
},
"host": "localhost:9000",
"basePath": "/docs",
"schemes": [
"https",
"http"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
]
}
as minimum swagger base json.

Is there anything which i am missing???

@SangeetaGulia
Copy link
Contributor Author

Actually i need to do it in next two days. You can use the demo project i have created, it may help me too to get the solution earlier. May be i am missing out something important.

@SangeetaGulia
Copy link
Contributor Author

Hey,
The error is resolved. After putting swagger.json into conf folder of the project the problem is resolved.
Thanks for your help too.

I just want to ask one more question is there any way to configure on what can be the location to store swagger.json?

@kailuowang
Copy link
Member

play-swagger reads swagger.json from resources. currently there is no way in play-swagger json to read from a location outside resources. I am glad that you resolved the issue. Thanks for the feedback!

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