How to bring Swagger UI’s Closed Ollapse

Asked

Viewed 94 times

0

I installed Swagger for software documentation but would like to change the preview of my template. I managed to close Collapse when loading the page forcing a javascript when starting, but it got a small bug, because I have to click twice to work.

I did something like this:

$(document).ready(function() {
  $('.opblock-tag-section').find('div').slideUp();
  $('.opblock-tag-section').click(function(){
    $(this).find('div').slideToggle();
  });
});

I did it using, "display", "None" in the div too, and then I sent a "block" to show it again. Even so it gives a lock and only works in the second click. Does it have something to do with the json loading of my api in Swagger? I wondered that, because it mounts the interface via the json call, and I’m changing the behavior of Collapse after it’s loaded.

1 answer

0

I don’t know You still need it, but I’ll answer in case someone else needs it.

In Swaggerconfig in this part here:

.EnableSwaggerUi(c =>
                    { 
                       c.DocExpansion(DocExpansion.List);

DocExpansion.List for Collapse and DocExpansion.Full for Expanded

Browser other questions tagged

You are not signed in. Login or sign up in order to post.