(schema: unknown)
| 27 | import type { JsonSchema } from '../models'; |
| 28 | |
| 29 | export 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. |
no outgoing calls
no test coverage detected
searching dependent graphs…