Skip to content

Instantly share code, notes, and snippets.

@nightkr
Created March 22, 2024 16:31
Show Gist options
  • Save nightkr/f7f06df7a14286a9b682ad6be7e3da14 to your computer and use it in GitHub Desktop.
Save nightkr/f7f06df7a14286a9b682ad6be7e3da14 to your computer and use it in GitHub Desktop.
$schema: http://json-schema.org/draft-07/schema#
title: Foo
type: object
required:
- optional_new
- required
properties:
optional_new:
type:
- object
- 'null'
additionalProperties:
type: string
optional_old:
anyOf:
- $ref: '#/definitions/StackableNodeSelector'
- type: 'null'
required:
$ref: '#/definitions/StackableNodeSelector'
definitions:
StackableNodeSelector:
description: |-
We can not simply use [`BTreeMap<String, String>`] in [`StackableAffinity`], as the fields needs to be [`Atomic`]. We can not mark it as [`Atomic`], as [`crate::config::fragment::FromFragment`] is already implemented for [`BTreeMap<String, String>`].
We `#[serde(flatten)]` the contained [`BTreeMap<String, String>`], so `serde_yaml` can deserialize everything as expected. However the generated JsonSchema will be wrong, so we need to provide our custom one (see <https://github.com/stackabletech/issues/issues/554> for details).
type: object
additionalProperties:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment