Skip to content

Commit c0254eb

Browse files
authored
fix: page refresh with local storage should validate only once (#2138)
also pass "local-storage" as argument to updateSpec
1 parent 71aded3 commit c0254eb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/plugins/local-storage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function(system) {
1313
// setTimeout runs on the next tick
1414
setTimeout(() => {
1515
if(localStorage.getItem(CONTENT_KEY)) {
16-
system.specActions.updateSpec(localStorage.getItem(CONTENT_KEY))
16+
system.specActions.updateSpec(localStorage.getItem(CONTENT_KEY), "local-storage")
1717
} else if(localStorage.getItem("ngStorage-SwaggerEditorCache")) {
1818
// Legacy migration for swagger-editor 2.x
1919
try {

src/plugins/validate-semantic/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ export default function SemanticValidatorsPlugin({getSystem}) {
4040
},
4141
wrapActions: {
4242
validateSpec: (ori, system) => (...args) => {
43-
ori(...args)
44-
debAll(system)
43+
// verify editor plugin already loaded and function is available (for tests)
44+
if (system.specSelectors.specOrigin) {
45+
const specOrigin = system.specSelectors.specOrigin()
46+
if (specOrigin === "editor") {
47+
ori(...args)
48+
debAll(system)
49+
}
50+
}
4551
}
4652
}
4753
},

0 commit comments

Comments
 (0)