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

Function sampleFromSchemaGeneric

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

Source from the content-addressed store, hash-verified

37261 a
37262 )
37263 },
37264 sampleFromSchemaGeneric = (s, o = {}, i = void 0, a = !1) => {
37265 s && isFunc(s.toJS) && (s = s.toJS())
37266 let u = void 0 !== i || (s && void 0 !== s.example) || (s && void 0 !== s.default)
37267 const _ = !u && s && s.oneOf && s.oneOf.length > 0,
37268 w = !u && s && s.anyOf && s.anyOf.length > 0
37269 if (!u && (_ || w)) {
37270 const i = objectify(_ ? s.oneOf[0] : s.anyOf[0])
37271 if (
37272 (!(s = mergeJsonSchema(s, i, o)).xml && i.xml && (s.xml = i.xml),
37273 void 0 !== s.example && void 0 !== i.example)
37274 )
37275 u = !0
37276 else if (i.properties) {
37277 s.properties || (s.properties = {})
37278 let a = objectify(i.properties)
37279 for (let u in a)
37280 Object.prototype.hasOwnProperty.call(a, u) &&
37281 ((a[u] && a[u].deprecated) ||
37282 (a[u] && a[u].readOnly && !o.includeReadOnly) ||
37283 (a[u] && a[u].writeOnly && !o.includeWriteOnly) ||
37284 s.properties[u] ||
37285 ((s.properties[u] = a[u]),
37286 !i.required &&
37287 Array.isArray(i.required) &&
37288 -1 !== i.required.indexOf(u) &&
37289 (s.required ? s.required.push(u) : (s.required = [u]))))
37290 }
37291 }
37292 const x = {}
37293 let {
37294 xml: C,
37295 type: j,
37296 example: L,
37297 properties: B,
37298 additionalProperties: $,
37299 items: U,
37300 } = s || {},
37301 { includeReadOnly: V, includeWriteOnly: z } = o
37302 C = C || {}
37303 let Y,
37304 { name: Z, prefix: ee, namespace: ie } = C,
37305 ae = {}
37306 if (a && ((Z = Z || 'notagname'), (Y = (ee ? ee + ':' : '') + Z), ie)) {
37307 x[ee ? 'xmlns:' + ee : 'xmlns'] = ie
37308 }
37309 a && (ae[Y] = [])
37310 const schemaHasAny = (o) => o.some((o) => Object.prototype.hasOwnProperty.call(s, o))
37311 s &&
37312 !j &&
37313 (B || $ || schemaHasAny(ms)
37314 ? (j = 'object')
37315 : U || schemaHasAny(gs)
37316 ? (j = 'array')
37317 : schemaHasAny(ys)
37318 ? ((j = 'number'), (s.type = 'number'))
37319 : u || s.enum || ((j = 'string'), (s.type = 'string')))
37320 const handleMinMaxItems = (o) => {

Callers 2

createXMLExampleFunction · 0.85
sampleFromSchemaFunction · 0.85

Calls 15

isFuncFunction · 0.85
objectifyFunction · 0.85
mergeJsonSchemaFunction · 0.85
schemaHasAnyFunction · 0.85
primitiveFunction · 0.85
canAddPropertyFunction · 0.85
sanitizeRefFunction · 0.85
handleMinMaxItemsFunction · 0.85
hasExceededMaxPropertiesFunction · 0.85
normalizeArrayFunction · 0.85
concatMethod · 0.80
dsFunction · 0.50

Tested by

no test coverage detected