Format code
This commit is contained in:
parent
7530568498
commit
5dac986c84
@ -1,7 +1,7 @@
|
|||||||
//! Built-in verbs for the Bevy Remote Protocol.
|
//! Built-in verbs for the Bevy Remote Protocol.
|
||||||
|
|
||||||
use core::any::TypeId;
|
|
||||||
use alloc::borrow::Cow;
|
use alloc::borrow::Cow;
|
||||||
|
use core::any::TypeId;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result as AnyhowResult};
|
use anyhow::{anyhow, Result as AnyhowResult};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
//! Module with JSON Schema type for Bevy Registry Types.
|
//! Module with JSON Schema type for Bevy Registry Types.
|
||||||
//! It tries to follow this standard: <https://json-schema.org/specification>
|
//! It tries to follow this standard: <https://json-schema.org/specification>
|
||||||
|
use alloc::borrow::Cow;
|
||||||
use bevy_platform::collections::HashMap;
|
use bevy_platform::collections::HashMap;
|
||||||
use bevy_reflect::{
|
use bevy_reflect::{
|
||||||
prelude::ReflectDefault, serde::ReflectSerializer, GetTypeRegistration, Reflect,
|
prelude::ReflectDefault, serde::ReflectSerializer, GetTypeRegistration, Reflect,
|
||||||
@ -8,7 +9,6 @@ use bevy_reflect::{
|
|||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use alloc::borrow::Cow;
|
|
||||||
|
|
||||||
use crate::schemas::{
|
use crate::schemas::{
|
||||||
reflect_info::{SchemaInfoReflect, SchemaNumber},
|
reflect_info::{SchemaInfoReflect, SchemaNumber},
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
//! Module with schemas used for various BRP endpoints
|
//! Module with schemas used for various BRP endpoints
|
||||||
|
use alloc::borrow::Cow;
|
||||||
use bevy_derive::Deref;
|
use bevy_derive::Deref;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
reflect::{ReflectComponent, ReflectResource},
|
reflect::{ReflectComponent, ReflectResource},
|
||||||
@ -10,7 +11,6 @@ use bevy_reflect::{
|
|||||||
TypeRegistration,
|
TypeRegistration,
|
||||||
};
|
};
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
use alloc::borrow::Cow;
|
|
||||||
|
|
||||||
use crate::schemas::json_schema::JsonSchemaBevyType;
|
use crate::schemas::json_schema::JsonSchemaBevyType;
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
//! Module containing information about reflected types.
|
//! Module containing information about reflected types.
|
||||||
use bevy_reflect::{GenericInfo, NamedField, Reflect, TypeInfo, UnnamedField, VariantInfo};
|
use bevy_reflect::{GenericInfo, NamedField, Reflect, TypeInfo, UnnamedField, VariantInfo};
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use core::{
|
use core::{
|
||||||
any::Any,
|
any::Any,
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
ops::{Bound, RangeBounds},
|
ops::{Bound, RangeBounds},
|
||||||
};
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::schemas::json_schema::{
|
use crate::schemas::json_schema::{
|
||||||
JsonSchemaBevyType, JsonSchemaVariant, SchemaKind, SchemaType, SchemaTypeVariant,
|
JsonSchemaBevyType, JsonSchemaVariant, SchemaKind, SchemaType, SchemaTypeVariant,
|
||||||
@ -297,7 +297,10 @@ impl From<&SchemaTypeInfo> for Option<SchemaTypeVariant> {
|
|||||||
SchemaType::Null,
|
SchemaType::Null,
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
InternalSchemaType::Regular => value.type_id.as_ref().map(|s| SchemaTypeVariant::Single((*s).into())),
|
InternalSchemaType::Regular => value
|
||||||
|
.type_id
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| SchemaTypeVariant::Single((*s).into())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,7 +338,8 @@ impl From<SchemaTypeInfo> for JsonSchemaVariant {
|
|||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
short_path: val
|
short_path: val
|
||||||
.type_info
|
.type_info
|
||||||
.as_ref().map(|s| s.type_path_table().short_path().into())
|
.as_ref()
|
||||||
|
.map(|s| s.type_path_table().short_path().into())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
crate_name: val
|
crate_name: val
|
||||||
.type_info
|
.type_info
|
||||||
@ -374,7 +378,10 @@ impl From<SchemaTypeInfo> for JsonSchemaVariant {
|
|||||||
}
|
}
|
||||||
InternalSchemaType::Regular => {}
|
InternalSchemaType::Regular => {}
|
||||||
InternalSchemaType::EnumHolder(variants) => {
|
InternalSchemaType::EnumHolder(variants) => {
|
||||||
schema.one_of = variants.iter().map(SchemaInfoReflect::build_schema).collect();
|
schema.one_of = variants
|
||||||
|
.iter()
|
||||||
|
.map(SchemaInfoReflect::build_schema)
|
||||||
|
.collect();
|
||||||
}
|
}
|
||||||
InternalSchemaType::EnumVariant(variant_info) => match &variant_info {
|
InternalSchemaType::EnumVariant(variant_info) => match &variant_info {
|
||||||
VariantInfo::Struct(struct_variant_info) => {
|
VariantInfo::Struct(struct_variant_info) => {
|
||||||
@ -442,7 +449,10 @@ impl From<SchemaTypeInfo> for JsonSchemaVariant {
|
|||||||
return new_schema;
|
return new_schema;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
schema.prefix_items = unnamed_fields.iter().map(SchemaInfoReflect::build_schema).collect();
|
schema.prefix_items = unnamed_fields
|
||||||
|
.iter()
|
||||||
|
.map(SchemaInfoReflect::build_schema)
|
||||||
|
.collect();
|
||||||
schema.min_items = Some(unnamed_fields.len() as u64);
|
schema.min_items = Some(unnamed_fields.len() as u64);
|
||||||
schema.max_items = Some(unnamed_fields.len() as u64);
|
schema.max_items = Some(unnamed_fields.len() as u64);
|
||||||
}
|
}
|
||||||
@ -522,7 +532,7 @@ pub trait SchemaInfoReflect {
|
|||||||
TypeInfo::Set(_) => SchemaKind::Set,
|
TypeInfo::Set(_) => SchemaKind::Set,
|
||||||
TypeInfo::Enum(_) => SchemaKind::Enum,
|
TypeInfo::Enum(_) => SchemaKind::Enum,
|
||||||
TypeInfo::Opaque(_) => SchemaKind::Opaque,
|
TypeInfo::Opaque(_) => SchemaKind::Opaque,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
SchemaKind::Value
|
SchemaKind::Value
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user