Skip to content

Commit d5258f5

Browse files
authored
Merge pull request #1514 from swagger-api/feature/autocomplete-changes
Add the validateSpec action as its own thing
2 parents e48bdce + 467af88 commit d5258f5

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/plugins/editor-autosuggest-keywords/get-keywords-for-path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import isPlainObject from "lodash/isPlainObject"
55
import toArray from "lodash/toArray"
66
import isString from "lodash/isString"
77

8-
export default function getKeywordsForPath({ system, path, keywordMap}) {
8+
export default function getKeywordsForPath({ system, path, keywordMap }) {
99
keywordMap = Object.assign({}, keywordMap)
1010

1111
// is getting path was not successful stop here and return no candidates

src/plugins/editor/components/editor.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { placeMarkerDecorations } from "../editor-helpers/marker-placer"
55
import Im, { fromJS } from "immutable"
66
import ImPropTypes from "react-immutable-proptypes"
77

8-
import eq from "lodash/eq"
8+
import isEqual from "lodash/isEqual"
99
import isEmpty from "lodash/isEmpty"
1010

1111
import ace from "brace"
@@ -167,7 +167,7 @@ export default function makeEditor({ editorPluginsToRun }) {
167167

168168
componentWillReceiveProps(nextProps) {
169169
let { state } = this
170-
let hasChanged = (k) => !eq(nextProps[k], this.props[k])
170+
let hasChanged = (k) => !isEqual(nextProps[k], this.props[k])
171171
let wasEmptyBefore = (k) => nextProps[k] && (!this.props[k] || isEmpty(this.props[k]))
172172

173173
this.updateErrorAnnotations(nextProps)

src/plugins/validation/apis/index.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,34 @@ import { makeValidationWorker } from "../helpers"
44

55
let debouncedValidation = makeValidationWorker()
66

7-
export const updateResolved = (ori, {errActions, specSelectors}) => (...args) => {
7+
export const updateResolved = (ori, {specActions}) => (...args) => {
88
ori(...args)
9+
/*
10+
To allow us to remove this, we should prefer the practice of
11+
only _composing_ inside of wrappedActions. It keeps us free to
12+
remove pieces added by plugins. In this case, I want to toggle validation.
13+
But I can't look inside the updateResolved action,
14+
I can only remove it ( which isn't desirable ). However I _can_ remove `validateSpec` action,
15+
making it a noop. That way, the only overhead I end up with is a bunch of noops inside wrappedActions.
16+
Which isn't bad.
17+
*/
18+
const [ spec ] = args
19+
specActions.validateSpec(spec)
20+
}
21+
22+
export const validateSpec = (resolvedSpec) => ({ specSelectors, errActions }) => {
923
const isOAS3 = specSelectors.isOAS3 ? specSelectors.isOAS3() : false
1024
const ourMode = isOAS3 ? "oas3" : "swagger2"
11-
debouncedValidation({ mode: ourMode, specSelectors, errActions, resolvedSpec: args[0] })
25+
debouncedValidation({ mode: ourMode, specSelectors, errActions, resolvedSpec })
1226
}
1327

1428
export default function() {
1529
return {
1630
statePlugins: {
1731
spec: {
32+
actions: {
33+
validateSpec,
34+
},
1835
wrapActions: {
1936
updateResolved
2037
}

0 commit comments

Comments
 (0)