Rename reflect_types to reflect_type_data, update field doc
This commit is contained in:
parent
5dac986c84
commit
e9ee9462dd
@ -1254,7 +1254,7 @@ pub fn export_registry_types(In(params): In<Option<Value>>, world: &World) -> Br
|
|||||||
.type_limit
|
.type_limit
|
||||||
.with
|
.with
|
||||||
.iter()
|
.iter()
|
||||||
.any(|c| schema.reflect_types.iter().any(|cc| c.eq(cc)))
|
.any(|c| schema.reflect_type_data.iter().any(|cc| c.eq(cc)))
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -1263,7 +1263,7 @@ pub fn export_registry_types(In(params): In<Option<Value>>, world: &World) -> Br
|
|||||||
.type_limit
|
.type_limit
|
||||||
.without
|
.without
|
||||||
.iter()
|
.iter()
|
||||||
.any(|c| schema.reflect_types.iter().any(|cc| c.eq(cc)))
|
.any(|c| schema.reflect_type_data.iter().any(|cc| c.eq(cc)))
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,7 +88,7 @@ impl TryFrom<(&TypeRegistration, &SchemaTypesMetadata)> for JsonSchemaBevyType {
|
|||||||
let JsonSchemaVariant::Schema(mut typed_schema) = base_schema else {
|
let JsonSchemaVariant::Schema(mut typed_schema) = base_schema else {
|
||||||
return Err(InvalidJsonSchema::InvalidType);
|
return Err(InvalidJsonSchema::InvalidType);
|
||||||
};
|
};
|
||||||
typed_schema.reflect_types = metadata.get_registered_reflect_types(reg);
|
typed_schema.reflect_type_data = metadata.get_registered_reflect_types(reg);
|
||||||
Ok(*typed_schema)
|
Ok(*typed_schema)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,9 +139,9 @@ pub struct JsonSchemaBevyType {
|
|||||||
/// Bevy specific field, name of the crate that type is part of.
|
/// Bevy specific field, name of the crate that type is part of.
|
||||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||||
pub crate_name: Option<Cow<'static, str>>,
|
pub crate_name: Option<Cow<'static, str>>,
|
||||||
/// Bevy specific field, names of the types that type reflects.
|
/// Bevy specific field, names of the types that type reflects. Mapping of the names to the data types is provided by [`SchemaTypesMetadata`].
|
||||||
#[serde(skip_serializing_if = "Vec::is_empty", default)]
|
#[serde(skip_serializing_if = "Vec::is_empty", default)]
|
||||||
pub reflect_types: Vec<Cow<'static, str>>,
|
pub reflect_type_data: Vec<Cow<'static, str>>,
|
||||||
/// Bevy specific field, [`TypeInfo`] type mapping.
|
/// Bevy specific field, [`TypeInfo`] type mapping.
|
||||||
pub kind: SchemaKind,
|
pub kind: SchemaKind,
|
||||||
/// Bevy specific field, provided when [`SchemaKind`] `kind` field is equal to [`SchemaKind::Map`].
|
/// Bevy specific field, provided when [`SchemaKind`] `kind` field is equal to [`SchemaKind::Map`].
|
||||||
@ -453,11 +453,15 @@ mod tests {
|
|||||||
let schema = export_type::<Foo>();
|
let schema = export_type::<Foo>();
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
!schema.reflect_types.contains(&Cow::Borrowed("Component")),
|
!schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Component")),
|
||||||
"Should not be a component"
|
"Should not be a component"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
schema.reflect_types.contains(&Cow::Borrowed("Resource")),
|
schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Resource")),
|
||||||
"Should be a resource"
|
"Should be a resource"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -488,11 +492,15 @@ mod tests {
|
|||||||
}
|
}
|
||||||
let schema = export_type::<EnumComponent>();
|
let schema = export_type::<EnumComponent>();
|
||||||
assert!(
|
assert!(
|
||||||
schema.reflect_types.contains(&Cow::Borrowed("Component")),
|
schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Component")),
|
||||||
"Should be a component"
|
"Should be a component"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!schema.reflect_types.contains(&Cow::Borrowed("Resource")),
|
!schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Resource")),
|
||||||
"Should not be a resource"
|
"Should not be a resource"
|
||||||
);
|
);
|
||||||
assert!(schema.properties.is_empty(), "Should not have any field");
|
assert!(schema.properties.is_empty(), "Should not have any field");
|
||||||
@ -512,11 +520,15 @@ mod tests {
|
|||||||
}
|
}
|
||||||
let schema = export_type::<EnumComponent>();
|
let schema = export_type::<EnumComponent>();
|
||||||
assert!(
|
assert!(
|
||||||
!schema.reflect_types.contains(&Cow::Borrowed("Component")),
|
!schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Component")),
|
||||||
"Should not be a component"
|
"Should not be a component"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!schema.reflect_types.contains(&Cow::Borrowed("Resource")),
|
!schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Resource")),
|
||||||
"Should not be a resource"
|
"Should not be a resource"
|
||||||
);
|
);
|
||||||
assert!(schema.properties.is_empty(), "Should not have any field");
|
assert!(schema.properties.is_empty(), "Should not have any field");
|
||||||
@ -558,19 +570,19 @@ mod tests {
|
|||||||
.export_type_json_schema::<EnumComponent>(&metadata)
|
.export_type_json_schema::<EnumComponent>(&metadata)
|
||||||
.expect("Failed to export schema");
|
.expect("Failed to export schema");
|
||||||
assert!(
|
assert!(
|
||||||
!metadata.has_type_data::<ReflectComponent>(&schema.reflect_types),
|
!metadata.has_type_data::<ReflectComponent>(&schema.reflect_type_data),
|
||||||
"Should not be a component"
|
"Should not be a component"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!metadata.has_type_data::<ReflectResource>(&schema.reflect_types),
|
!metadata.has_type_data::<ReflectResource>(&schema.reflect_type_data),
|
||||||
"Should not be a resource"
|
"Should not be a resource"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
metadata.has_type_data::<ReflectDefault>(&schema.reflect_types),
|
metadata.has_type_data::<ReflectDefault>(&schema.reflect_type_data),
|
||||||
"Should have default"
|
"Should have default"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
metadata.has_type_data::<ReflectCustomData>(&schema.reflect_types),
|
metadata.has_type_data::<ReflectCustomData>(&schema.reflect_type_data),
|
||||||
"Should have CustomData"
|
"Should have CustomData"
|
||||||
);
|
);
|
||||||
assert!(schema.properties.is_empty(), "Should not have any field");
|
assert!(schema.properties.is_empty(), "Should not have any field");
|
||||||
@ -607,7 +619,9 @@ mod tests {
|
|||||||
.export_type_json_schema::<SomeType>(&SchemaTypesMetadata::default())
|
.export_type_json_schema::<SomeType>(&SchemaTypesMetadata::default())
|
||||||
.expect("Failed to export schema");
|
.expect("Failed to export schema");
|
||||||
assert!(
|
assert!(
|
||||||
!schema.reflect_types.contains(&Cow::Borrowed("Component")),
|
!schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Component")),
|
||||||
"Should not be a component"
|
"Should not be a component"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
@ -627,11 +641,15 @@ mod tests {
|
|||||||
|
|
||||||
let schema = export_type::<TupleStructType>();
|
let schema = export_type::<TupleStructType>();
|
||||||
assert!(
|
assert!(
|
||||||
schema.reflect_types.contains(&Cow::Borrowed("Component")),
|
schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Component")),
|
||||||
"Should be a component"
|
"Should be a component"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!schema.reflect_types.contains(&Cow::Borrowed("Resource")),
|
!schema
|
||||||
|
.reflect_type_data
|
||||||
|
.contains(&Cow::Borrowed("Resource")),
|
||||||
"Should not be a resource"
|
"Should not be a resource"
|
||||||
);
|
);
|
||||||
assert!(schema.properties.is_empty(), "Should not have any field");
|
assert!(schema.properties.is_empty(), "Should not have any field");
|
||||||
@ -655,7 +673,7 @@ mod tests {
|
|||||||
"typePath": "bevy_remote::schemas::json_schema::tests::Foo",
|
"typePath": "bevy_remote::schemas::json_schema::tests::Foo",
|
||||||
"modulePath": "bevy_remote::schemas::json_schema::tests",
|
"modulePath": "bevy_remote::schemas::json_schema::tests",
|
||||||
"crateName": "bevy_remote",
|
"crateName": "bevy_remote",
|
||||||
"reflectTypes": [
|
"reflectTypeData": [
|
||||||
"Resource",
|
"Resource",
|
||||||
"Default",
|
"Default",
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user