# `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 respresented 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.
#### `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 set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. Can be Boolean to enable or disable, or a string, in which case filtering will be enabled using that string as the filter expression. Filtering is case sensitive matching the filter expression anywhere inside the tag. See Swagger UI's [Plug Points](https://github.com/swagger-api/swagger-ui/blob/master/docs/cust
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
swagger-ui-4.12.0.tar.gz (595个子文件)
.agignore 6B
commit-msg 60B
nginx.conf 990B
cors.conf 543B
whitesource.config 32B
swagger-ui.css 141KB
index.css 202B
style.css 189B
injection.css 137B
Dockerfile 834B
.dockerignore 83B
.editorconfig 171B
.eslinrc 213B
.eslintignore 20B
.eslintrc 803B
.eslintrc 212B
.eslintrc 183B
.eslintrc 147B
.eslintrc 127B
.eslintrc 95B
.eslintrc 0B
.gitattributes 26B
.gitignore 289B
index.html 4KB
oauth2-redirect.html 3KB
oauth2-redirect.html 3KB
index.html 2KB
index.html 2KB
index.html 2KB
index.html 734B
index.html 391B
index.html 146B
swagger-ui-bundle.js 1.05MB
swagger-ui-es-bundle.js 1.05MB
swagger-ui-es-bundle-core.js 397KB
swagger-ui-standalone-preset.js 332KB
swagger-ui.js 280KB
utils.js 55KB
fn.js 51KB
schema-form.js 31KB
selectors.js 30KB
utils.js 25KB
multiple-examples.js 24KB
multiple-examples-core.js 22KB
main.js 19KB
fn.js 19KB
allow-empty-value.swagger.js 18KB
allow-empty-value.openapi.js 18KB
selectors.js 15KB
actions.js 15KB
reducers.js 15KB
system.js 14KB
curlify.js 12KB
oas3-request-body-required.js 10KB
state-integration.js 10KB
deep-linking.js 9KB
actions.js 9KB
translator.js 9KB
oauth2-authorize.js 8KB
actions.js 8KB
wrap-auth-selectors.js 8KB
selectors.js 7KB
example.js 7KB
base.js 7KB
index.js 6KB
oas3-multiple-media-type.js 6KB
actions.js 6KB
layout.js 6KB
oas3-request-body-allow-empty-values.js 6KB
reducers.js 5KB
reducers.js 5KB
reducer.js 5KB
request-body-upload-file.js 5KB
store.js 5KB
pet.js 5KB
fn.js 4KB
schema-form-enum-boolean.js 4KB
oas3-user-edit-request-body-flows.js 4KB
_config-builder.js 4KB
babel.config.js 4KB
5129.js 4KB
preauthorize.js 4KB
parameter-oneof.js 4KB
oauth2-authorize.js 4KB
urls.js 4KB
4641.js 3KB
download-url.js 3KB
get-parameter-schema.js 3KB
wrap-selectors.js 3KB
selectors.js 3KB
actions.js 3KB
dev.babel.js 3KB
password.js 3KB
model.js 3KB
pet.js 3KB
reducers.js 3KB
oas3-multiple-servers.js 3KB
es-bundle-core.babel.js 2KB
translator.js 2KB
selectors.js 2KB
共 595 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
YunFeiDong
- 粉丝: 152
- 资源: 3930
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功