committed by
Vladimír Gorej
parent
1ce9ce0cda
commit
2ce9d08af7
@@ -175,7 +175,7 @@ const RequestBody = ({
|
||||
}
|
||||
if (type === "object" || useInitialValue) {
|
||||
// TODO: what about example or examples from requestBody could be passed as exampleOverride
|
||||
initialValue = getSampleSchema(prop, false, {
|
||||
initialValue = fn.getSampleSchema(prop, false, {
|
||||
includeWriteOnly: true
|
||||
})
|
||||
}
|
||||
@@ -242,6 +242,7 @@ const RequestBody = ({
|
||||
requestBody,
|
||||
contentType,
|
||||
activeExamplesKey,
|
||||
fn,
|
||||
)
|
||||
let language = null
|
||||
let testValueForJson = getKnownSyntaxHighlighterLanguage(sampleRequestBody)
|
||||
|
||||
@@ -103,7 +103,7 @@ export const selectDefaultRequestBodyValue =
|
||||
}
|
||||
|
||||
export const hasUserEditedBody = onlyOAS3((state, path, method) => (system) => {
|
||||
const { oas3Selectors, specSelectors } = system
|
||||
const { oas3Selectors, specSelectors, fn } = system
|
||||
|
||||
let userHasEditedBody = false
|
||||
const currentMediaType = oas3Selectors.requestContentType(path, method)
|
||||
@@ -147,7 +147,8 @@ export const hasUserEditedBody = onlyOAS3((state, path, method) => (system) => {
|
||||
method,
|
||||
"requestBody",
|
||||
"requestBody"
|
||||
)
|
||||
),
|
||||
fn
|
||||
)
|
||||
userHasEditedBody =
|
||||
!!userEditedRequestBody &&
|
||||
|
||||
@@ -1,78 +1,128 @@
|
||||
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import React from "react"
|
||||
import { List, fromJS } from "immutable"
|
||||
|
||||
import { render } from "enzyme"
|
||||
|
||||
import ParameterRow from "components/parameter-row"
|
||||
import {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
} from "core/plugins/samples/fn/index"
|
||||
import makeGetSampleSchema from "core/plugins/samples/fn/get-sample-schema"
|
||||
import makeGetJsonSampleSchema from "core/plugins/samples/fn/get-json-sample-schema"
|
||||
import makeGetYamlSampleSchema from "core/plugins/samples/fn/get-yaml-sample-schema"
|
||||
import makeGetXmlSampleSchema from "core/plugins/samples/fn/get-xml-sample-schema"
|
||||
|
||||
describe("bug #4557: default parameter values", function(){
|
||||
it("should apply a Swagger 2.0 default value", function(){
|
||||
|
||||
describe("bug #4557: default parameter values", function () {
|
||||
it("should apply a Swagger 2.0 default value", function () {
|
||||
const paramValue = fromJS({
|
||||
description: "a pet",
|
||||
type: "string",
|
||||
default: "MyDefaultValue"
|
||||
default: "MyDefaultValue",
|
||||
})
|
||||
|
||||
let props = {
|
||||
getComponent: ()=> "div",
|
||||
const getSystem = () => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
security(){},
|
||||
parameterWithMetaByIdentity(){ return paramValue },
|
||||
isOAS3(){ return false },
|
||||
isSwagger2(){ return true }
|
||||
security() {},
|
||||
parameterWithMetaByIdentity() {
|
||||
return paramValue
|
||||
},
|
||||
isOAS3() {
|
||||
return false
|
||||
},
|
||||
isSwagger2() {
|
||||
return true
|
||||
},
|
||||
},
|
||||
fn: {},
|
||||
operation: {get: ()=>{}},
|
||||
getConfigs: () => {
|
||||
return {}
|
||||
},
|
||||
fn: {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
})
|
||||
const props = {
|
||||
...getSystem(),
|
||||
operation: { get: () => {} },
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
specPath: List([]),
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props}/>)
|
||||
render(<ParameterRow {...props} />)
|
||||
|
||||
expect(props.onChange).toHaveBeenCalled()
|
||||
expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
|
||||
expect(props.onChange).toHaveBeenCalledWith(
|
||||
paramValue,
|
||||
"MyDefaultValue",
|
||||
false
|
||||
)
|
||||
})
|
||||
it("should apply an OpenAPI 3.0 default value", function(){
|
||||
|
||||
it("should apply an OpenAPI 3.0 default value", function () {
|
||||
const paramValue = fromJS({
|
||||
description: "a pet",
|
||||
schema: {
|
||||
type: "string",
|
||||
default: "MyDefaultValue"
|
||||
}
|
||||
default: "MyDefaultValue",
|
||||
},
|
||||
})
|
||||
|
||||
let props = {
|
||||
getComponent: ()=> "div",
|
||||
const getSystem = () => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
security(){},
|
||||
parameterWithMetaByIdentity(){ return paramValue },
|
||||
isOAS3(){ return true },
|
||||
isSwagger2() { return false }
|
||||
security() {},
|
||||
parameterWithMetaByIdentity() {
|
||||
return paramValue
|
||||
},
|
||||
isOAS3() {
|
||||
return true
|
||||
},
|
||||
isSwagger2() {
|
||||
return false
|
||||
},
|
||||
},
|
||||
oas3Selectors: {
|
||||
activeExamplesMember: () => null
|
||||
activeExamplesMember: () => null,
|
||||
},
|
||||
fn: {},
|
||||
operation: {get: ()=>{}},
|
||||
getConfigs: () => {
|
||||
return {}
|
||||
},
|
||||
fn: {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
})
|
||||
const props = {
|
||||
...getSystem(),
|
||||
operation: { get: () => {} },
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
specPath: List([]),
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props}/>)
|
||||
render(<ParameterRow {...props} />)
|
||||
|
||||
expect(props.onChange).toHaveBeenCalled()
|
||||
expect(props.onChange).toHaveBeenCalledWith(paramValue, "MyDefaultValue", false)
|
||||
expect(props.onChange).toHaveBeenCalledWith(
|
||||
paramValue,
|
||||
"MyDefaultValue",
|
||||
false
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,22 +1,48 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import React from "react"
|
||||
import { List, fromJS } from "immutable"
|
||||
import { render } from "enzyme"
|
||||
|
||||
import ParameterRow from "components/parameter-row"
|
||||
import {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
} from "core/plugins/samples/fn/index"
|
||||
import makeGetSampleSchema from "core/plugins/samples/fn/get-sample-schema"
|
||||
import makeGetJsonSampleSchema from "core/plugins/samples/fn/get-json-sample-schema"
|
||||
import makeGetYamlSampleSchema from "core/plugins/samples/fn/get-yaml-sample-schema"
|
||||
import makeGetXmlSampleSchema from "core/plugins/samples/fn/get-xml-sample-schema"
|
||||
|
||||
describe("<ParameterRow/>", () => {
|
||||
const createProps = ({ param, isOAS3 }) => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
parameterWithMetaByIdentity: () => param,
|
||||
isOAS3: () => isOAS3,
|
||||
isSwagger2: () => !isOAS3
|
||||
},
|
||||
oas3Selectors: { activeExamplesMember: () => {} },
|
||||
param,
|
||||
rawParam: param,
|
||||
pathMethod: [],
|
||||
getConfigs: () => ({})
|
||||
})
|
||||
const createProps = ({ param, isOAS3 }) => {
|
||||
const getSystem = () => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
parameterWithMetaByIdentity: () => param,
|
||||
isOAS3: () => isOAS3,
|
||||
isSwagger2: () => !isOAS3,
|
||||
},
|
||||
fn: {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
oas3Selectors: { activeExamplesMember: () => {} },
|
||||
getConfigs: () => ({}),
|
||||
})
|
||||
|
||||
return {
|
||||
...getSystem(),
|
||||
param,
|
||||
rawParam: param,
|
||||
pathMethod: [],
|
||||
}
|
||||
}
|
||||
|
||||
it("Can render Swagger 2 parameter type with format", () => {
|
||||
const param = fromJS({
|
||||
@@ -24,11 +50,11 @@ describe("<ParameterRow/>", () => {
|
||||
in: "path",
|
||||
description: "UUID that identifies a pet",
|
||||
type: "string",
|
||||
format: "uuid"
|
||||
format: "uuid",
|
||||
})
|
||||
|
||||
const props = createProps({ param, isOAS3: false })
|
||||
const wrapper = render(<ParameterRow {...props}/>)
|
||||
const wrapper = render(<ParameterRow {...props} />)
|
||||
|
||||
expect(wrapper.find(".parameter__type").length).toEqual(1)
|
||||
expect(wrapper.find(".parameter__type").text()).toEqual("string($uuid)")
|
||||
@@ -39,11 +65,11 @@ describe("<ParameterRow/>", () => {
|
||||
name: "petId",
|
||||
in: "path",
|
||||
description: "ID that identifies a pet",
|
||||
type: "string"
|
||||
type: "string",
|
||||
})
|
||||
|
||||
const props = createProps({ param, isOAS3: false })
|
||||
const wrapper = render(<ParameterRow {...props}/>)
|
||||
const wrapper = render(<ParameterRow {...props} />)
|
||||
|
||||
expect(wrapper.find(".parameter__type").length).toEqual(1)
|
||||
expect(wrapper.find(".parameter__type").text()).toEqual("string")
|
||||
@@ -54,11 +80,11 @@ describe("<ParameterRow/>", () => {
|
||||
name: "hasId",
|
||||
in: "path",
|
||||
description: "boolean value to indicate if the pet has an id",
|
||||
type: "boolean"
|
||||
type: "boolean",
|
||||
})
|
||||
|
||||
const props = createProps({ param, isOAS3: false })
|
||||
const wrapper = render(<ParameterRow {...props}/>)
|
||||
const wrapper = render(<ParameterRow {...props} />)
|
||||
|
||||
expect(wrapper.find(".parameter__type").length).toEqual(1)
|
||||
expect(wrapper.find(".parameter__type").text()).toEqual("boolean")
|
||||
@@ -71,12 +97,12 @@ describe("<ParameterRow/>", () => {
|
||||
description: "UUID that identifies a pet",
|
||||
schema: {
|
||||
type: "string",
|
||||
format: "uuid"
|
||||
}
|
||||
format: "uuid",
|
||||
},
|
||||
})
|
||||
|
||||
const props = createProps({ param, isOAS3: true })
|
||||
const wrapper = render(<ParameterRow {...props}/>)
|
||||
const wrapper = render(<ParameterRow {...props} />)
|
||||
|
||||
expect(wrapper.find(".parameter__type").length).toEqual(1)
|
||||
expect(wrapper.find(".parameter__type").text()).toEqual("string($uuid)")
|
||||
@@ -88,12 +114,12 @@ describe("<ParameterRow/>", () => {
|
||||
in: "path",
|
||||
description: "ID that identifies a pet",
|
||||
schema: {
|
||||
type: "string"
|
||||
}
|
||||
type: "string",
|
||||
},
|
||||
})
|
||||
|
||||
const props = createProps({ param, isOAS3: true })
|
||||
const wrapper = render(<ParameterRow {...props}/>)
|
||||
const wrapper = render(<ParameterRow {...props} />)
|
||||
|
||||
expect(wrapper.find(".parameter__type").length).toEqual(1)
|
||||
expect(wrapper.find(".parameter__type").text()).toEqual("string")
|
||||
@@ -105,12 +131,12 @@ describe("<ParameterRow/>", () => {
|
||||
in: "path",
|
||||
description: "boolean value to indicate if the pet has an id",
|
||||
schema: {
|
||||
type: "boolean"
|
||||
}
|
||||
type: "boolean",
|
||||
},
|
||||
})
|
||||
|
||||
const props = createProps({ param, isOAS3: true })
|
||||
const wrapper = render(<ParameterRow {...props}/>)
|
||||
const wrapper = render(<ParameterRow {...props} />)
|
||||
|
||||
expect(wrapper.find(".parameter__type").length).toEqual(1)
|
||||
expect(wrapper.find(".parameter__type").text()).toEqual("boolean")
|
||||
@@ -122,26 +148,42 @@ describe("bug #5573: zero default and example values", function () {
|
||||
const paramValue = fromJS({
|
||||
description: "a pet",
|
||||
type: "integer",
|
||||
default: 0
|
||||
default: 0,
|
||||
})
|
||||
|
||||
let props = {
|
||||
const getSystem = () => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
security() { },
|
||||
parameterWithMetaByIdentity() { return paramValue },
|
||||
isOAS3() { return false },
|
||||
isSwagger2() { return true }
|
||||
security() {},
|
||||
parameterWithMetaByIdentity() {
|
||||
return paramValue
|
||||
},
|
||||
isOAS3() {
|
||||
return false
|
||||
},
|
||||
isSwagger2() {
|
||||
return true
|
||||
},
|
||||
},
|
||||
fn: {},
|
||||
operation: { get: () => { } },
|
||||
fn: {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
getConfigs: () => {
|
||||
return {}
|
||||
},
|
||||
})
|
||||
const props = {
|
||||
...getSystem(),
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => { },
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
specPath: List([]),
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props} />)
|
||||
@@ -154,27 +196,44 @@ describe("bug #5573: zero default and example values", function () {
|
||||
description: "a pet",
|
||||
type: "integer",
|
||||
schema: {
|
||||
example: 0
|
||||
}
|
||||
example: 0,
|
||||
},
|
||||
})
|
||||
|
||||
let props = {
|
||||
const getSystem = () => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
security() { },
|
||||
parameterWithMetaByIdentity() { return paramValue },
|
||||
isOAS3() { return false },
|
||||
isSwagger2() { return true }
|
||||
security() {},
|
||||
parameterWithMetaByIdentity() {
|
||||
return paramValue
|
||||
},
|
||||
isOAS3() {
|
||||
return false
|
||||
},
|
||||
isSwagger2() {
|
||||
return true
|
||||
},
|
||||
},
|
||||
fn: {},
|
||||
operation: { get: () => { } },
|
||||
getConfigs: () => {
|
||||
return {}
|
||||
},
|
||||
fn: {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
})
|
||||
const props = {
|
||||
...getSystem(),
|
||||
operation: { get: () => {} },
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => { },
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
specPath: List([]),
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props} />)
|
||||
@@ -187,30 +246,47 @@ describe("bug #5573: zero default and example values", function () {
|
||||
description: "a pet",
|
||||
schema: {
|
||||
type: "integer",
|
||||
default: 0
|
||||
}
|
||||
default: 0,
|
||||
},
|
||||
})
|
||||
|
||||
let props = {
|
||||
const getSystem = () => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
security() { },
|
||||
parameterWithMetaByIdentity() { return paramValue },
|
||||
isOAS3() { return true },
|
||||
isSwagger2() { return false }
|
||||
security() {},
|
||||
parameterWithMetaByIdentity() {
|
||||
return paramValue
|
||||
},
|
||||
isOAS3() {
|
||||
return true
|
||||
},
|
||||
isSwagger2() {
|
||||
return false
|
||||
},
|
||||
},
|
||||
oas3Selectors: {
|
||||
activeExamplesMember: () => null
|
||||
activeExamplesMember: () => null,
|
||||
},
|
||||
fn: {},
|
||||
operation: { get: () => { } },
|
||||
getConfigs: () => {
|
||||
return {}
|
||||
},
|
||||
fn: {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
})
|
||||
const props = {
|
||||
...getSystem(),
|
||||
operation: { get: () => {} },
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => { },
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
specPath: List([]),
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props} />)
|
||||
@@ -223,30 +299,47 @@ describe("bug #5573: zero default and example values", function () {
|
||||
description: "a pet",
|
||||
schema: {
|
||||
type: "integer",
|
||||
example: 0
|
||||
}
|
||||
example: 0,
|
||||
},
|
||||
})
|
||||
|
||||
let props = {
|
||||
const getSystem = () => ({
|
||||
getComponent: () => "div",
|
||||
specSelectors: {
|
||||
security() { },
|
||||
parameterWithMetaByIdentity() { return paramValue },
|
||||
isOAS3() { return true },
|
||||
isSwagger2() { return false }
|
||||
security() {},
|
||||
parameterWithMetaByIdentity() {
|
||||
return paramValue
|
||||
},
|
||||
isOAS3() {
|
||||
return true
|
||||
},
|
||||
isSwagger2() {
|
||||
return false
|
||||
},
|
||||
},
|
||||
oas3Selectors: {
|
||||
activeExamplesMember: () => null
|
||||
activeExamplesMember: () => null,
|
||||
},
|
||||
fn: {},
|
||||
operation: { get: () => { } },
|
||||
getConfigs: () => {
|
||||
return {}
|
||||
},
|
||||
fn: {
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
})
|
||||
const props = {
|
||||
...getSystem(),
|
||||
operation: { get: () => {} },
|
||||
onChange: jest.fn(),
|
||||
param: paramValue,
|
||||
rawParam: paramValue,
|
||||
onChangeConsumes: () => { },
|
||||
onChangeConsumes: () => {},
|
||||
pathMethod: [],
|
||||
getConfigs: () => { return {} },
|
||||
specPath: List([])
|
||||
specPath: List([]),
|
||||
}
|
||||
|
||||
render(<ParameterRow {...props} />)
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
/**
|
||||
* @prettier
|
||||
*/
|
||||
import React from "react"
|
||||
import { shallow } from "enzyme"
|
||||
import { fromJS, List } from "immutable"
|
||||
|
||||
import Response from "components/response"
|
||||
import ModelExample from "components/model-example"
|
||||
import { inferSchema } from "corePlugins/samples/fn"
|
||||
import {
|
||||
inferSchema,
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
} from "core/plugins/samples/fn/index"
|
||||
import makeGetSampleSchema from "core/plugins/samples/fn/get-sample-schema"
|
||||
import makeGetJsonSampleSchema from "core/plugins/samples/fn/get-json-sample-schema"
|
||||
import makeGetYamlSampleSchema from "core/plugins/samples/fn/get-yaml-sample-schema"
|
||||
import makeGetXmlSampleSchema from "core/plugins/samples/fn/get-xml-sample-schema"
|
||||
|
||||
describe("<Response />", function () {
|
||||
const dummyComponent = () => null
|
||||
@@ -13,21 +25,30 @@ describe("<Response />", function () {
|
||||
modelExample: ModelExample,
|
||||
Markdown: dummyComponent,
|
||||
operationLink: dummyComponent,
|
||||
contentType: dummyComponent
|
||||
contentType: dummyComponent,
|
||||
}
|
||||
const props = {
|
||||
getComponent: c => components[c],
|
||||
const getSystem = () => ({
|
||||
getComponent: (c) => components[c],
|
||||
getConfigs: () => {
|
||||
return {}
|
||||
},
|
||||
specSelectors: {
|
||||
isOAS3() {
|
||||
return false
|
||||
}
|
||||
},
|
||||
},
|
||||
fn: {
|
||||
inferSchema
|
||||
inferSchema,
|
||||
memoizedSampleFromSchema,
|
||||
memoizedCreateXMLExample,
|
||||
getJsonSampleSchema: makeGetJsonSampleSchema(getSystem),
|
||||
getYamlSampleSchema: makeGetYamlSampleSchema(getSystem),
|
||||
getXmlSampleSchema: makeGetXmlSampleSchema(getSystem),
|
||||
getSampleSchema: makeGetSampleSchema(getSystem),
|
||||
},
|
||||
})
|
||||
const props = {
|
||||
...getSystem(),
|
||||
contentType: "application/json",
|
||||
className: "for-test",
|
||||
specPath: List(),
|
||||
@@ -36,19 +57,19 @@ describe("<Response />", function () {
|
||||
type: "object",
|
||||
properties: {
|
||||
// Note reverse order: c, b, a
|
||||
"c": {
|
||||
type: "integer"
|
||||
c: {
|
||||
type: "integer",
|
||||
},
|
||||
"b": {
|
||||
type: "boolean"
|
||||
b: {
|
||||
type: "boolean",
|
||||
},
|
||||
"a": {
|
||||
type: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
a: {
|
||||
type: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
code: "200"
|
||||
code: "200",
|
||||
}
|
||||
|
||||
it("renders the model-example schema properties in order", function () {
|
||||
@@ -57,7 +78,9 @@ describe("<Response />", function () {
|
||||
expect(renderedModelExample.length).toEqual(1)
|
||||
|
||||
// Assert the schema's properties have maintained their order
|
||||
const modelExampleSchemaProperties = renderedModelExample.props().schema.toJS().properties
|
||||
const modelExampleSchemaProperties = renderedModelExample
|
||||
.props()
|
||||
.schema.toJS().properties
|
||||
expect(Object.keys(modelExampleSchemaProperties)).toEqual(["c", "b", "a"])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user