Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
maintained node versions

[node-development]
node 20.3.0
node 22

[browser-production]
> 1%
Expand All @@ -26,4 +26,4 @@ maintained node versions
last 1 chrome version
last 1 firefox version
last 1 safari version
node 20.3.0
node 22
38 changes: 0 additions & 38 deletions .eslintrc

This file was deleted.

78 changes: 78 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* @prettier
*/
const path = require("node:path")

module.exports = {
parser: "@babel/eslint-parser",
env: {
browser: true,
node: true,
es6: true,
jest: true,
"jest/globals": true,
},
parserOptions: {
ecmaFeatures: { jsx: true },
babelOptions: { configFile: path.join(__dirname, "babel.config.js") },
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
],
plugins: ["react", "import", "jest", "prettier"],
settings: {
react: {
pragma: "React",
version: "15.0",
},
},
rules: {
semi: [2, "never"],
strict: 0,
quotes: [
2,
"double",
{
avoidEscape: true,
allowTemplateLiterals: true,
},
],
"no-unused-vars": 2,
"no-multi-spaces": 1,
camelcase: [
"error",
{
allow: [
"^UNSAFE_",
"^requestSnippetGenerator_",
"^JsonSchema_",
"^curl_",
"^dom_",
"^api_",
"^client_",
"^grant_",
"^code_",
"^redirect_",
"^spec",
],
},
],
"no-use-before-define": [2, "nofunc"],
"no-underscore-dangle": 0,
"no-unused-expressions": 1,
"comma-dangle": 0,
"no-console": [
2,
{
allow: ["warn", "error"],
},
],
"react/jsx-no-bind": 1,
"react/jsx-no-target-blank": 2,
"react/display-name": 0,
"import/no-extraneous-dependencies": 2,
"react/jsx-filename-extension": 2,
},
}
3 changes: 2 additions & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"*.js": "eslint"
"*.{js,jsx}": ["eslint --max-warnings 0"],
"*.scss": ["stylelint '**/*.scss'"]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.3.0
22.11.0
28 changes: 9 additions & 19 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"branches": [
{
"name": "master"
},
{
"name": "next",
"channel": "alpha",
"prerelease": "alpha"
}
{"name": "master"}
],
"tagFormat": "v${version}",
"plugins": [
Expand All @@ -21,15 +14,12 @@
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json"
],
"message": "chore(release): cut the ${nextRelease.version} release\n\n${nextRelease.notes}"
}
]
["@semantic-release/git", {
"assets": [
"package.json",
"package-lock.json"
],
"message": "chore(release): cut the ${nextRelease.version} release\n\n${nextRelease.notes}"
}]
]
}
}
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

FROM nginx:1.27.4-alpine

LABEL maintainer="vladimir.gorej@gmail.com" \
org.opencontainers.image.authors="vladimir.gorej@gmail.com" \
org.opencontainers.image.url="docker.swagger.io/swaggerapi/swagger-ui" \
org.opencontainers.image.source="https://github.com/swagger-api/swagger-ui" \
org.opencontainers.image.description="SwaggerUI Docker image" \
org.opencontainers.image.licenses="Apache-2.0"

RUN apk add --update-cache --no-cache "nodejs"

LABEL maintainer="char0n"
Expand Down
2 changes: 1 addition & 1 deletion config/jest/jest.unit.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ module.exports = {
moduleNameMapper: {
'^.+\\.svg$': 'jest-transform-stub'
},
transformIgnorePatterns: ['/node_modules/(?!(sinon|react-syntax-highlighter)/)'],
transformIgnorePatterns: ['/node_modules/(?!(sinon|react-syntax-highlighter|@asamuzakjp/css-color)/)'],
silent: true, // set to `false` to allow console.* calls to be printed
};
2 changes: 2 additions & 0 deletions docs/development/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Script name | Description
`lint` | Report ESLint style errors and warnings.
`lint-errors` | Report ESLint style errors, without warnings.
`lint-fix` | Attempt to fix style errors automatically.
`lint-styles` | Report Stylelint style errors and warnings.
`lint-styles-fix` | Attempt to fix Stylelint errors and warnings automatically.
`watch` | Rebuild the core files in `/dist` when the source code changes. Useful for `npm link` with Swagger Editor.

