Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Customizing Swagger-js for vendor extensions #863

Closed
scout387 opened this issue Sep 22, 2016 · 2 comments
Closed

Customizing Swagger-js for vendor extensions #863

scout387 opened this issue Sep 22, 2016 · 2 comments

Comments

@scout387
Copy link

scout387 commented Sep 22, 2016

Hello,

I will start with the example of I want to simulate.
Go to: http://docs.sencha.com/extjs/4.2.5/#!/api

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

@fehguy
Copy link
Contributor

fehguy commented Sep 27, 2016

Hi, your approach is correct, adding support inside the swagger-js client then exposing them in swagger-ui.

@fehguy
Copy link
Contributor

fehguy commented Oct 12, 2016

#869 adds all extensions to the client prototype.

@fehguy fehguy closed this as completed Oct 12, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants