diff --git a/.github/config-schema.json b/.github/config-schema.json index 2b2502569..599f52730 100644 --- a/.github/config-schema.json +++ b/.github/config-schema.json @@ -2259,7 +2259,7 @@ ], "allOf": [ { - "$ref": "#/definitions/Either_for_StarshipConditionalStyleConfig_and_Array_of_StarshipConditionalStyleConfig" + "$ref": "#/definitions/Either_for_Either_for_String_and_StarshipConditionalStyle_and_Array_of_Either_for_String_and_StarshipConditionalStyle" } ] }, @@ -2296,21 +2296,28 @@ } } }, - "Either_for_StarshipConditionalStyleConfig_and_Array_of_StarshipConditionalStyleConfig": { + "Either_for_Either_for_String_and_StarshipConditionalStyle_and_Array_of_Either_for_String_and_StarshipConditionalStyle": { "anyOf": [ { - "$ref": "#/definitions/StarshipConditionalStyleConfig" + "$ref": "#/definitions/Either_for_String_and_StarshipConditionalStyle" }, { "type": "array", "items": { - "$ref": "#/definitions/StarshipConditionalStyleConfig" + "$ref": "#/definitions/Either_for_String_and_StarshipConditionalStyle" } } ] }, - "StarshipConditionalStyleConfig": { - "$ref": "#/definitions/StarshipConditionalStyle" + "Either_for_String_and_StarshipConditionalStyle": { + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/definitions/StarshipConditionalStyle" + } + ] }, "StarshipConditionalStyle": { "type": "object", diff --git a/src/conditional_style.rs b/src/conditional_style.rs index 9d3ab7cb1..adb77cad1 100644 --- a/src/conditional_style.rs +++ b/src/conditional_style.rs @@ -77,9 +77,23 @@ impl<'a> StarshipConditionalStyle<'a> { } #[derive(Clone, Debug, Default, Serialize, PartialEq)] -#[cfg_attr(feature = "config-schema", derive(schemars::JsonSchema))] pub struct StarshipConditionalStyleConfig<'a>(StarshipConditionalStyle<'a>); +#[cfg(feature = "config-schema")] +impl<'a> schemars::JsonSchema for StarshipConditionalStyleConfig<'a> { + fn schema_name() -> String { + Either::::schema_name() + } + + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + Either::::json_schema(gen) + } + + fn is_referenceable() -> bool { + Either::::is_referenceable() + } +} + impl<'de: 'a, 'a> Deserialize<'de> for StarshipConditionalStyleConfig<'a> { fn deserialize(deserializer: D) -> Result where