### Building
Expand Down
13 changes: 8 additions & 5 deletions docs/development/setting-up.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# Setting up a dev environment

Swagger UI includes a development server that provides hot module reloading and unminified stack traces, for easier development.
SwaggerUI includes a development server that provides hot module reloading and unminified stack traces, for easier development.

### Prerequisites

- git, any version
- **Node.js >=20.3.0** and **npm >=9.6.7** are the minimum required versions that this repo runs on, but we always recommend using the latest version of Node.js.
- **Node.js >=22.11.0** and **npm >=10.9.0** are the minimum required versions that this repo runs on, but we always recommend using the latest version of Node.js.



### Steps

1. `git clone https://github.com/swagger-api/swagger-ui.git`
2. `cd swagger-ui`
3. `npm install`
4. `npm run dev`
5. Wait a bit
6. Open http://localhost:3200/
4. `npx husky init` (optional)
5. `npm run dev`
6. Wait a bit
7. Open http://localhost:3200/

### Using your own local api definition with local dev build

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openapi: "3.0.0"
openapi: "3.0.4"
info:
version: "0.0.1"
title: "Swagger UI Webpack Setup"
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ Set the value to the literal object value you'd like, taking care to escape char
Example:

```sh
SPEC="{ \"openapi\": \"3.0.0\" }"
SPEC="{ \"openapi\": \"3.0.4\" }"
```

### Docker-Compose
Expand Down
17 changes: 17 additions & 0 deletions docs/usage/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ We publish three modules to npm: **`swagger-ui`**, **`swagger-ui-dist`** and **`
such as Webpack, Browserify, and Rollup. Its main file exports Swagger UI's main function,
and the module also includes a namespaced stylesheet at `swagger-ui/dist/swagger-ui.css`. Here's an example:

### Installation

You can now install SwaggerUI packages using `npm`:

```sh
$ npm install swagger-ui
````

```sh
$ npm install swagger-ui-react
````

```sh
$ npm install swagger-ui-dist
````


```javascript
import SwaggerUI from 'swagger-ui'
// or use require if you prefer
Expand Down
7 changes: 6 additions & 1 deletion flavors/swagger-ui-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Alternatively, you can set the environment variable `SCARF_ANALYTICS` to `false`
Install `swagger-ui-react`:

```
$ npm i --save swagger-ui-react
$ npm install swagger-ui-react
```

Use it in your React application:
Expand Down Expand Up @@ -194,6 +194,11 @@ Redirect url given as parameter to the oauth2 provider. Default the url refers t

⚠️ 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.

#### `initialState`: PropTypes.object

Passes initial values to the Swagger UI state.

⚠️ 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.

## Limitations

Expand Down
3 changes: 3 additions & 0 deletions flavors/swagger-ui-react/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const SwaggerUI = ({
persistAuthorization = config.defaults.persistAuthorization,
oauth2RedirectUrl = config.defaults.oauth2RedirectUrl,
onComplete = null,
initialState = config.defaults.initialState,
}) => {
const [system, setSystem] = useState(null)
const SwaggerUIComponent = system?.getComponent("App", "root")
Expand Down Expand Up @@ -83,6 +84,7 @@ const SwaggerUI = ({
filter,
persistAuthorization,
withCredentials,
initialState,
...(typeof oauth2RedirectUrl === "string"
? { oauth2RedirectUrl: oauth2RedirectUrl }
: {}),
Expand Down Expand Up @@ -165,6 +167,7 @@ SwaggerUI.propTypes = {
persistAuthorization: PropTypes.bool,
withCredentials: PropTypes.bool,
oauth2RedirectUrl: PropTypes.string,
initialState: PropTypes.object,
}
SwaggerUI.System = SwaggerUIConstructor.System
SwaggerUI.presets = SwaggerUIConstructor.presets
Expand Down
Loading
Loading