swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.57k stars 8.96k forks source link

Are there "expandOperation" or "expandEndpointListForResource" in new SwaggerUI? #4313

Open LuoPQ opened 6 years ago

LuoPQ commented 6 years ago

We can use Docs.expandOperation or Docs.expandEndpointListForResource to expand a section in the old version, but I can't find some functions like these, are they removed in new SwaggerUI?

shockey commented 6 years ago

Correct, they haven't been implemented in v3 (yet?)

You can use the private layoutActions API if you'd like to get this functionality today.

LuoPQ commented 6 years ago

@shockey how should I do with layoutActions, could you plz give me an exmaple?

shockey commented 6 years ago

Sure.

To expand/collapse a tag:

// talk about a specific tag on the page with:
// ["operations-tags", (tag name)]
ui.layoutActions.show(["operations-tag", "pet"], true) // show
ui.layoutActions.show(["operations-tag", "pet"], false) // hide

To expand/collapse an operation:

// talk about a specific operation on the page with:
// ["operations", (tag that operation is under), (operationId)]
ui.layoutActions.show(["operations", "pet", "addPet"], true) // show
ui.layoutActions.show(["operations", "pet", "addPet"], false) // hide

Do note that since this is a private API, it may change between minor versions (e.g. between 3.13.1 and 3.14.0). Plan accordingly!

v-vashchenko commented 5 years ago

is there a way to hide all tags?