diff --git a/src/core/plugins/oas3/helpers.jsx b/src/core/plugins/oas3/helpers.jsx
index 79b95722..9d46eef5 100644
--- a/src/core/plugins/oas3/helpers.jsx
+++ b/src/core/plugins/oas3/helpers.jsx
@@ -32,3 +32,18 @@ export function OAS3ComponentWrapFactory(Component) {
}
}
}
+
+export function OAS30ComponentWrapFactory(Component) {
+ return (Ori, system) => (props) => {
+ if (typeof system.specSelectors?.isOAS30 === "function") {
+ if (system.specSelectors.isOAS30()) {
+ return
+ } else {
+ return
+ }
+ } else {
+ console.warn("OAS30 wrapper: couldn't get spec")
+ return null
+ }
+ }
+}
diff --git a/src/core/plugins/oas3/wrap-components/version-stamp.jsx b/src/core/plugins/oas3/wrap-components/version-stamp.jsx
index d0d188bd..9ec70f1b 100644
--- a/src/core/plugins/oas3/wrap-components/version-stamp.jsx
+++ b/src/core/plugins/oas3/wrap-components/version-stamp.jsx
@@ -1,13 +1,19 @@
+/**
+ * @prettier
+ */
import React from "react"
-import { OAS3ComponentWrapFactory } from "../helpers"
-export default OAS3ComponentWrapFactory((props) => {
+import { OAS30ComponentWrapFactory } from "../helpers"
+
+export default OAS30ComponentWrapFactory((props) => {
const { Ori } = props
- return
-
-
- OAS3
-
-
+ return (
+
+
+
+ OAS 3.0
+
+
+ )
})
diff --git a/src/core/plugins/oas31/index.js b/src/core/plugins/oas31/index.js
index 11c60c1b..855123f7 100644
--- a/src/core/plugins/oas31/index.js
+++ b/src/core/plugins/oas31/index.js
@@ -11,6 +11,7 @@ import LicenseWrapper from "./wrap-components/license"
import ContactWrapper from "./wrap-components/contact"
import InfoWrapper from "./wrap-components/info"
import VersionPragmaFilterWrapper from "./wrap-components/version-pragma-filter"
+import VersionStampWrapper from "./wrap-components/version-stamp"
import {
license as selectLicense,
contact as selectContact,
@@ -71,6 +72,7 @@ const OAS31Plugin = ({ fn }) => {
License: LicenseWrapper,
Contact: ContactWrapper,
VersionPragmaFilter: VersionPragmaFilterWrapper,
+ VersionStamp: VersionStampWrapper,
},
statePlugins: {
spec: {
diff --git a/src/core/plugins/oas31/wrap-components/version-stamp.jsx b/src/core/plugins/oas31/wrap-components/version-stamp.jsx
new file mode 100644
index 00000000..6af4017e
--- /dev/null
+++ b/src/core/plugins/oas31/wrap-components/version-stamp.jsx
@@ -0,0 +1,21 @@
+/**
+ * @prettier
+ */
+import React from "react"
+
+const VersionStampWrapper = (Original, system) => (props) => {
+ if (system.specSelectors.isOAS31()) {
+ return (
+
+
+
+ OAS 3.1
+
+
+ )
+ }
+
+ return
+}
+
+export default VersionStampWrapper
diff --git a/test/e2e-cypress/tests/bugs/4865.js b/test/e2e-cypress/tests/bugs/4865.js
index 85573ef7..22db26dc 100644
--- a/test/e2e-cypress/tests/bugs/4865.js
+++ b/test/e2e-cypress/tests/bugs/4865.js
@@ -5,7 +5,7 @@ describe("#4865: multiple invocations + OAS3 plugin", () => {
cy.visit("/?url=/documents/petstore-expanded.openapi.yaml")
.get("#swagger-ui")
.get("pre.version")
- .contains("OAS3")
+ .contains("OAS 3.0")
})
it("test: should render the OAS3 badge correctly after re-initializing the UI", () => {
@@ -14,6 +14,6 @@ describe("#4865: multiple invocations + OAS3 plugin", () => {
.then(win => win.onload()) // re-initializes Swagger UI
.get("#swagger-ui")
.get("pre.version")
- .contains("OAS3")
+ .contains("OAS 3.0")
})
})
diff --git a/test/e2e-cypress/tests/features/oas3-badge.js b/test/e2e-cypress/tests/features/oas3-badge.js
new file mode 100644
index 00000000..1db2ae5f
--- /dev/null
+++ b/test/e2e-cypress/tests/features/oas3-badge.js
@@ -0,0 +1,15 @@
+describe("OpenAPI 3.x.y Badge", () => {
+ it("should display light green badge with version indicator for OpenAPI 3.0.x", () => {
+ cy.visit("/?url=/documents/petstore-expanded.openapi.yaml")
+ .get("#swagger-ui")
+ .get("pre.version")
+ .contains("OAS 3.0")
+ })
+
+ it("should display light green badge with version indicator for OpenAPI 3.1.0", () => {
+ cy.visit("/?url=/documents/features/info-openAPI31.yaml")
+ .get("#swagger-ui")
+ .get("pre.version")
+ .contains("OAS 3.1")
+ })
+})