Swagger with Restlet - Changing the URL

394 views
Skip to first unread message

hshorter

unread,
Oct 7, 2014, 12:32:15 PM10/7/14
to swagger-sw...@googlegroups.com
Hi,

I am using Swagger with Restlet, and successfully rendering in the Swagger UI.

My problem is the default URL is always being used, eg:


Whereas the protocol is https, the host is not localhost, the port is different and I would like to drop the v1 aspect of the URL entirely. 

Could someone help with this please? I've searched around the group but can't find any answers. I have tried setting basePath and apiVersion in the Restlet SwaggerSpecificationRestlet but they are not being shown in the resultant JSON.

Thanks.




Ron

unread,
Oct 7, 2014, 2:10:52 PM10/7/14
to swagger-sw...@googlegroups.com
Based on what you wrote, I assume your application uses Restlet's annotations and not JAX-RS annotations which is why you use Restlet's internal Swagger implementation and not swagger-core.
I'm not all that familiar with that implementation and it would be difficult for me to provide assistance with it.
I believe the proper place to ask related questions would be here - http://restlet.com/participate/.

If you post there and don't get a reply back, please let me know. We have a few contacts with Restlet's people so we may be able to help in getting them to respond.

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

hshorter

unread,
Oct 7, 2014, 2:48:26 PM10/7/14
to swagger-sw...@googlegroups.com
Thank you for the reply.

Yes, your assumptions are correct. 

I've posted into the Github issue tracking the Restlet Swagger work, but no reply so far (https://github.com/restlet/restlet-framework-java/issues/827)

I'm not sure where the default path is coming from. In the JSON provided by the server it uses a relative path of /Customers for the resourcePath. However basePath is not set.

Is Swagger UI inserting this default URL because basePath is not set? Is there a work around whereby I can change my deployed Swagger UI to swap out for my URL?

Many thanks.




Ron

unread,
Oct 7, 2014, 2:56:03 PM10/7/14
to swagger-sw...@googlegroups.com
Well, what do you see as the basePath value in the Swagger json you get from restlet?



hshorter

unread,
Oct 7, 2014, 3:25:26 PM10/7/14
to swagger-sw...@googlegroups.com
There is nothing in the top api-docs path, but then in /Customers I see:


So it must be set somehow in Restlet. I tried setting basePath in the top level SwaggerSpecificationRestlet.

Is there a way in the UI to do a replace upon reading the JSON, just until I get some help from the Restlet folks?

Thanks


Ron

unread,
Oct 7, 2014, 3:34:19 PM10/7/14
to swagger-sw...@googlegroups.com
The basePath is supposed to be declared in the api declarations (that is, in the files declared in /api-docs, like /Customers in your example).

So you tried using http://restlet.com/learn/javadocs/snapshot/jse/ext/org/restlet/ext/swagger/SwaggerSpecificationRestlet.html#setBasePath%28java.lang.String%29 and it didn't modify the json itself?



hshorter

unread,
Oct 7, 2014, 3:41:53 PM10/7/14
to swagger-sw...@googlegroups.com

That's correct, I've overridden getSwaggerSpecificationRestlet and called super to get the default SwaggerSpecificationRestlet, then called setBasePath on it before returning. From looking at the code the value of basePath isn't actually used anywhere, unless it's by reflection.

Thanks


Ron

unread,
Oct 7, 2014, 3:52:03 PM10/7/14
to swagger-sw...@googlegroups.com
That may not be the right way to configure it. From your SwaggerApplication, try calling http://restlet.com/learn/javadocs/snapshot/jee/ext/org/restlet/ext/swagger/SwaggerApplication.html#getSwaggerSpecificationRestlet%28org.restlet.Context%29 and then .setBasePath on that.

On 7 October 2014 22:41, hshorter <hsho...@gmail.com> wrote:

That's correct, I've overridden getSwaggerSpecificationRestlet and called super to get the default SwaggerSpecificationRestlet, then called setBasePath on it before returning. From looking at the code the value of basePath isn't actually used anywhere, unless it's by reflection.

Thanks


hshorter

unread,
Oct 7, 2014, 4:24:12 PM10/7/14
to swagger-sw...@googlegroups.com

Unfortunately that produces the same result. It seems the basePath doesn't get used where ever it is set.

Ron

unread,
Oct 7, 2014, 4:27:47 PM10/7/14
to swagger-sw...@googlegroups.com

Perhaps there is indeed a bug, though it surprises me as there are quite a few users of resltet and Swagger out there. Let's give the restlet people a chance to reply.

On Oct 7, 2014 11:24 PM, "hshorter" <hsho...@gmail.com> wrote:

Unfortunately that produces the same result. It seems the basePath doesn't get used where ever it is set.

--

hshorter

unread,
Oct 7, 2014, 4:51:14 PM10/7/14
to swagger-sw...@googlegroups.com
I have altered the handle method to intercept the JSON and replace the default path with the correct one, and the JSON is providing the correct response now (not ideal I know, but it gets me over the hurdle for now!)

However, when using the "Try It Now" nothing is returned. Could this be because HTTP Basic Auth is in use? Is there a way to set the credentials in the Swagger UI?

Many thanks. 

Jerome Louvel

unread,
Oct 8, 2014, 12:18:52 AM10/8/14
to swagger-sw...@googlegroups.com
Thanks for your question. Our Swagger extension for Restlet Framework is still pretty recent so it is possible that you hit some limitation.
I've forwarded your question to the developers in charge of this extension so they can provide a more concrete answer.

Best regards,
Jerome

Jerome Louvel

unread,
Oct 8, 2014, 9:29:25 PM10/8/14
to swagger-sw...@googlegroups.com
For those following this thread, the discussion has move to this ticket:
https://github.com/restlet/restlet-framework-java/issues/827

Jerome

Ron

unread,
Oct 9, 2014, 3:53:54 AM10/9/14
to swagger-sw...@googlegroups.com
Thank you for the update, Jerome!

--
Reply all
Reply to author
Forward
0 new messages