Skip to content

Commit 4a15c2d

Browse files
committed
Use references for schemas
1 parent 758632b commit 4a15c2d

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

examples/axum/openrpc.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
"result": {
2121
"name": "SendResult",
2222
"schema": {
23-
"title": "uint",
24-
"type": "integer",
25-
"format": "uint",
26-
"minimum": 0.0
23+
"$ref": "#/components/schemas/uint"
2724
},
2825
"required": true
2926
},

examples/axum/src/webserver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl Session {
128128

129129
/// List chat messages.
130130
#[rpc(positional)]
131-
pub async fn list(&self) -> yerpc::Result<Vec<ChatMessage>> {
131+
pub async fn list(&self) -> yerpc::Result<Vec::<ChatMessage>> {
132132
let list = self.backend.list().await;
133133
Ok(list)
134134
}

yerpc-derive/src/openrpc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn generate_param(input: &Input, i: usize) -> TokenStream {
1818
::yerpc::openrpc::Param {
1919
name: #name.to_string(),
2020
description: None,
21-
schema: ::yerpc::openrpc::generate_schema::<#ty>(),
21+
schema: ::schemars::schema::SchemaObject::new_ref(format!("#/components/schemas/{}", #ty::schema_name())),
2222
required: true
2323
}
2424

@@ -67,7 +67,7 @@ fn generate_method(method: &RemoteProcedure) -> TokenStream {
6767
::yerpc::openrpc::Param {
6868
name: #output_name.to_string(),
6969
description: None,
70-
schema: ::yerpc::openrpc::generate_schema::<#output_ty>(),
70+
schema: ::schemars::schema::SchemaObject::new_ref(format!("#/components/schemas/{}", #output_ty::schema_name())),
7171
required: true
7272
}
7373
};

0 commit comments

Comments
 (0)