# `swagger-ui-react`
[![NPM version](https://badge.fury.io/js/swagger-ui-react.svg)](http://badge.fury.io/js/swagger-ui-react)
`swagger-ui-react` is a flavor of Swagger UI suitable for use in React applications.
It has a few differences from the main version of Swagger UI:
* Declares `react` and `react-dom` as peerDependencies instead of production dependencies
* Exports a component instead of a constructor function
Versions of this module mirror the version of Swagger UI included in the distribution.
## Quick start
Install `swagger-ui-react`:
```
$ npm i --save swagger-ui-react
```
Use it in your React application:
```js
import SwaggerUI from "swagger-ui-react"
import "swagger-ui-react/swagger-ui.css"
export default App = () => <SwaggerUI url="https://petstore.swagger.io/v2/swagger.json" />
```
## Props
These props map to [Swagger UI configuration options](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md) of the same name.
#### `spec`: PropTypes.object
An OpenAPI document represented as a JavaScript object, JSON string, or YAML string for Swagger UI to display.
⚠️ Don't use this in conjunction with `url` - unpredictable behavior may occur.
#### `url`: PropTypes.string
Remote URL to an OpenAPI document that Swagger UI will fetch, parse, and display.
⚠️ Don't use this in conjunction with `spec` - unpredictable behavior may occur.
#### `layout`: PropTypes.string
The name of a component available via the plugin system to use as the top-level layout for Swagger UI. The default value is `BaseLayout`.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `onComplete`: PropTypes.func
> `(system) => void`
A callback function that is triggered when Swagger-UI finishes rendering an OpenAPI document.
Swagger UI's `system` object is passed as an argument.
#### `requestInterceptor`: PropTypes.func
> `req => req` or `req => Promise<req>`.
A function that accepts a request object, and returns either a request object
or a Promise that resolves to a request object.
#### `responseInterceptor`: PropTypes.func
> `res => res` or `res => Promise<res>`.
A function that accepts a response object, and returns either a response object
or a Promise that resolves to a response object.
#### `docExpansion`: PropTypes.oneOf(['list', 'full', 'none'])
Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). The default value is 'list'.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `defaultModelExpandDepth`: PropTypes.number
The default expansion depth for models (set to -1 completely hide the models).
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `defaultModelRendering`: PropTypes.oneOf(["example", "model"])
Controls how the model is shown when the API is first rendered. (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.) The default value is 'example'.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `displayOperationId`: PropTypes.bool
Controls the display of operationId in operations list. The default is false.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `plugins`: PropTypes.arrayOf(PropTypes.object),
An array of objects that augment and modify Swagger UI's functionality. See Swagger UI's [Plugin API](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plugin-api.md) for more details.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `supportedSubmitMethods`: PropTypes.arrayOf(PropTypes.oneOf(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']))
HTTP methods that have the Try it out feature enabled. An empty array disables Try it out for all operations. This does not filter the operations from the display.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `showExtensions`: PropTypes.bool
Controls the display of vendor extension (`x-`) fields and values for Operations, Parameters, Responses, and Schema.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `showCommonExtensions`: PropTypes.bool
Controls the display of extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `showMutatedRequest`: PropTypes.bool
If set to `true`, uses the mutated request returned from a requestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `presets`: PropTypes.arrayOf(PropTypes.func),
An array of functions that augment and modify Swagger UI's functionality. See Swagger UI's [Plugin API](https://github.com/swagger-api/swagger-ui/blob/master/docs/customization/plugin-api.md) for more details.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `tryItOutEnabled`: PropTypes.bool
Controls whether the "Try it out" section should start enabled. The default is false.
⚠️ This prop is currently only applied once, on mount. Changes to this prop's value will not be propagated to the underlying Swagger UI instance. A future version of this module will remove this limitation, and the change will not be considered a breaking change.
#### `displayRequestDuration`: PropTypes.bool
Controls the display of the request duration (in milliseconds) for "Try it out" requests. The default is false.
#### `filter`: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
If se
没有合适的资源?快使用搜索试试~ 我知道了~
swagger-ui 压缩包
共818个文件
js:334个
jsx:219个
yaml:119个
需积分: 1 0 下载量 130 浏览量
2023-10-20
15:26:09
上传
评论
收藏 4.11MB ZIP 举报
温馨提示
swagger-ui 压缩包
资源推荐
资源详情
资源评论
收起资源包目录
swagger-ui 压缩包 (818个子文件)
.agignore 6B
.browserslistrc 426B
commit-msg 60B
cors.conf 543B
swagger-ui.css 148KB
index.css 202B
style.css 189B
injection.css 137B
Dockerfile 1KB
.dockerignore 83B
.editorconfig 171B
.eslinrc 213B
.eslintignore 20B
.eslintrc 823B
.eslintrc 212B
.eslintrc 183B
.eslintrc 147B
.eslintrc 127B
.eslintrc 95B
.eslintrc 0B
.gitattributes 26B
.gitignore 379B
index.html 4KB
oauth2-redirect.html 3KB
oauth2-redirect.html 3KB
index.html 2KB
index.html 2KB
index.html 2KB
index.html 2KB
index.html 734B
index.html 391B
index.html 146B
swagger-ui-bundle.js 1.32MB
swagger-ui-es-bundle.js 1.32MB
swagger-ui-es-bundle-core.js 453KB
swagger-ui.js 332KB
swagger-ui-standalone-preset.js 225KB
fn.js 67KB
index.js 55KB
utils.js 51KB
schema-form.cy.js 31KB
selectors.js 30KB
multiple-examples.js 24KB
multiple-examples-core.cy.js 23KB
index.js 23KB
main.js 19KB
index.js 19KB
allow-empty-value.openapi.js 18KB
allow-empty-value.swagger.js 18KB
actions.js 16KB
selectors.js 16KB
reducers.js 15KB
main.js 14KB
system.js 14KB
curlify.js 14KB
fn.js 10KB
oas3-request-body-required.cy.js 10KB
state-integration.js 10KB
deep-linking.cy.js 9KB
actions.js 9KB
translator.js 9KB
selectors.js 8KB
index.js 8KB
oauth2-authorize.js 8KB
actions.js 8KB
wrap-auth-selectors.js 8KB
example.js 7KB
oas3-multiple-media-type.cy.js 6KB
index.js 6KB
actions.js 6KB
layout.js 6KB
oas3-request-body-allow-empty-values.cy.js 6KB
index.js 6KB
index.js 6KB
selectors.js 6KB
reducers.js 5KB
selectors.js 5KB
reducers.js 5KB
fn.js 5KB
reducer.js 5KB
request-body-upload-file.cy.js 5KB
pet.js 5KB
store.js 5KB
string.js 4KB
get-sample-schema.js 4KB
_config-builder.js 4KB
get-sample-schema.js 4KB
schema-form-enum-boolean.cy.js 4KB
oas3-user-edit-request-body-flows.cy.js 4KB
external-docs.cy.js 4KB
5129.cy.js 4KB
preauthorize.js 4KB
parameter-oneof.js 4KB
oauth2-authorize.js 4KB
index.js 4KB
type.js 4KB
urls.cy.js 4KB
license.cy.js 4KB
get-parameter-schema.js 3KB
4641.cy.js 3KB
共 818 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
鲤鱼的日常生活
- 粉丝: 1381
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功