MCPcopy Create free account
hub / github.com/eclipsesource/jsonforms / getFirstPrimitiveProp

Function getFirstPrimitiveProp

packages/core/src/util/schema.ts:29–52  ·  view source on GitHub ↗
(schema: unknown)

Source from the content-addressed store, hash-verified

27import type { JsonSchema } from '../models';
28
29export const getFirstPrimitiveProp = (schema: unknown) => {
30 if (
31 schema &&
32 typeof schema === 'object' &&
33 'properties' in schema &&
34 schema.properties
35 ) {
36 return find(
37 Object.keys(schema.properties),
38 (propName: keyof typeof schema.properties) => {
39 const prop: unknown = schema.properties[propName];
40 return (
41 prop &&
42 typeof prop === 'object' &&
43 'type' in prop &&
44 (prop.type === 'string' ||
45 prop.type === 'number' ||
46 prop.type === 'integer')
47 );
48 }
49 );
50 }
51 return undefined;
52};
53
54/**
55 * Tests whether the schema has an enum based on oneOf.

Callers 4

computeChildLabelFunction · 0.90
mapAdditionalPropsMethod · 0.90
childLabelForIndexFunction · 0.90
childLabelForIndexFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…