Procházet zdrojové kódy

improvement: add Schema/Model switching to ModelExample component (via #5080)

bubble
kyle před 5 roky
committed by GitHub
rodič
revize
f5e179ac39
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: 4AEE18F83AFDEB23
2 změnil soubory, kde provedl 37 přidání a 12 odebrání
  1. +5
    -1
      src/core/components/model-example.jsx
  2. +32
    -11
      test/e2e-cypress/tests/bugs/swos-63.js

+ 5
- 1
src/core/components/model-example.jsx Zobrazit soubor

@@ -44,13 +44,17 @@ export default class ModelExample extends React.Component {
let { defaultModelExpandDepth } = getConfigs()
const ModelWrapper = getComponent("ModelWrapper")

let isOAS3 = specSelectors.isOAS3()

return <div>
<ul className="tab">
<li className={ "tabitem" + ( this.state.activeTab === "example" ? " active" : "") }>
<a className="tablinks" data-name="example" onClick={ this.activeTab }>{isExecute ? "Edit Value" : "Example Value"}</a>
</li>
{ schema ? <li className={ "tabitem" + ( this.state.activeTab === "model" ? " active" : "") }>
<a className={ "tablinks" + ( isExecute ? " inactive" : "" )} data-name="model" onClick={ this.activeTab }>Model</a>
<a className={ "tablinks" + ( isExecute ? " inactive" : "" )} data-name="model" onClick={ this.activeTab }>
{isOAS3 ? "Schema" : "Model" }
</a>
</li> : null }
</ul>
<div>


+ 32
- 11
test/e2e-cypress/tests/bugs/swos-63.js Zobrazit soubor

@@ -1,14 +1,35 @@
describe("SWOS-63: Schema/Model section labeling", () => {
it("should render `Schemas` for OpenAPI 3", () => {
cy
.visit("/?url=/documents/petstore-expanded.openapi.yaml")
.get("section.models > h4")
.contains("Schemas")
describe("SWOS-63: Schema/Model labeling", () => {
describe("SchemaS/Models section", () => {
it("should render `Schemas` for OpenAPI 3", () => {
cy
.visit("/?url=/documents/petstore-expanded.openapi.yaml")
.get("section.models > h4")
.contains("Schemas")
})
it("should render `Models` for OpenAPI 2", () => {
cy
.visit("/?url=/documents/petstore.swagger.yaml")
.get("section.models > h4")
.contains("Models")
})
})
it("should render `Models` for OpenAPI 2", () => {
cy
.visit("/?url=/documents/petstore.swagger.yaml")
.get("section.models > h4")
.contains("Models")
describe("ModelExample within Operation", () => {
it("should render `Schemas` for OpenAPI 3", () => {
cy
.visit("/?url=/documents/petstore-expanded.openapi.yaml")
.get("#operations-default-findPets")
.click()
.get("a.tablinks[data-name=model]")
.contains("Schema")
})
it("should render `Models` for OpenAPI 2", () => {
cy
.visit("/?url=/documents/petstore.swagger.yaml")
.get("section.models > h4")
.get("#operations-pet-addPet")
.click()
.get("a.tablinks[data-name=model]")
.contains("Model")
})
})
})

Načítá se…
Zrušit
Uložit