From 57b255552b43499ab408a933dba08b054f770530 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Mon, 27 May 2024 13:29:54 +0200 Subject: [PATCH] Update doc comment for `offeringBasedSchema` (#184223) ## Summary Updates the doc comment to callout that this utility should only be used to validate Kibana config. --- .../src/helpers/offering_based_schema.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/kbn-config-schema/src/helpers/offering_based_schema.ts b/packages/kbn-config-schema/src/helpers/offering_based_schema.ts index 09ddfc3a75644..b4ccaf57330f2 100644 --- a/packages/kbn-config-schema/src/helpers/offering_based_schema.ts +++ b/packages/kbn-config-schema/src/helpers/offering_based_schema.ts @@ -12,6 +12,16 @@ import { Type, TypeOptions } from '../types'; /** * Helper to apply different validations depending on whether Kibana is running the Serverless or Traditional offering. * + * @remark This utility is intended to be used for Kibana YAML-based configuration validation only! Using it in other + * contexts will lead to only `traditional` validation being used. + * + * If you want to switch schemas based on the offering in other contexts do the following: + * + * ```ts + * // env is passed to your plugin constructor + * const schema = env.packageInfo.buildFlavor === 'serverless' ? baseSchema.extend(a) : baseSchema.extend(b); + * ``` + * * @example Only allow the setting on Serverless * const config = schema.object({ * myProp: offeringBasedSchema({ serverless: schema.boolean({ defaultValue: true }) }),