Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Hide endpoints based on yaml/spec #1743

Closed
GiladShoham opened this issue Nov 12, 2015 · 3 comments
Closed

Hide endpoints based on yaml/spec #1743

GiladShoham opened this issue Nov 12, 2015 · 3 comments

Comments

@GiladShoham
Copy link

Hi,

I want to add some attribute to my yaml spec for example x-hide : true/false so that the swagger-ui will know to not show those endpoints.
i can't remove them completely from the yaml because im using swagger-node / swagger-express-mw so it's define the express mw based on this yaml, so if i remove them i can't use them at all.
i want them to be reachable but just not presented on the ui (because documentaion isn't ready yet / because they are mostly internally APIs that doesn't interest for the API users).
is there any way to do it?
maybe someone can help me to the best way to do it if there isn't out of the box?

Thanks.

@fehguy
Copy link
Contributor

fehguy commented Nov 12, 2015

Hi, this is for swagger-node to do. Can you please open a ticket in that project? For example, the swagger-inflector allows x-inflector-hidden to create the route but not expose the route in the documentation.

@wvengen
Copy link

wvengen commented Nov 18, 2016

While it's probably best to do this in the json/yaml file, one can use this hack in index.html. Insert between window.swaggerUi = ... and window.swaggerUi.load():

      // hack to filter out internal endpoints, operations and parameters before rendering
      var oldSuccess = window.swaggerUi.getOption('success');
      function filterInternal(x) { return x['x-hide'] !== true && (x['vendorExtensions']||{})['x-hide'] !== true; };
      window.swaggerUi.setOption('success', function() {
        var client = window.swaggerUi.api;
        client.apisArray = client.apisArray.filter(filterInternal);
        client.apisArray.forEach(function(api) {
          api.operationsArray = api.operationsArray.filter(filterInternal);
          api.operationsArray.forEach(function(op) {
            op.parameters = op.parameters.filter(filterInternal);
          });
        });
        return oldSuccess();
      });

@webron
Copy link
Contributor

webron commented Jun 9, 2017

You should be able to write a plugin to the new UI to add that functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants