refactor: use samples plugin to generate schemas examples (#8728)
Refs #8577
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import React, { PureComponent } from "react"
|
||||
import PropTypes from "prop-types"
|
||||
import { fromJS, List } from "immutable"
|
||||
import { getSampleSchema } from "core/utils"
|
||||
import { getKnownSyntaxHighlighterLanguage } from "core/utils/jsonParse"
|
||||
|
||||
const NOOP = Function.prototype
|
||||
@@ -67,10 +66,10 @@ export default class ParamBody extends PureComponent {
|
||||
}
|
||||
|
||||
sample = (xml) => {
|
||||
let { param, fn:{inferSchema} } = this.props
|
||||
let schema = inferSchema(param.toJS())
|
||||
let { param, fn} = this.props
|
||||
let schema = fn.inferSchema(param.toJS())
|
||||
|
||||
return getSampleSchema(schema, xml, {
|
||||
return fn.getSampleSchema(schema, xml, {
|
||||
includeWriteOnly: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Map, List } from "immutable"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
import win from "core/window"
|
||||
import { getSampleSchema, getExtensions, getCommonExtensions, numberToString, stringify, isEmptyValue } from "core/utils"
|
||||
import { getExtensions, getCommonExtensions, numberToString, stringify, isEmptyValue } from "core/utils"
|
||||
import getParameterSchema from "../../helpers/get-parameter-schema.js"
|
||||
|
||||
export default class ParameterRow extends Component {
|
||||
@@ -94,7 +94,7 @@ export default class ParameterRow extends Component {
|
||||
}
|
||||
|
||||
setDefaultValue = () => {
|
||||
let { specSelectors, pathMethod, rawParam, oas3Selectors } = this.props
|
||||
let { specSelectors, pathMethod, rawParam, oas3Selectors, fn } = this.props
|
||||
|
||||
const paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()
|
||||
const { schema } = getParameterSchema(paramWithMeta, { isOAS3: specSelectors.isOAS3() })
|
||||
@@ -104,7 +104,7 @@ export default class ParameterRow extends Component {
|
||||
.first()
|
||||
|
||||
// getSampleSchema could return null
|
||||
const generatedSampleValue = schema ? getSampleSchema(schema.toJS(), parameterMediaType, {
|
||||
const generatedSampleValue = schema ? fn.getSampleSchema(schema.toJS(), parameterMediaType, {
|
||||
|
||||
includeWriteOnly: true
|
||||
}) : null
|
||||
|
||||
@@ -3,7 +3,7 @@ import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
import cx from "classnames"
|
||||
import { fromJS, Seq, Iterable, List, Map } from "immutable"
|
||||
import { getExtensions, getSampleSchema, fromJSOrdered, stringify } from "core/utils"
|
||||
import { getExtensions, fromJSOrdered, stringify } from "core/utils"
|
||||
import { getKnownSyntaxHighlighterLanguage } from "core/utils/jsonParse"
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ export default class Response extends React.Component {
|
||||
oas3Actions,
|
||||
} = this.props
|
||||
|
||||
let { inferSchema } = fn
|
||||
let { inferSchema, getSampleSchema } = fn
|
||||
let isOAS3 = specSelectors.isOAS3()
|
||||
const { showExtensions } = getConfigs()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user