Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Custom Layout #6193

Closed
wregis opened this issue Jun 30, 2020 · 2 comments
Closed

React Custom Layout #6193

wregis opened this issue Jun 30, 2020 · 2 comments

Comments

@wregis
Copy link

wregis commented Jun 30, 2020

Q&A

  • OS: any
  • Browser: any
  • Version: any
  • Method of installation: npm
  • Swagger-UI version: 3.28.0
  • Swagger/OpenAPI version: any

Content & configuration

None yet

Swagger/OpenAPI definition:
Using pet store sample definition

Swagger-UI configuration options:

SwaggerUI({
  dom_id: '#root',
  url: "https://petstore.swagger.io/v2/swagger.json",
  plugins: [ MyLayoutPlugin ],
  layout: "MyLayout"
})

How can we help?

It was not clear to me how to customize the UI appearance.

It seems that React is the recommended way to do so, but the SwaggerUI from swagger-ui-react component does not expose a "layout" property as the function from swagger-ui. If there's a way to go beyond this, will I be able to update the url property dynamically?

I want to make an API doc able to list multiple definition (based on client and version) through a list and with the functional method, I can't figure out a elegant way to achieve that.

The getComponent property is also not clear to me on which components are available. Is the only way to know that to read the entire source code?

@cbo100
Copy link
Contributor

cbo100 commented Sep 2, 2020

See #5367 for more discussion

@tim-lai
Copy link
Contributor

tim-lai commented Oct 6, 2020

@wregis If you are able to use swagger-ui instead of swagger-ui-react, you can create a SwaggerUI plugin that replaces and/or extends the BaseLayout. For example, swagger-editor is a plugin to swagger-ui, and uses a "custom" layout. Documentation for SwaggerUI Plugin API can be found here: https://swagger.io/docs/open-source-tools/swagger-ui/customization/overview/

As noted by others, swagger-ui-react does not currently support custom layout.

@tim-lai tim-lai closed this as completed Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants