stringy05
stringy05

Reputation: 7067

Export list of API Paths from OpenAPI spec using swagger ui

I have a bunch of APIs that are documented as OpenAPI v3 specs.

Eg: foo.yaml, bar.yaml and baz.yaml

I also have a Web server that displays the specs in the swagger ui, so all my swagger models are easily consumable by devs, designers and so on.

My question: is there an easy way, using the javascript console, to give me a list of the resource paths?

I've had a quick look around the swagger ui source code but couldn't find anything useful, other than the SwaggerUIBundle object.

Upvotes: 1

Views: 2249

Answers (1)

Helen
Helen

Reputation: 97629

The API definition is accessible via ui.specSelectors.specJson(). The value is an Immutable.js Map.

You can use the following code to list all the paths:

let paths = ui.specSelectors.specJson().get("paths")
paths.mapKeys(key => console.log(key))

Upvotes: 2

Related Questions