Skip to content

Commit eb6c434

Browse files
authored
fix: resolved model data invalidation (via #4858)
1 parent f1224e5 commit eb6c434

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/core/components/models.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default class Models extends Component {
5959
const rawSchema = specSelectors.specJson().getIn(fullPath, Im.Map())
6060
const displayName = schema.get("title") || rawSchema.get("title") || name
6161

62-
if(layoutSelectors.isShown(["models", name], false) && schema === undefined) {
62+
if(layoutSelectors.isShown(["models", name], false) && (schema.size === 0 && rawSchema.size > 0)) {
6363
// Firing an action in a container render is not great,
6464
// but it works for now.
6565
this.props.specActions.requestResolvedSubtree([...this.getSchemaBasePath(), name])
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
swagger: "2.0"
2+
3+
paths:
4+
/:
5+
get:
6+
description: wow
7+
8+
definitions:
9+
MyModel:
10+
type: object
11+
properties:
12+
a:
13+
type: string
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import repeat from "lodash/repeat"
2+
3+
describe("Editor #1868: model changes break rendering", () => {
4+
it("should render model content changes correctly", () => {
5+
cy
6+
.visit("/?url=/documents/bugs/editor-1868.yaml")
7+
8+
.get(".model-toggle.collapsed")
9+
.click()
10+
11+
.get("#model-MyModel")
12+
.contains("a")
13+
14+
.window()
15+
.then(win => {
16+
// Simulate Swagger Editor updating a model
17+
const content = win.ui.specSelectors.specStr()
18+
win.ui.specActions.updateSpec(content + `\n b:\n type: string`)
19+
})
20+
21+
.get("#model-MyModel")
22+
.contains("a")
23+
.get("#model-MyModel")
24+
.contains("b")
25+
})
26+
})

0 commit comments

Comments
 (0)