diff --git a/src/core/components/models.jsx b/src/core/components/models.jsx index 86c82d7dca2e45fa4a27455d73203a3ddb3edfd3..0818be1d8f83b142502f848794ea86c51b0471ff 100644 --- a/src/core/components/models.jsx +++ b/src/core/components/models.jsx @@ -59,7 +59,7 @@ export default class Models extends Component { const rawSchema = specSelectors.specJson().getIn(fullPath, Im.Map()) const displayName = schema.get("title") || rawSchema.get("title") || name - if(layoutSelectors.isShown(["models", name], false) && schema === undefined) { + if(layoutSelectors.isShown(["models", name], false) && (schema.size === 0 && rawSchema.size > 0)) { // Firing an action in a container render is not great, // but it works for now. this.props.specActions.requestResolvedSubtree([...this.getSchemaBasePath(), name]) diff --git a/test/e2e-cypress/static/documents/bugs/editor-1868.yaml b/test/e2e-cypress/static/documents/bugs/editor-1868.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ef0d8f71f57e41b7d0dc7ce73c5c9f1a8dcc7e83 --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/editor-1868.yaml @@ -0,0 +1,13 @@ +swagger: "2.0" + +paths: + /: + get: + description: wow + +definitions: + MyModel: + type: object + properties: + a: + type: string \ No newline at end of file diff --git a/test/e2e-cypress/tests/bugs/editor-1868.js b/test/e2e-cypress/tests/bugs/editor-1868.js new file mode 100644 index 0000000000000000000000000000000000000000..cf78e0e30bfae30c179ee202286e2e1dfe393c42 --- /dev/null +++ b/test/e2e-cypress/tests/bugs/editor-1868.js @@ -0,0 +1,26 @@ +import repeat from "lodash/repeat" + +describe("Editor #1868: model changes break rendering", () => { + it("should render model content changes correctly", () => { + cy + .visit("/?url=/documents/bugs/editor-1868.yaml") + + .get(".model-toggle.collapsed") + .click() + + .get("#model-MyModel") + .contains("a") + + .window() + .then(win => { + // Simulate Swagger Editor updating a model + const content = win.ui.specSelectors.specStr() + win.ui.specActions.updateSpec(content + `\n b:\n type: string`) + }) + + .get("#model-MyModel") + .contains("a") + .get("#model-MyModel") + .contains("b") + }) +}) \ No newline at end of file