UNPKG

@prefecthq/prefect-ui-library

Version:

This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.

23 lines (17 loc) 758 B
import merge from 'lodash.merge' import { Schema, SchemaDefinition, SchemaProperty, isPropertyWith } from '@/schemas/types/schema' export function getSchemaDefinition(schema: Schema, definition: SchemaDefinition): SchemaProperty { const definitionKey = definition.replace('#/definitions/', '') const definitionSchema = schema.definitions?.[definitionKey] if (!definitionSchema) { throw new Error(`Definition not found for ${definition}`) } return definitionSchema } export function mergeSchemaPropertyDefinition(property: SchemaProperty, schema: Schema): SchemaProperty { if (isPropertyWith(property, '$ref')) { const { $ref, ...rest } = property return merge({}, getSchemaDefinition(schema, $ref), rest) } return property }