Forum Discussion

malik_nisha's avatar
Occasional Visitor
10 months ago

Render Html pages coming as response of get API

Hi Team,
i am new to swagger-ui and this is my very first post on the community here.
I am trying to get authcode implemented in an api which is a two step process as follows
1. Make a get call to a URL which sends back the response with an HTML form asking for username/password.
2. when we submit the form on browser there is a code which gets generated as a Query parameter in the URL.

I want to render the HTLM form from the first request in the swagger-ui as an HTML where user can fill-in information and submit the page.
can we achieve this is the out of the box(oob) swagger-ui?
if yes can someone provide the link to configure this please.


if this is not possible can i get the documentation somewhere in swagger-ui documentation.


Thanks in advance.

2 Replies

  • nehakakar's avatar
    Occasional Contributor

    You can use libraries like fetch or axios to make the HTTP request.

    for more detail check this doc

  • Hi malik_nisha,


    It sounds like you're trying to implement an OAuth 2.0 or OpenID Connect server. The implementation of such is outside of the scope of Swagger tooling.


    If you have such a server in place (or even better if you use a battle testing identity provider), then you can leverage it to protect your APIs using OpenAPI spec. See the OAuth 2.0 docs for information on how to configure the security schemes.


    Once an API description (i.e. an OpenAPI definition) has been setup correctly with the relevant security schemes and the path items require security, then the `Authorize` button in SwaggerUI will render the appropriate form for you to enter the appropriate data and communicate with the configured OAuth provider.


    You can also set the OAuth configuration before user interaction, you can also refer to here

    Hope this helps.