mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 01:08:28 +02:00
Proto selection UI/models
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
use prost_reflect::SerializeOptions;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tonic::transport::Uri;
|
||||
|
||||
use crate::proto::fill_pool;
|
||||
|
||||
mod codec;
|
||||
mod json_schema;
|
||||
@@ -28,31 +25,3 @@ pub struct MethodDefinition {
|
||||
pub client_streaming: bool,
|
||||
pub server_streaming: bool,
|
||||
}
|
||||
|
||||
pub async fn reflect(uri: &Uri) -> Result<Vec<ServiceDefinition>, String> {
|
||||
let (pool, _) = fill_pool(uri).await?;
|
||||
|
||||
Ok(pool
|
||||
.services()
|
||||
.map(|s| {
|
||||
let mut def = ServiceDefinition {
|
||||
name: s.full_name().to_string(),
|
||||
methods: vec![],
|
||||
};
|
||||
for method in s.methods() {
|
||||
let input_message = method.input();
|
||||
def.methods.push(MethodDefinition {
|
||||
name: method.name().to_string(),
|
||||
server_streaming: method.is_server_streaming(),
|
||||
client_streaming: method.is_client_streaming(),
|
||||
schema: serde_json::to_string_pretty(&json_schema::message_to_json_schema(
|
||||
&pool,
|
||||
input_message,
|
||||
))
|
||||
.unwrap(),
|
||||
})
|
||||
}
|
||||
def
|
||||
})
|
||||
.collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user