Swagger UI - PHP integration

1,568 views
Skip to first unread message

Anoop Ambalapuzha

unread,
Sep 9, 2014, 2:51:46 AM9/9/14
to swagger-sw...@googlegroups.com
Hi All,

I am a new user in swagger.  I want to know some basic steps, I google my requirement but didn't get a enough tutorial.

I have a PHP project which has many API response and I need to integrate with swagger. For that purpose,

> I have added swagger-ui in my work-space

I have replaced the URL as described in README.md, 

window.swaggerUi = new SwaggerUi({
     // url: "http://petstore.swagger.wordnik.com/api/api-docs",   // this line is commented
     url: "http://my-api-url",
     dom_id: "swagger-ui-container",  
-----------------
----------------

But when i refresh ui (http://localhost/swagger-ui/dist/), this error message will happen ->   " Can't read from server. It may not have the appropriate access-control-origin settings. "

I know there are something more parameters should be defined, but I don't know where it is.
I have download a swagger php folder (swagger-php). Do I need to config anything here ?

Can you please help me to test even a single php api with swagger UI ?

Thanks
swa.png

Ron

unread,
Sep 9, 2014, 3:35:46 AM9/9/14
to swagger-sw...@googlegroups.com
You need to enable CORS support. https://github.com/wordnik/swagger-core/wiki/CORS

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anoop Ambalapuzha

unread,
Sep 9, 2014, 5:16:40 AM9/9/14
to swagger-sw...@googlegroups.com
Thanks for the suggestion. I understand that if am using different domain for projects and swagger , its useful. But now I updated both domain as same. Again showing same error message. Please help........... 

Ron

unread,
Sep 9, 2014, 5:29:38 AM9/9/14
to swagger-sw...@googlegroups.com
Not just the same domain, the same application server. Even if it's on the same machine, you'd need to enable CORS. That's what the error means.

Triju Issac

unread,
Sep 19, 2014, 2:14:05 AM9/19/14
to swagger-sw...@googlegroups.com
I am a php developer. I am new to Swagger. I want to implement Swagger to my project. I am not able to find a way to start. I have attached a sample rest api. Can you guys tell me how can i implement Swagger to this api requests.
 
 
api.php

Ron

unread,
Sep 19, 2014, 5:46:21 AM9/19/14
to swagger-sw...@googlegroups.com
The first step would be to go to the list of PHP implementations (https://github.com/wordnik/swagger-spec/#php), pick the one that suits your needs and follow its documentation.

On 19 September 2014 09:14, Triju Issac <triju...@cabotsolutions.com> wrote:
I am a php developer. I am new to Swagger. I want to implement Swagger to my project. I am not able to find a way to start. I have attached a sample rest api. Can you guys tell me how can i implement Swagger to this api requests.
 
 

--
Reply all
Reply to author
Forward
0 new messages