refactor: Use openapi for recipe endpoint types and in frontend (#3548)

This commit is contained in:
Jarrod Sibbison
2025-07-21 19:40:13 +10:00
committed by GitHub
parent a996227381
commit d085126709
10 changed files with 863 additions and 132 deletions
+9 -8
View File
@@ -6,6 +6,7 @@ use std::fmt;
use crate::agents::extension::ExtensionConfig;
use serde::de::Deserializer;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
pub mod build_recipe;
pub mod read_recipe_file_content;
@@ -67,7 +68,7 @@ fn default_version() -> String {
/// sub_recipes: None,
/// };
///
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
pub struct Recipe {
// Required fields
#[serde(default = "default_version")]
@@ -110,7 +111,7 @@ pub struct Recipe {
pub sub_recipes: Option<Vec<SubRecipe>>, // sub-recipes for the recipe
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
pub struct Author {
#[serde(skip_serializing_if = "Option::is_none")]
pub contact: Option<String>, // creator/contact information of the recipe
@@ -119,7 +120,7 @@ pub struct Author {
pub metadata: Option<String>, // any additional metadata for the author
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
pub struct Settings {
#[serde(skip_serializing_if = "Option::is_none")]
pub goose_provider: Option<String>,
@@ -131,13 +132,13 @@ pub struct Settings {
pub temperature: Option<f32>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
pub struct Response {
#[serde(skip_serializing_if = "Option::is_none")]
pub json_schema: Option<serde_json::Value>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
pub struct SubRecipe {
pub name: String,
pub path: String,
@@ -172,7 +173,7 @@ where
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum RecipeParameterRequirement {
Required,
@@ -190,7 +191,7 @@ impl fmt::Display for RecipeParameterRequirement {
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum RecipeParameterInputType {
String,
@@ -210,7 +211,7 @@ impl fmt::Display for RecipeParameterInputType {
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)]
pub struct RecipeParameter {
pub key: String,
pub input_type: RecipeParameterInputType,