Skip to content

Commit

Permalink
Merge pull request #2882 from PrefectHQ/craig/oss-5561-customwebhookn…
Browse files Browse the repository at this point in the history
…otificationblock-not-allowing-headers-in-ui

Add support for properties with "additionalProperties" to schemas v1
  • Loading branch information
pleek91 authored Jan 10, 2025
2 parents 2017a75 + 675e398 commit 6af6258
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/SchemaFormPropertyAnyOf.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<p-button-group v-model="selected" :options="options" small />

<p-label class="schema-form-property-any-of__fields p-background" :description="description">
<template v-if="isObject">
<template v-if="displayedDefinition.meta && displayedDefinition.meta.component">
<SchemaFormProperty :property="displayedDefinition" :prop-key="propKey" />
</template>

<template v-else-if="isObject">
<p-content>
<template v-for="(subProperty, key) in displayedDefinition.properties" :key="key">
<SchemaFormProperty :prop-key="`${propKey}.${key}`" :property="subProperty!" />
Expand Down
7 changes: 7 additions & 0 deletions src/services/schemas/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ function findObjectDefinitionIndex(definitions: Schema[], value: object | null):
}, [0, 0])

if (keysInCommon === 0) {
const indexOfDefinitionWithAdditionalProperties = definitions.findIndex(definition => definition.additionalProperties)

// Since we were unable to find a definition with a matching set of keys, we'll use the definition with additionalProperties if one exists.
if (indexOfDefinitionWithAdditionalProperties !== -1) {
return indexOfDefinitionWithAdditionalProperties
}

return null
}

Expand Down
1 change: 1 addition & 0 deletions src/types/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export type SchemaProperty = {
multipleOf?: number,
pattern?: string,
properties?: SchemaProperties,
additionalProperties?: SchemaProperty | boolean,
required?: string[],
title?: string,
type?: SchemaType,
Expand Down

0 comments on commit 6af6258

Please sign in to comment.