Skip to content

Commit f0332d9

Browse files
committed
add isSwagger2 selector
1 parent f2b40a4 commit f0332d9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/core/plugins/oas3/helpers.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ export function isOAS3(jsSpec) {
99
return oasVersion.startsWith("3.0.0")
1010
}
1111

12+
export function isSwagger2(jsSpec) {
13+
const swaggerVersion = jsSpec.get("swagger")
14+
if(!swaggerVersion) {
15+
return false
16+
}
17+
18+
return swaggerVersion.startsWith("2")
19+
}
20+
1221
export function OAS3ComponentWrapFactory(Component) {
1322
return (Ori, system) => (props) => {
1423
if(system && system.specSelectors && system.specSelectors.specJson) {

src/core/plugins/oas3/wrap-selectors.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createSelector } from "reselect"
22
import { Map } from "immutable"
3-
import { isOAS3 as isOAS3Helper } from "./helpers"
3+
import { isOAS3 as isOAS3Helper, isSwagger2 as isSwagger2Helper } from "./helpers"
44

55

66
// Helpers
@@ -60,3 +60,8 @@ export const isOAS3 = (ori, system) => () => {
6060
const spec = system.getSystem().specSelectors.specJson()
6161
return isOAS3Helper(spec)
6262
}
63+
64+
export const isSwagger2 = (ori, system) => () => {
65+
const spec = system.getSystem().specSelectors.specJson()
66+
return isSwagger2Helper(spec)
67+
}

0 commit comments

Comments
 (0)