Skip to content

Commit 7e6f740

Browse files
committed
Disable Swagger2 auth features in OAS3
1 parent c6a6643 commit 7e6f740

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { createSelector } from "reselect"
2+
import { Map } from "immutable"
3+
import { isOAS3 as isOAS3Helper, isSwagger2 as isSwagger2Helper } from "../helpers"
4+
5+
6+
// Helpers
7+
8+
function onlyOAS3(selector) {
9+
return (ori, system) => (...args) => {
10+
const spec = system.getSystem().specSelectors.specJson()
11+
if(isOAS3Helper(spec)) {
12+
return selector(...args)
13+
} else {
14+
return ori(...args)
15+
}
16+
}
17+
}
18+
19+
const state = state => {
20+
return state || Map()
21+
}
22+
23+
const nullSelector = createSelector(() => null)
24+
25+
const OAS3NullSelector = onlyOAS3(nullSelector)
26+
27+
// Hasta la vista, authentication!
28+
export const shownDefinitions = OAS3NullSelector
29+
export const definitionsToAuthorize = OAS3NullSelector
30+
export const getDefinitionsByNames = OAS3NullSelector
31+
export const authorized = OAS3NullSelector
32+
export const isAuthorized = OAS3NullSelector
33+
export const getConfigs = OAS3NullSelector

src/core/plugins/oas3/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// import reducers from "./reducers"
22
// import * as actions from "./actions"
33
import * as specWrapSelectors from "./spec-extensions/wrap-selectors"
4+
import * as authWrapSelectors from "./auth-extensions/wrap-selectors"
45
import * as specSelectors from "./spec-extensions/selectors"
56
import components from "./components"
67
import wrapComponents from "./wrap-components"
@@ -17,6 +18,9 @@ export default function() {
1718
wrapSelectors: specWrapSelectors,
1819
selectors: specSelectors
1920
},
21+
auth: {
22+
wrapSelectors: authWrapSelectors
23+
},
2024
oas3: {
2125
actions: oas3Actions,
2226
reducers: oas3Reducers,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const basePath = OAS3NullSelector
5353
export const consumes = OAS3NullSelector
5454
export const produces = OAS3NullSelector
5555
export const schemes = OAS3NullSelector
56+
export const securityDefinitions = OAS3NullSelector
5657

5758
// New selectors
5859

0 commit comments

Comments
 (0)