Skip to content

Commit

Permalink
Merge branch 'master' into ft/randomness-option
Browse files Browse the repository at this point in the history
  • Loading branch information
twanthony4 authored Jul 26, 2024
2 parents fd95d54 + 8e6824c commit 3232dff
Show file tree
Hide file tree
Showing 35 changed files with 4,627 additions and 4,524 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ updates:
directory: "/"
schedule:
interval: daily
time: "23:00"
commit-message:
prefix: "chore"
include: "scope"
Expand All @@ -18,6 +19,7 @@ updates:
# Check for updates once a week
schedule:
interval: "weekly"
time: "23:00"

- package-ecosystem: "github-actions"
target-branch: "master"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# will not occur.
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v2.1.0
uses: dependabot/fetch-metadata@v2.2.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Here the PR gets approved.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# We don't declare them here — take a look at our docs.
# https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md

FROM nginx:1.26.0-alpine
FROM nginx:1.27.0-alpine

RUN apk update && apk add --no-cache "nodejs>=18.20.1-r0 "

Expand Down
11 changes: 6 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ If you believe you've found an exploitable security issue in Swagger UI,
This is the list of versions of `swagger-ui` which are
currently being supported with security updates.

| Version | Supported | Notes |
| -------- | ------------------ | ---------------------- |
| 4.x | :white_check_mark: | |
| 3.x | :x: | End-of-life as of November 2021 |
| 2.x | :x: | End-of-life as of 2017 |
| Version | Supported | Notes |
|---------|--------------------|---------------------------------|
| 5.x | :white_check_mark: | Active LTS |
| 4.x | :x: | End-of-life as of August 2023 |
| 3.x | :x: | End-of-life as of November 2021 |
| 2.x | :x: | End-of-life as of 2017 |

## Reporting a vulnerability

Expand Down
2 changes: 1 addition & 1 deletion dist/swagger-ui-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-es-bundle-core.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-es-bundle-core.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-es-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui-standalone-preset.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/swagger-ui.js.map

Large diffs are not rendered by default.

26 changes: 22 additions & 4 deletions flavors/swagger-ui-react/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
*/
"use client"

import React, { useEffect, useState } from "react"
import React, { useEffect, useRef, useState } from "react"
import PropTypes from "prop-types"
import SwaggerUIConstructor from "#swagger-ui"

const { config } = SwaggerUIConstructor

const usePrevious = (value) => {
const ref = useRef()
useEffect(() => {
ref.current = value
}, [value])
return ref.current
}

const SwaggerUI = ({
spec = config.defaults.spec,
url = config.defaults.url,
Expand Down Expand Up @@ -40,6 +48,8 @@ const SwaggerUI = ({
}) => {
const [system, setSystem] = useState(null)
const SwaggerUIComponent = system?.getComponent("App", "root")
const prevSpec = usePrevious(spec)
const prevUrl = usePrevious(url)

useEffect(() => {
const systemInstance = SwaggerUIConstructor({
Expand Down Expand Up @@ -84,22 +94,30 @@ const SwaggerUI = ({
useEffect(() => {
if (system) {
const prevStateUrl = system.specSelectors.url()
if (url !== prevStateUrl) {
if (url !== prevStateUrl || url !== prevUrl) {
system.specActions.updateSpec("")
if (url) {
system.specActions.updateUrl(url)
system.specActions.download(url)
}
}
}
}, [system, url])

useEffect(() => {
if (system) {
const prevStateSpec = system.specSelectors.specStr()
if (spec && spec !== prevStateSpec) {
if (
spec &&
spec !== SwaggerUIConstructor.config.defaults.spec &&
(spec !== prevStateSpec || spec !== prevSpec)
) {
const updatedSpec =
typeof spec === "object" ? JSON.stringify(spec) : spec
system.specActions.updateSpec(updatedSpec)
}
}
}, [system, url, spec])
}, [system, spec])

return SwaggerUIComponent ? <SwaggerUIComponent /> : null
}
Expand Down
Loading

0 comments on commit 3232dff

Please sign in to comment.