swagger-api / swagger-api/swagger-ui

Swagger React: change value of parameters upon click of "try it out"?

Open
#5,605 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: Windows 10
  • Browser: Chrome
  • Version: 76.0.3809.132 (Official Build) (64-bit)
  • Method of installation: swagger-ui-react node module
  • Swagger-UI version: ^3.23.9
  • Swagger/OpenAPI version: Swagger 2.0
  • Using this along with: react - v16.8.6
Content & configuration

Swagger/OpenAPI definition:

https://petstore.swagger.io/v2/swagger.yaml

Swagger-UI configuration options:

return (
    <div className="api-doc-page-wrapper">
      <SwaggerUI
        url="https://petstore.swagger.io/v2/swagger.yaml"
        withCredentials
        requestInterceptor={req => console.log(req)}
        responseInterceptor={res => console.log(res)}
      />
    </div>
  );
How can we help?
  1. Is it possible to pass in values to the parameters once I get some values?
    Eg. If I were to generate a token separately, can I pass it in with some values to autofill some of the parameters when "try it out" button has been clicked?

image

  1. Is it normal for requestInterceptor and responseInterceptor to be called when the swagger component is mounted and rendered without any execution button clicked?

image

Any help in understanding the Swagger process will be appreciated. Thank you in advance...!!...:D

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SwaggerUI React component and trace the Try It Out flow alongside the requestInterceptor and responseInterceptor entry points. Determine whether parameter values can be supplied at that point and why the interceptors run during mounting; done means the supported behavior and required change are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.