Explorar el Código

fix: resolved model data invalidation (via #4858)

bubble
kyle hace 6 años
committed by GitHub
padre
commit
eb6c43405f
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 4AEE18F83AFDEB23
Se han modificado 3 ficheros con 40 adiciones y 1 borrados
  1. +1
    -1
      src/core/components/models.jsx
  2. +13
    -0
      test/e2e-cypress/static/documents/bugs/editor-1868.yaml
  3. +26
    -0
      test/e2e-cypress/tests/bugs/editor-1868.js

+ 1
- 1
src/core/components/models.jsx Ver fichero

@@ -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])


+ 13
- 0
test/e2e-cypress/static/documents/bugs/editor-1868.yaml Ver fichero

@@ -0,0 +1,13 @@
swagger: "2.0"

paths:
/:
get:
description: wow

definitions:
MyModel:
type: object
properties:
a:
type: string

+ 26
- 0
test/e2e-cypress/tests/bugs/editor-1868.js Ver fichero

@@ -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")
})
})

Cargando…
Cancelar
Guardar