swagger-codegen apis path

465 views
Skip to first unread message

polarice

unread,
Nov 12, 2014, 6:08:16 PM11/12/14
to swagger-sw...@googlegroups.com
I set my api's path in api-docs to /issue/get.
When I run the BasicPHPGenerator, it is trying to find the controller action at http://localhost.example.com/api-docs/issue/get.
The controller action is actually at http://localhost.example.com/issue/get (without api-doc), so it results in a 404 when I browse to it.

This is the command that I run to generate the client libraries in PHP.
./bin/runscala.sh com.wordnik.swagger.codegen.BasicPHPGenerator http://localhost.example.com/api-docs

When this runs, I get an exception that it can't find http://localhost.example.com/api-docs/login/get (since the actual controller/action is not located there).

How can I change the path to not contain "api-docs"?

Ron

unread,
Nov 13, 2014, 1:49:41 AM11/13/14
to swagger-sw...@googlegroups.com

What's the basePath value?

--
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.

polarice

unread,
Nov 13, 2014, 10:03:14 AM11/13/14
to swagger-sw...@googlegroups.com

Ron

unread,
Nov 13, 2014, 10:04:28 AM11/13/14
to swagger-sw...@googlegroups.com
So that's why it runs it all under api-docs.
The basePath should represent the context root of your application, not the documentation.

--

polarice

unread,
Nov 13, 2014, 10:20:20 AM11/13/14
to swagger-sw...@googlegroups.com
Yes, but I had to specify the location of the api-docs for BasicPHPGenerator.
./bin/runscala.sh com.wordnik.swagger.codegen.BasicPHPGenerator http://localhost.example.com/api-docs
It uses that parameter as both the location of api-docs and context root of my application. Is there any way to have these two values separate?
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron

unread,
Nov 13, 2014, 10:52:09 AM11/13/14
to swagger-sw...@googlegroups.com
Those two are separate. Even if you don't use the codegen, Swagger-UI will not be able to produce the proper API calls with that basePath.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

polarice

unread,
Nov 13, 2014, 11:03:35 AM11/13/14
to swagger-sw...@googlegroups.com
I tried specifying a basePath in api-docs file but it is still trying to locate http://localhost.example.com/api-docs/issue/get.
How would I specify the location of api-docs separate from the basePath?


On Thursday, November 13, 2014 10:52:09 AM UTC-5, Ron R wrote:
Those two are separate. Even if you don't use the codegen, Swagger-UI will not be able to produce the proper API calls with that basePath.
On 13 November 2014 17:20, polarice <yute...@gmail.com> wrote:
Yes, but I had to specify the location of the api-docs for BasicPHPGenerator.
./bin/runscala.sh com.wordnik.swagger.codegen.BasicPHPGenerator http://localhost.example.com/api-docs
It uses that parameter as both the location of api-docs and context root of my application. Is there any way to have these two values separate?

On Thursday, November 13, 2014 10:04:28 AM UTC-5, Ron R wrote:
So that's why it runs it all under api-docs.
The basePath should represent the context root of your application, not the documentation.
On 13 November 2014 17:03, polarice <yute...@gmail.com> wrote:
The base path is http://localhost.example.com/api-docs


On Thursday, November 13, 2014 1:49:41 AM UTC-5, Ron R wrote:

What's the basePath value?

On Nov 13, 2014 1:08 AM, "polarice" <yute...@gmail.com> wrote:
I set my api's path in api-docs to /issue/get.
When I run the BasicPHPGenerator, it is trying to find the controller action at http://localhost.example.com/api-docs/issue/get.
The controller action is actually at http://localhost.example.com/issue/get (without api-doc), so it results in a 404 when I browse to it.

This is the command that I run to generate the client libraries in PHP.
./bin/runscala.sh com.wordnik.swagger.codegen.BasicPHPGenerator http://localhost.example.com/api-docs

When this runs, I get an exception that it can't find http://localhost.example.com/api-docs/login/get (since the actual controller/action is not located there).

How can I change the path to not contain "api-docs"?

--
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-swaggersocket+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron

unread,
Nov 13, 2014, 11:08:56 AM11/13/14
to swagger-sw...@googlegroups.com
I'm not sure I follow. How would you specificy the location of api-docs in what?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

polarice

unread,
Nov 13, 2014, 11:32:01 AM11/13/14
to swagger-sw...@googlegroups.com
I am running the following command:
./bin/runscala.sh com.wordnik.swagger.codegen.BasicPHPGenerator http://localhost.example.com/api-docs

I get the following output:
java.io.FileNotFoundException: http://localhost.example.com/api-docs/login/get

It is assuming that /login/get is relative to http://localhost.example.com/api-docs based on the second parameter that is passed in (in red).
How would I change the base path to be just http://localhost.example.com/.

Their assumed base path: http://localhost.example.com/api-docs
Actual base path: http://localhost.example.com/

Ron

unread,
Nov 13, 2014, 11:33:25 AM11/13/14
to swagger-sw...@googlegroups.com
Can you share your swagger json(s)?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

polarice

unread,
Nov 13, 2014, 11:57:33 AM11/13/14
to swagger-sw...@googlegroups.com
This is the api-docs json
{
   "apiVersion":"1.0.0",
   "swaggerVersion":"1.2",
   "apis":[
      {
         "path":"/login/get",
         "description":"Operation about login"
      },
      {
         "path":"/issue/get",
         "description":"Operations about issue"
      }
   ],
   "authorizations":{
      "apiKey":{
         "type":"apiKey",
         "passAs":"header",
         "keyname":"apikey"
      }
   }
}

The other json files aren't found by swagger-codegen because of the relative url problem mentioned above. Thank you.

Ron

unread,
Nov 13, 2014, 12:32:20 PM11/13/14
to swagger-sw...@googlegroups.com
Right, and what's the json you get when you go to /api-docs/login/get?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

polarice

unread,
Nov 13, 2014, 12:39:03 PM11/13/14
to swagger-sw...@googlegroups.com
The json file is not located in /api-docs/login/get so it is error 404. The json file is actually in /login/get. If it has the correct url, everything works fine.

Ron

unread,
Nov 13, 2014, 12:47:26 PM11/13/14
to swagger-sw...@googlegroups.com
Then something is messed up with your swagger documentation.

The way it works, the /api-docs will list the resources (the "apis") and each path produces a detailed information with the given path for that "api". In your case, it would be /api-docs/login/get and /api-docs/issue/get.

If those paths don't return anything, then something is wrong.

Which library do you use to produce your swagger docs?

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

polarice

unread,
Nov 13, 2014, 1:05:38 PM11/13/14
to swagger-sw...@googlegroups.com
The doc was written manually, what library do you recommend?

Ron

unread,
Nov 13, 2014, 1:09:49 PM11/13/14
to swagger-sw...@googlegroups.com
Oh! I thought that's an auto-generated documentation.

Do you have an existing server that you're documenting or is it a design-first approach?

If it's design-first, I'd suggest moving to Swagger 2.0 and using our editor, whether online (editor.swagger.io) or locally (https://github.com/wordnik/swagger-editor).

If it's an existing server, let me know which language/framework you use.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

polarice

unread,
Nov 13, 2014, 1:13:14 PM11/13/14
to swagger-sw...@googlegroups.com
It is an existing server, we're using Zend.

Ron

unread,
Nov 13, 2014, 1:15:17 PM11/13/14
to swagger-sw...@googlegroups.com
The known PHP implementations can be found here - https://github.com/swagger-api/swagger-spec#php

I can't recommend one over the other as I've never used PHP nor those libraries. It seems swagger-php is most popular, but I cannot say whether it is the best fit for your needs.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages