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.59k stars 8.96k forks source link

How do we Navigate to specific resources in the SwaggerUI #1667

Closed Jindam closed 7 years ago

Jindam commented 9 years ago

Hi, I want to go to specific Resource by appending .../swagger/ui/index/Appoinments Here,it should navigate to Appointments Controller

webron commented 9 years ago

Do you mean display only that resource in the UI or directly open it? Linking to specific resources can be done by something like http://petstore.swagger.io/#!/pet but you can't filter out a single resource only.

Jindam commented 9 years ago

Thanks for your reply,I can able to browse list of controllers when I navigate to http://localhost:10000/swagger/ui/index#/. Can we select the particular controller by appending in the route URL,Something like this http://localhost:10000/swagger/ui/index#/Appointments. Here,Appointments is the controller name from the list.So that,I can view only particular controller not all the controllers.

webron commented 9 years ago

Right now, the only way to do that is by having a different Swagger definition for each controller.

Jindam commented 9 years ago

I have more than 100 controllers in the application,so adding definition each time doesn't make application consistent. Is this requirement can be customized by swagger.?

webron commented 9 years ago

Which tool do you use to generate your Swagger definition?

Jindam commented 9 years ago

VisualStudio 2015

Jindam commented 9 years ago

Can we upload documents to SwaggerUI as a binary file

webron commented 9 years ago

Not sure I follow the last question.

kbadiger commented 5 years ago

Hi , i have created the restfull apis document by swagger editor , i have a navigation isssue , for example the url is https://petstore.swagger.io/#/pet/updatePet , whem you click this it will redirecting to main page instead of the next page , please help me to overcome from this

vsix27 commented 1 year ago

that is doable with js...

  1. open swagger ui with dev tools - you can see that apis are spans with attribute data-path="/aaa/bbb" - so the solution would be to inject before each span and call it for navigation
  2. to redecorate these spans you need to inject js (options.InjectJavascript("/swagger-nav.js");) which will scan all spans after swagger ui loaded - create your scanning js function , say 'onLoadNav()' and in your js call it via
  3. var checkExist = setInterval(function () { // if that is too soon, consider "operations-tag-User" if (document.getElementById("swagger-ui") == null) return; clearInterval(checkExist); onLoadNav(); }, 500);