diff --git a/schemars/src/flatten.rs b/schemars/src/flatten.rs index 930f8de..3a22888 100644 --- a/schemars/src/flatten.rs +++ b/schemars/src/flatten.rs @@ -32,7 +32,7 @@ macro_rules! impl_merge { impl_merge!(SchemaObject { merge: definitions extensions instance_type enum_values number string array object, - or: schema id title description format all_of any_of one_of not + or: schema id title description format const_value all_of any_of one_of not if_schema then_schema else_schema, }); diff --git a/schemars/src/schema.rs b/schemars/src/schema.rs index b0bb506..3074c51 100644 --- a/schemars/src/schema.rs +++ b/schemars/src/schema.rs @@ -47,13 +47,13 @@ pub struct SchemaObject { #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - // TODO Set instead of Vec pub instance_type: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub format: Option, #[serde(rename = "enum", skip_serializing_if = "Option::is_none")] - // TODO Set instead of Vec pub enum_values: Option>, + #[serde(rename = "const", skip_serializing_if = "Option::is_none")] + pub const_value: Option, #[serde(skip_serializing_if = "Option::is_none")] pub all_of: Option>, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/schemars/tests/expected/schema-openapi3.json b/schemars/tests/expected/schema-openapi3.json index 82f5f04..9ad9317 100644 --- a/schemars/tests/expected/schema-openapi3.json +++ b/schemars/tests/expected/schema-openapi3.json @@ -101,6 +101,9 @@ }, "nullable": true }, + "const": { + "nullable": true + }, "contains": { "anyOf": [ { diff --git a/schemars/tests/expected/schema.json b/schemars/tests/expected/schema.json index 10eaf9f..4c84b1d 100644 --- a/schemars/tests/expected/schema.json +++ b/schemars/tests/expected/schema.json @@ -117,6 +117,7 @@ } ] }, + "const": true, "contains": { "anyOf": [ {