diff --git a/schemars/tests/expected/doc_comments_enum.json b/schemars/tests/expected/doc_comments_enum.json index 2115c37..1961955 100644 --- a/schemars/tests/expected/doc_comments_enum.json +++ b/schemars/tests/expected/doc_comments_enum.json @@ -4,6 +4,7 @@ "description": "This is the enum's description.", "anyOf": [ { + "type": "string", "enum": [ "UndocumentedUnit", "DocumentedUnit" diff --git a/schemars/tests/expected/enum-external.json b/schemars/tests/expected/enum-external.json index a041210..466d458 100644 --- a/schemars/tests/expected/enum-external.json +++ b/schemars/tests/expected/enum-external.json @@ -3,6 +3,7 @@ "title": "External", "anyOf": [ { + "type": "string", "enum": [ "unitOne", "unitTwo" diff --git a/schemars/tests/expected/schema-2019_09.json b/schemars/tests/expected/schema-2019_09.json index 5592b53..2f7a1ca 100644 --- a/schemars/tests/expected/schema-2019_09.json +++ b/schemars/tests/expected/schema-2019_09.json @@ -358,6 +358,7 @@ "definitions": { "InstanceType": { "description": "The possible types of values in JSON Schema documents.\n\nSee [JSON Schema 4.2.1. Instance Data Model](https://tools.ietf.org/html/draft-handrews-json-schema-02#section-4.2.1).", + "type": "string", "enum": [ "null", "boolean", diff --git a/schemars/tests/expected/schema-openapi3.json b/schemars/tests/expected/schema-openapi3.json index 6da10c6..8d35dbb 100644 --- a/schemars/tests/expected/schema-openapi3.json +++ b/schemars/tests/expected/schema-openapi3.json @@ -294,6 +294,7 @@ "definitions": { "InstanceType": { "description": "The possible types of values in JSON Schema documents.\n\nSee [JSON Schema 4.2.1. Instance Data Model](https://tools.ietf.org/html/draft-handrews-json-schema-02#section-4.2.1).", + "type": "string", "enum": [ "null", "boolean", diff --git a/schemars/tests/expected/schema.json b/schemars/tests/expected/schema.json index 8b0d4e0..cef9425 100644 --- a/schemars/tests/expected/schema.json +++ b/schemars/tests/expected/schema.json @@ -358,6 +358,7 @@ "definitions": { "InstanceType": { "description": "The possible types of values in JSON Schema documents.\n\nSee [JSON Schema 4.2.1. Instance Data Model](https://tools.ietf.org/html/draft-handrews-json-schema-02#section-4.2.1).", + "type": "string", "enum": [ "null", "boolean", diff --git a/schemars/tests/expected/skip_enum_variants.json b/schemars/tests/expected/skip_enum_variants.json index 6ce7aca..c347df0 100644 --- a/schemars/tests/expected/skip_enum_variants.json +++ b/schemars/tests/expected/skip_enum_variants.json @@ -3,6 +3,7 @@ "title": "MyEnum", "anyOf": [ { + "type": "string", "enum": [ "Included2" ] diff --git a/schemars_derive/src/schema_exprs.rs b/schemars_derive/src/schema_exprs.rs index 0ce909f..ba557fb 100644 --- a/schemars_derive/src/schema_exprs.rs +++ b/schemars_derive/src/schema_exprs.rs @@ -89,6 +89,7 @@ fn expr_for_external_tagged_enum<'a>( let unit_names = unit_variants.iter().map(|v| v.name()); let unit_schema = schema_object(quote! { + instance_type: Some(schemars::schema::InstanceType::String.into()), enum_values: Some(vec![#(#unit_names.into()),*]), });