swagger-api / swagger-api/swagger-ui

Are swagger-ui/swagger-ui-react packages designed to handle dynamic apidocs ?

Open
#10,711 0 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

  • Browser: [chrome]
  • Version: [5.31.0]
  • Method of installation: [npm install swagger-ui-react]
  • Swagger-UI version: [5.31.0]
  • Swagger/OpenAPI version: [OpenAPI 3.2]

Swagger-UI configuration options:

    const { spec } = useApiDoc(specId);

      <SwaggerUI
        spec={spec}
        persistAuthorization={false}
        withCredentials
        tryItOutEnabled={false}
        supportedSubmitMethods={[]}
      />

Hello,

I am building React app that allows to search for API docs. Those API docs are returned by external endpoint as JSON.

I have observed an issue, when feeding specs to SwaggerUI component, some parts of it are out of sync. For example when I select api doc X, and then api doc Y and schema definitions are not updating, still displaying content of api doc X. The rest of the content seems OK (endpoint definitions and api description). Tried to use pure JavaScript version of Swagger UI package (no React) but the effect remains the same. I have also tried to manually remove Swagger component from DOM and re-mount it with new data, but it didn't help either. I have noticed that SwaggerUI uses Redux & ImmutableJS, but I didn't find any hooks that would allow to interact with internal SwaggerUI state.

So my questions it:

How do I handle dynamic api docs in Swagger UI ? Is Swagger UI designed to handle dynamic data ?
I have search all issues on GitHub and docs, but didn't find similar issue.

Thanks.

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 component and its Redux and ImmutableJS state handling, then reproduce the issue by switching from API doc X to API doc Y through the dynamic spec prop. Done means the displayed schema definitions update along with the endpoint definitions and API description.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react, redux
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.