Skip to content

Commit 3d41337

Browse files
authored
fix(autosuggest): OAS3 fixed-field lookups (via #1971)
* store fixed field regex as a string * use type-safe lodash.get for reaching into keyword map values
1 parent d13b673 commit 3d41337

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import mapValues from "lodash/mapValues"
44
import isPlainObject from "lodash/isPlainObject"
55
import toArray from "lodash/toArray"
66
import isString from "lodash/isString"
7+
import get from "lodash/get"
78

89
export default function getKeywordsForPath({ system, path, keywordMap }) {
910
keywordMap = Object.assign({}, keywordMap)
@@ -128,7 +129,7 @@ function getChild(object, key) {
128129

129130
function suggestionFromSchema(map) {
130131
const res = toArray(mapValues(map, (val, key) => {
131-
const keyword = val.__value === undefined ? key : val.__value
132+
const keyword = get(val, "__value", key)
132133
const meta = isPlainObject(val) ? "object" : "keyword"
133134

134135
return constructAceCompletion(meta, keyword)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import mapValues from "lodash/mapValues"
44
import isPlainObject from "lodash/isPlainObject"
55
import toArray from "lodash/toArray"
66
import isString from "lodash/isString"
7+
import get from "lodash/get"
78

89
export default function getKeywordsForPath({ system, path, keywordMap}) {
910
keywordMap = Object.assign({}, keywordMap)
@@ -128,7 +129,7 @@ function getChild(object, key) {
128129

129130
function suggestionFromSchema(map) {
130131
const res = toArray(mapValues(map, (val, key) => {
131-
const keyword = val.__value === undefined ? key : val.__value
132+
const keyword = get(val, "__value", key)
132133
const meta = isPlainObject(val) ? "object" : "keyword"
133134

134135
return constructAceCompletion(meta, keyword)

src/plugins/editor-autosuggest-oas3-keywords/oas3-objects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export const SecurityScheme = {
247247
openIdConnectUrl: String,
248248
}
249249

250-
const ComponentFixedFieldRegex = /^[a-zA-Z0-9\.\-_]+$/
250+
const ComponentFixedFieldRegex = "^[a-zA-Z0-9\.\-_]+$"
251251

252252
export const Components = {
253253
schemas: {

0 commit comments

Comments
 (0)