Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/core/components/parameter-row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ export default class ParameterRow extends Component {
schema = this.composeJsonSchema(schema)
}

let format = schema ? schema.get("format") : null
const hasCombiningKeywords = schema && (schema.get("anyOf") || schema.get("oneOf"))
let format = !hasCombiningKeywords && schema ? schema.get("format") : null
let isFormData = inType === "formData"
let isFormDataSupported = "FormData" in win
let required = param.get("required")
Expand Down
15 changes: 10 additions & 5 deletions src/core/plugins/json-schema-2020-12/fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,14 @@ export const makeGetType = (fnAccessor) => {

const handleCombiningKeywords = (keyword, separator) => {
if (Array.isArray(schema[keyword])) {
const combinedTypes = schema[keyword].map((subSchema) =>
getType(subSchema, processedSchemas)
)
return `(${combinedTypes.join(separator)})`
const combinedTypes = schema[keyword].map((subSchema) => {
let subType = getType(subSchema, processedSchemas)
if (subSchema?.format) {
subType = `${subType}($${subSchema.format})`
}
return subType
})
return combinedTypes.join(separator)
}
return null
}
Expand All @@ -155,7 +159,8 @@ export const makeGetType = (fnAccessor) => {
const anyOfString = handleCombiningKeywords("anyOf", " | ")
const allOfString = handleCombiningKeywords("allOf", " & ")

const combinedStrings = [typeString, oneOfString, anyOfString, allOfString]
const hasUnionKeyword = oneOfString || anyOfString
const combinedStrings = [hasUnionKeyword ? null : typeString, oneOfString, anyOfString, allOfString]
.filter(Boolean)
.join(" | ")

Expand Down
3 changes: 2 additions & 1 deletion src/core/plugins/oas3/components/request-body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ const RequestBody = ({
const objectType = fn.getSchemaObjectType(schema)
const objectTypeLabel = fn.getSchemaObjectTypeLabel(schema)
const schemaItemsType = fn.getSchemaObjectType(schema?.get("items"))
const format = schema.get("format")
const hasCombiningKeywords = schema.get("anyOf") || schema.get("oneOf")
const format = !hasCombiningKeywords ? schema.get("format") : null
const description = schema.get("description")
const currentValue = requestBodyValue.getIn([key, "value"])
const currentErrors = requestBodyValue.getIn([key, "errors"]) || requestBodyErrors
Expand Down