Customizing Swagger-UI for a Custom Field "x-foo" in swagger.json

435 views
Skip to first unread message

Carlos Angel M Rivera Pagan

unread,
Sep 22, 2016, 11:46:42 AM9/22/16
to Swagger
Hello community,

I will start with the example of I want to simulate.

Below the Tree View for the API documentation, there is a "Show private classes" checkbox. By default they only show the API of the classes you will use, but for your convenience, they offer the option to see the internal classes (which are not recommended to use), you just have to check "Show private classes". 

So, in my company we are using older versions of Swagger, and we want to upgrade to newest versions. We have a similar situation with EXTjs. We have a REST API, and we documented all our routes for the convenience of our clients, and developers. But now we would like to differentiate between internal routes used by our developers, and the external routes used by our clients.

I have read most of Swagger's documentation, and I realized that I will have to implement it by myself.

My first approach was:
1) Added a custom field to the Swagger "x-internal" which can hold a boolean.
2) I would customize Swagger-UI to get that API, read the "x-internal" field, and finally just display what the user wants to see.

My problem is:
I noticed that Swagger-UI depends on SwaggerClient, which is doing the hard work. SwaggerClient is not consuming the "x-internal" field, and it strip it away.


So! I am here to see if someone has done something similar to this, and/or if they have a better approach.  I am guessing that I will have to customize first Swagger-js, and then customize Swagger-UI.
I think I understand quite well (or at least partially well) Swagger-UI, but now I will have to understand the source code of Swagger-js, so it will be of great help if you guys could give me hits of where I need to do the changes.

Thank you all!

Ron Ratovsky

unread,
Sep 22, 2016, 2:04:15 PM9/22/16
to swagger-sw...@googlegroups.com

Hi Carlos,

 

I’d suggest starting off by opening a ticket on swagger-js and we’ll take it from there.

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

Carlos Angel M Rivera Pagan

unread,
Sep 22, 2016, 2:23:37 PM9/22/16
to Swagger
Hey Ron,

I am new to all this. Do you mean an issue at the swagger-js GitHub project?

Thank you, by the way, you guys reply super fast, I am impressed.

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

Ron Ratovsky

unread,
Sep 22, 2016, 2:33:41 PM9/22/16
to swagger-sw...@googlegroups.com

Yes, https://github.com/swagger-api/swagger-js.

 

IIRC, you are right that we currently don’t expose all vendor extensions, but we with your help, we can probably get to a point where we expose what’s relevant to you.

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.

--

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.

Reply all
Reply to author
Forward
0 new messages