Remove id field
This commit is contained in:
parent
714d56e1ed
commit
492ad8be31
@ -1681,7 +1681,9 @@ mod tests {
|
||||
use bevy_math::Vec3;
|
||||
use bevy_reflect::Reflect;
|
||||
|
||||
use crate::schemas::{ReflectJsonSchemaForceAsArray, SchemaTypesMetadata};
|
||||
use crate::schemas::{
|
||||
reflect_info::TypeReferenceId, ReflectJsonSchemaForceAsArray, SchemaTypesMetadata,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
@ -1760,7 +1762,7 @@ mod tests {
|
||||
assert_eq!(response.definitions.len(), 1);
|
||||
{
|
||||
let first = response.definitions.iter().next().expect("Should have one");
|
||||
assert_eq!(first.1.id, "urn:glam-Vec3");
|
||||
assert_eq!(first.0, &TypeReferenceId::from("glam-Vec3"));
|
||||
}
|
||||
let response = export_registry_types_ext(
|
||||
BrpJsonSchemaQueryFilter {
|
||||
|
@ -126,11 +126,6 @@ impl From<SchemaMarker> for Cow<'static, str> {
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Reflect)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct JsonSchemaBevyType {
|
||||
/// JSON Schema specific field.
|
||||
/// This keyword declares an identifier for the schema resource.
|
||||
#[serde(skip_serializing_if = "str::is_empty", default)]
|
||||
#[serde(rename = "$id")]
|
||||
pub id: Cow<'static, str>,
|
||||
/// Identifies the JSON Schema version used in the schema.
|
||||
#[serde(rename = "$schema")]
|
||||
#[serde(skip_serializing_if = "Option::is_none", default)]
|
||||
@ -722,7 +717,6 @@ mod tests {
|
||||
let schema = export_type::<Foo>();
|
||||
let schema_as_value = serde_json::to_value(&schema).expect("Failed to serialize schema");
|
||||
let mut value = json!({
|
||||
"$id": "urn:bevy_remote-schemas-json_schema-tests-Foo",
|
||||
"shortPath": "Foo",
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"typePath": "bevy_remote::schemas::json_schema::tests::Foo",
|
||||
|
@ -223,19 +223,13 @@ impl TypeInformation {
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds a `TypeReferencePath` from the type identifier.
|
||||
pub fn try_get_path_id(&self) -> Option<TypeReferencePath> {
|
||||
self.try_get_type_reference_id()
|
||||
.map(|id| TypeReferencePath::new_ref(ReferenceLocation::Urn, id))
|
||||
}
|
||||
|
||||
/// Builds a `TypeReferenceId` from the type path.
|
||||
pub fn try_get_type_reference_id(&self) -> Option<TypeReferenceId> {
|
||||
if let Some(schema) = self.try_get_custom_schema() {
|
||||
if schema.0.id.is_empty() {
|
||||
if schema.0.type_path.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(schema.0.id.trim().into())
|
||||
Some(TypeReferenceId::from(&*schema.0.type_path))
|
||||
}
|
||||
} else if self.is_primitive_type() {
|
||||
None
|
||||
@ -1119,7 +1113,12 @@ impl SchemaTypeInfo {
|
||||
pub fn to_ref_schema(&self) -> JsonSchemaBevyType {
|
||||
let range = self.get_range();
|
||||
let description = self.get_docs();
|
||||
let (ref_type, schema_type) = (self.ty_info.try_get_path_id(), self.into());
|
||||
let (ref_type, schema_type) = (
|
||||
self.ty_info
|
||||
.try_get_type_reference_id()
|
||||
.map(TypeReferencePath::definition),
|
||||
self.into(),
|
||||
);
|
||||
|
||||
let mut schema = JsonSchemaBevyType {
|
||||
description,
|
||||
@ -1212,13 +1211,8 @@ impl SchemaTypeInfo {
|
||||
} else {
|
||||
(Cow::default(), Cow::default(), None, None)
|
||||
};
|
||||
let schema_id = self
|
||||
.ty_info
|
||||
.try_get_path_id()
|
||||
.map(|id| Cow::Owned(id.to_string()))
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut schema = JsonSchemaBevyType {
|
||||
id: schema_id,
|
||||
description: self.ty_info.get_docs(),
|
||||
type_path,
|
||||
short_path,
|
||||
@ -1418,16 +1412,6 @@ impl SchemaTypeInfo {
|
||||
(Cow::default(), Cow::default(), None, None)
|
||||
};
|
||||
schema = JsonSchemaBevyType {
|
||||
id: self
|
||||
.ty_info
|
||||
.try_get_type_reference_id()
|
||||
.map(|id| {
|
||||
Cow::Owned(
|
||||
TypeReferencePath::new_ref(ReferenceLocation::Urn, id)
|
||||
.to_string(),
|
||||
)
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
short_path,
|
||||
type_path,
|
||||
module_path,
|
||||
|
Loading…
Reference in New Issue
Block a user