MCPcopy Index your code
hub / github.com/dataease/SQLBot / main_sampleFromSchemaGeneric

Function main_sampleFromSchemaGeneric

frontend/public/swagger-ui-bundle.js:74930–75168  ·  view source on GitHub ↗
(s, o = {}, i = void 0, a = !1)

Source from the content-addressed store, hash-verified

74928 )
74929 },
74930 NT = merge_merge,
74931 main_sampleFromSchemaGeneric = (s, o = {}, i = void 0, a = !1) => {
74932 if (null == s && void 0 === i) return
74933 ;('function' == typeof s?.toJS && (s = s.toJS()), (s = typeCast(s)))
74934 let u = void 0 !== i || hasExample(s)
74935 const _ = !u && Array.isArray(s.oneOf) && s.oneOf.length > 0,
74936 w = !u && Array.isArray(s.anyOf) && s.anyOf.length > 0
74937 if (!u && (_ || w)) {
74938 const i = typeCast(random_pick(_ ? s.oneOf : s.anyOf))
74939 ;(!(s = NT(s, i, o)).xml && i.xml && (s.xml = i.xml),
74940 hasExample(s) && hasExample(i) && (u = !0))
74941 }
74942 const x = {}
74943 let { xml: C, properties: j, additionalProperties: L, items: B, contains: $ } = s || {},
74944 U = type_getType(s),
74945 { includeReadOnly: V, includeWriteOnly: z } = o
74946 C = C || {}
74947 let Y,
74948 { name: Z, prefix: ee, namespace: ie } = C,
74949 ae = {}
74950 if (
74951 (Object.hasOwn(s, 'type') || (s.type = U),
74952 a && ((Z = Z || 'notagname'), (Y = (ee ? `${ee}:` : '') + Z), ie))
74953 ) {
74954 x[ee ? `xmlns:${ee}` : 'xmlns'] = ie
74955 }
74956 a && (ae[Y] = [])
74957 const ce = objectify(j)
74958 let le,
74959 pe = 0
74960 const hasExceededMaxProperties = () =>
74961 Number.isInteger(s.maxProperties) && s.maxProperties > 0 && pe >= s.maxProperties,
74962 canAddProperty = (o) =>
74963 !(Number.isInteger(s.maxProperties) && s.maxProperties > 0) ||
74964 (!hasExceededMaxProperties() &&
74965 (!((o) =>
74966 !Array.isArray(s.required) ||
74967 0 === s.required.length ||
74968 !s.required.includes(o))(o) ||
74969 s.maxProperties -
74970 pe -
74971 (() => {
74972 if (!Array.isArray(s.required) || 0 === s.required.length) return 0
74973 let o = 0
74974 return (
74975 a
74976 ? s.required.forEach((s) => (o += void 0 === ae[s] ? 0 : 1))
74977 : s.required.forEach((s) => {
74978 o += void 0 === ae[Y]?.find((o) => void 0 !== o[s]) ? 0 : 1
74979 }),
74980 s.required.length - o
74981 )
74982 })() >
74983 0))
74984 if (
74985 ((le = a
74986 ? (i, u = void 0) => {
74987 if (s && ce[i]) {

Callers 2

main_createXMLExampleFunction · 0.85
main_sampleFromSchemaFunction · 0.85

Calls 15

typeCastFunction · 0.85
hasExampleFunction · 0.85
random_pickFunction · 0.85
NTFunction · 0.85
type_getTypeFunction · 0.85
objectifyFunction · 0.85
extractExampleFunction · 0.85
asFunction · 0.85
canAddPropertyFunction · 0.85
isJSONSchemaObjectFunction · 0.85
hasExceededMaxPropertiesFunction · 0.85

Tested by

no test coverage detected