Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/core/json-schema-components.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class JsonSchema_string extends Component {
const Select = getComponent("Select")
return (<Select className={ errors.length ? "invalid" : ""}
title={ errors.length ? errors : ""}
allowedValues={ enumValue }
allowedValues={ [...enumValue] }
value={ value }
allowEmptyValue={ !required }
disabled={disabled}
Expand Down Expand Up @@ -335,14 +335,14 @@ export class JsonSchema_boolean extends Component {
errors = errors.toJS ? errors.toJS() : []
let enumValue = schema && schema.get ? schema.get("enum") : null
let allowEmptyValue = !enumValue || !required
let booleanValue = !enumValue && fromJS(["true", "false"])
let booleanValue = !enumValue && ["true", "false"]
const Select = getComponent("Select")

return (<Select className={ errors.length ? "invalid" : ""}
title={ errors.length ? errors : ""}
value={ String(value) }
disabled={ disabled }
allowedValues={ enumValue || booleanValue }
allowedValues={ enumValue ? [...enumValue] : booleanValue }
allowEmptyValue={ allowEmptyValue }
onChange={ this.onEnumChange }/>)
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/get-parameter-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function getParameterSchema(parameter, { isOAS3 } = {}) {
}

return {
schema: parameter.get("schema", Im.Map()),
schema: parameter.get("schema") ? parameter.get("schema", Im.Map()): Im.Map(),
parameterContentMediaType: null,
}
}
32 changes: 32 additions & 0 deletions test/unit/components/parameter-row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ describe("<ParameterRow/>", () => {
expect(wrapper.find(".parameter__type").text()).toEqual("string")
})

it("Can render Swagger 2 parameter type boolean without format", () => {
const param = fromJS({
name: "hasId",
in: "path",
description: "boolean value to indicate if the pet has an id",
type: "boolean"
})

const props = createProps({ param, isOAS3: false })
const wrapper = render(<ParameterRow {...props}/>)

expect(wrapper.find(".parameter__type").length).toEqual(1)
expect(wrapper.find(".parameter__type").text()).toEqual("boolean")
})

it("Can render OAS3 parameter type with format", () => {
const param = fromJS({
name: "petUuid",
Expand Down Expand Up @@ -83,6 +98,23 @@ describe("<ParameterRow/>", () => {
expect(wrapper.find(".parameter__type").length).toEqual(1)
expect(wrapper.find(".parameter__type").text()).toEqual("string")
})

it("Can render OAS3 parameter type boolean without format", () => {
const param = fromJS({
name: "hasId",
in: "path",
description: "boolean value to indicate if the pet has an id",
schema: {
type: "boolean"
}
})

const props = createProps({ param, isOAS3: true })
const wrapper = render(<ParameterRow {...props}/>)

expect(wrapper.find(".parameter__type").length).toEqual(1)
expect(wrapper.find(".parameter__type").text()).toEqual("boolean")
})
})

describe("bug #5573: zero default and example values", function () {
Expand Down