unmbt/ciallo/schema does not have a README file

    Schema

    pub(open) trait Schema {
    fn schema_node(_proxy : Self?) -> SchemaNode
    fn schema_ref(_proxy : Self?) -> SchemaNode = _
    fn schema_id(_proxy : Self?) -> String? = _
    fn contains_dynamic_or_sensitive(_proxy : Self?) -> Bool = _
    }

    以内置 Self? 作为零分配类型锚点,规避无关联类型限制与多 Trait 约束分派警告(Warning 0083 / Error 4018)
    impl Schema for Bool
    impl Schema for Int
    impl Schema for Int64
    impl Schema for UInt
    impl Schema for UInt64
    impl Schema for Float
    impl Schema for Double
    impl Schema for String
    impl Schema for FixedArray[T]
    impl Schema for ReadOnlyArray[T]
    impl Schema for Array[T]
    impl Schema for Map[String, V]
    impl Schema for Json

    ValidationError

    pub(all) suberror ValidationError {
    InvalidInput(issues~ : Array[ValidationIssue])
    } derive(Eq,
    Debug
    )

    Base64Bytes

    pub(all) struct Base64Bytes(Bytes) derive(Eq,
    Debug
    )

    基于标准库 moonbitlang/core/encoding/base64 的一等公民 Base64 二进制载荷包装器(替代标准库 \xHH 转义的裸 Bytes,OpenAPI 映射为 format: "byte")

    Base64Bytes::to_json

    CursorPage

    pub(all) struct CursorPage[T] {
    items : Array[T]
    next_cursor : String?
    has_more : Bool
    } derive(Eq,
    Debug
    ,
    FromJson
    ,
    ToJson
    )

    impl Schema for CursorPage[T]

    FieldMask

    pub struct FieldMask {
    // private fields
    } derive(Eq,
    Debug
    )

    稀疏字段掩码(支持逗号分隔与点分嵌套路径,如 "id,name,profile.avatar")

    FieldMask::contains

    fn FieldMask::contains(self : FieldMask, field : StringView) -> Bool

    FieldMask::empty

    fn FieldMask::empty() -> FieldMask

    FieldMask::is_empty

    fn FieldMask::is_empty(self : FieldMask) -> Bool

    FieldMask::parse

    fn FieldMask::parse(raw : StringView) -> FieldMask

    从查询参数解析稀疏字段掩码(例如 "?fields=id,name,profile.avatar")

    FieldMask::sub_mask

    fn FieldMask::sub_mask(self : FieldMask, field : StringView) -> FieldMask?

    NoContent

    pub(all) struct NoContent {
    } derive(Eq,
    Debug
    )

    204 No Content 强类型零开销哨兵(schema_id = "ciallo.NoContent",OpenAPI 生成无 content 的 204,Eden 映射为 void/Unit)
    impl Schema for NoContent

    NoContent::to_json

    Nullable

    pub(all) enum Nullable[T] {
    Null
    Value(T)
    } derive(Eq, Hash,
    Debug
    )

    一等公民标准 JSON 可空包装器(编码为标准 null | T,打通顶层/容器可空值与 PATCH field : Nullable[T]? 三态语义;严禁误用标准库单元素数组 [v] 编码的通用 T?)
    impl Schema for Nullable[T]

    ObjectField

    pub(all) struct ObjectField {
    name : String
    schema : SchemaNode
    required : Bool
    description : String?
    } derive(Eq,
    Debug
    )

    ObjectField::ObjectField

    fn ObjectField::ObjectField(name : String, schema : SchemaNode, required? : Bool, description? : String) -> ObjectField

    Page

    pub(all) struct Page[T] {
    items : Array[T]
    total : Int64
    page : Int
    page_size : Int
    } derive(Eq,
    Debug
    ,
    FromJson
    ,
    ToJson
    )

    统一分页契约(定居于 v0.1 四目标纯核,total : Int64 自动按 Int64String 导出至 OpenAPI 3.1 / ciallo-eden)
    impl Schema for Page[T]

    SchemaMeta

    pub(all) struct SchemaMeta {
    description : String?
    format : String?
    pattern : String?
    default :
    Json
    ?
    deprecated : Bool
    } derive(Eq,
    Debug
    )

    通用 Schema 元数据(支撑 OpenAPI 3.1 文档、TypeScript JSDoc 注释与 MCP Tool 描述)

    SchemaMeta::SchemaMeta

    fn SchemaMeta::SchemaMeta(description? : String, format? : String, pattern? : String, default? :
    Json
    , deprecated? : Bool) -> SchemaMeta

    SchemaNode

    pub(all) enum SchemaNode {
    Any
    Empty
    Null
    Boolean(meta~ : SchemaMeta)
    Integer(min~ : Int64?, max~ : Int64?, meta~ : SchemaMeta)
    Int64String(min~ : Int64?, max~ : Int64?, meta~ : SchemaMeta)
    Number(min~ : Double?, max~ : Double?, meta~ : SchemaMeta)
    String(min_len~ : Int?, max_len~ : Int?, meta~ : SchemaMeta)
    Array(items~ : SchemaNode, min_items~ : Int?, max_items~ : Int?, meta~ : SchemaMeta)
    Record(value~ : SchemaNode, meta~ : SchemaMeta)
    Object(fields~ : Array[ObjectField], additional_properties~ : Bool, schema_id~ : String?, meta~ : SchemaMeta)
    Enum(values~ : Array[String], meta~ : SchemaMeta)
    Union(variants~ : Array[SchemaNode], meta~ : SchemaMeta)
    Nullable(SchemaNode)
    Ref(SchemaRef)
    } derive(Eq,
    Debug
    )

    SchemaNode::array

    fn SchemaNode::array(items : SchemaNode, min_items? : Int, max_items? : Int, meta? : SchemaMeta) -> SchemaNode

    SchemaNode::boolean

    fn SchemaNode::boolean(meta? : SchemaMeta) -> SchemaNode

    SchemaNode::empty

    fn SchemaNode::empty() -> SchemaNode

    SchemaNode::int64_string

    fn SchemaNode::int64_string(min? : Int64, max? : Int64, meta? : SchemaMeta) -> SchemaNode

    SchemaNode::integer

    fn SchemaNode::integer(min? : Int64, max? : Int64, meta? : SchemaMeta) -> SchemaNode

    SchemaNode::nullable

    fn SchemaNode::nullable(inner : SchemaNode) -> SchemaNode

    SchemaNode::number

    fn SchemaNode::number(min? : Double, max? : Double, meta? : SchemaMeta) -> SchemaNode

    SchemaNode::object

    fn SchemaNode::object(fields : Array[ObjectField], additional_properties? : Bool, schema_id? : String, meta? : SchemaMeta) -> SchemaNode

    SchemaNode::record

    fn SchemaNode::record(value : SchemaNode, meta? : SchemaMeta) -> SchemaNode

    SchemaNode::schema_id

    fn SchemaNode::schema_id(self : SchemaNode) -> String?

    SchemaNode::schema_ref

    fn SchemaNode::schema_ref(id~ : String, build~ : () -> SchemaNode) -> SchemaNode

    SchemaNode::str_enum

    fn SchemaNode::str_enum(values : Array[String], meta? : SchemaMeta) -> SchemaNode

    SchemaNode::string

    fn SchemaNode::string(min_len? : Int, max_len? : Int, meta? : SchemaMeta) -> SchemaNode

    SchemaRef

    pub struct SchemaRef {
    id : String
    // private fields
    }

    惰性自引用断环包装器(自定义按 id 判等的 Eq/Debug,既支持 SchemaNode #derive(Debug, Eq),又杜绝递归类型爆栈并自动聚拢至 #/components/schemas/)
    impl Eq for SchemaRef

    SchemaRef::SchemaRef

    fn SchemaRef::SchemaRef(id~ : String, build~ : () -> SchemaNode) -> SchemaRef

    SchemaRef::resolve

    fn SchemaRef::resolve(self : SchemaRef) -> SchemaNode

    ValidationIssue

    pub(all) struct ValidationIssue {
    path : String
    message : String
    expected : String
    } derive(Eq,
    Debug
    ,
    FromJson
    ,
    ToJson
    )

    ValidationIssue::to_json

    automatically derived

    coerce_query_params

    fn coerce_query_params(raw : Map[String, Array[String]], schema : SchemaNode) ->
    Json
    raise ValidationError

    coerce_string_map

    fn coerce_string_map(raw : Map[String, String], schema : SchemaNode) ->
    Json
    raise ValidationError

    normalize_json

    响应脱敏(Exact Mirror Normalization):按 SchemaNode 树递归剔除未在 Object Schema 声明的多余字段(如 passwordHash)

    project_json

    安全稀疏字段投影:严格求 FieldMask ∩ response_schema 交集,绝不透出未在 Schema 声明的敏感字段

    schema_of

    fn[T : Schema] schema_of(_proxy : T?) -> SchemaNode

    供业务与 ciallo-gen 生成代码以 @schema.schema_ref_of((None : FieldType?)) 零反射委托给 moonc 消解类型

    schema_ref_of

    fn[T : Schema] schema_ref_of(_proxy : T?) -> SchemaNode

    validate_json

    fn validate_json(value :
    Json
    , schema : SchemaNode) -> Array[ValidationIssue]