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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"hot-e2e-cypress-server": "webpack-dev-server --config webpack/dev-e2e.babel.js --content-base test/e2e-cypress/static",
"hot-e2e-selenium-server": "webpack-dev-server --config webpack/dev-e2e.babel.js --content-base test/e2e-selenium/static",
"e2e-cypress": "run-p -r hot-e2e-cypress-server mock-api test-e2e-cypress",
"dev-test-e2e-cypress-open": "cypress open",
"dev-e2e-cypress": "run-p -r hot-e2e-cypress-server mock-api dev-e2e-cypress-open",
"e2e-selenium": "run-p -r hot-e2e-selenium-server mock-api test-e2e-selenium",
"open-static": "node -e \"require('open')('http://localhost:3002')\"",
"security-audit": "run-s -sc security-audit:all security-audit:prod",
Expand Down
35 changes: 18 additions & 17 deletions src/core/components/parameter-row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class ParameterRow extends Component {

if(isOAS3) {
let { schema } = getParameterSchema(parameterWithMeta, { isOAS3 })
enumValue = schema.get("enum")
enumValue = schema ? schema.get("enum") : undefined
} else {
enumValue = parameterWithMeta ? parameterWithMeta.get("enum") : undefined
}
Expand All @@ -59,7 +59,7 @@ export default class ParameterRow extends Component {
if ( value !== undefined && value !== paramValue ) {
this.onChangeWrapper(numberToString(value))
}

// todo: could check if schema here; if not, do not call. impact?
this.setDefaultValue()
}

Expand Down Expand Up @@ -97,17 +97,16 @@ export default class ParameterRow extends Component {
let { specSelectors, pathMethod, rawParam, oas3Selectors } = this.props

const paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()

const { schema } = getParameterSchema(paramWithMeta, { isOAS3: specSelectors.isOAS3() })

const parameterMediaType = paramWithMeta
.get("content", Map())
.keySeq()
.first()

const generatedSampleValue = getSampleSchema(schema.toJS(), parameterMediaType, {
// getSampleSchema could return null
const generatedSampleValue = schema ? getSampleSchema(schema.toJS(), parameterMediaType, {
includeWriteOnly: true
})
}) : null

if (!paramWithMeta || paramWithMeta.get("value") !== undefined) {
return
Expand All @@ -121,14 +120,14 @@ export default class ParameterRow extends Component {
if (specSelectors.isSwagger2()) {
initialValue = paramWithMeta.get("x-example")
|| paramWithMeta.getIn(["schema", "example"])
|| schema.getIn(["default"])
|| (schema && schema.getIn(["default"]))
} else if (specSelectors.isOAS3()) {
const currentExampleKey = oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
initialValue = paramWithMeta.getIn(["examples", currentExampleKey, "value"])
|| paramWithMeta.getIn(["content", parameterMediaType, "example"])
|| paramWithMeta.get("example")
|| schema.get("example")
|| schema.get("default")
|| (schema && schema.get("example"))
|| (schema && schema.get("default"))
|| paramWithMeta.get("default") // ensures support for `parameterMacro`
}

Expand All @@ -144,7 +143,7 @@ export default class ParameterRow extends Component {
if(initialValue !== undefined) {
this.onChangeWrapper(initialValue)
} else if(
schema.get("type") === "object"
schema && schema.get("type") === "object"
&& generatedSampleValue
&& !paramWithMeta.get("examples")
) {
Expand Down Expand Up @@ -212,12 +211,12 @@ export default class ParameterRow extends Component {
let { schema } = getParameterSchema(param, { isOAS3 })
let paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()

let format = schema.get("format")
let type = schema.get("type")
let format = schema ? schema.get("format") : null
let type = schema ? schema.get("type") : null
let itemType = schema ? schema.getIn(["items", "type"]) : null
let isFormData = inType === "formData"
let isFormDataSupported = "FormData" in win
let required = param.get("required")
let itemType = schema.getIn(["items", "type"])

let value = paramWithMeta ? paramWithMeta.get("value") : ""
let commonExt = showCommonExtensions ? getCommonExtensions(schema) : null
Expand All @@ -229,24 +228,26 @@ export default class ParameterRow extends Component {
let paramExample // undefined
let isDisplayParamEnum = false

if ( param !== undefined ) {
if ( param !== undefined && schema ) {
paramItems = schema.get("items")
}

if (paramItems !== undefined) {
paramEnum = paramItems.get("enum")
paramDefaultValue = paramItems.get("default")
} else {
} else if (schema) {
paramEnum = schema.get("enum")
}

if ( paramEnum !== undefined && paramEnum.size > 0) {
if ( paramEnum && paramEnum.size && paramEnum.size > 0) {
isDisplayParamEnum = true
}

// Default and Example Value for readonly doc
if ( param !== undefined ) {
paramDefaultValue = schema.get("default")
if (schema) {
paramDefaultValue = schema.get("default")
}
if (paramDefaultValue === undefined) {
paramDefaultValue = param.get("default")
}
Expand Down
Loading