use super::schemas::IrType;
use super::types::NormalizedName;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HttpMethod {
Get,
Post,
Put,
Delete,
Patch,
Options,
Head,
Trace,
}
impl HttpMethod {
pub fn as_str(&self) -> &'static str {
match self {
HttpMethod::Get => "GET",
HttpMethod::Post => "POST",
HttpMethod::Put => "PUT",
HttpMethod::Delete => "DELETE",
HttpMethod::Patch => "PATCH",
HttpMethod::Options => "OPTIONS",
HttpMethod::Head => "HEAD",
HttpMethod::Trace => "TRACE",
}
}
}
#[derive(Debug, Clone)]
pub struct IrOperation {
pub name: NormalizedName,
pub method: HttpMethod,
pub path: String,
pub summary: Option<String>,
pub description: Option<String>,
pub tags: Vec<String>,
pub parameters: Vec<IrParameter>,
pub request_body: Option<IrRequestBody>,
pub return_type: IrReturnType,
pub deprecated: bool,
}
#[derive(Debug, Clone)]
pub enum IrReturnType {
Standard(IrResponse),
Sse(IrSseReturn),
Void,
}
#[derive(Debug, Clone)]
pub struct IrSseReturn {
pub event_type: IrType,
pub variants: Vec<IrType>,
pub event_type_name: Option<String>,
pub also_has_json: bool,
pub json_response: Option<IrResponse>,
}
#[derive(Debug, Clone)]
pub struct IrResponse {
pub response_type: IrType,
pub description: Option<String>,
}
#[derive(Debug, Clone)]
pub struct IrParameter {
pub name: NormalizedName,
pub original_name: String,
pub location: IrParameterLocation,
pub param_type: IrType,
pub required: bool,
pub description: Option<String>,
pub style: Option<String>,
pub explode: Option<bool>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum IrParameterLocation {
Path,
Query,
Header,
Cookie,
}
#[derive(Debug, Clone)]
pub struct IrFieldEncoding {
pub field_name: String,
pub content_type: Option<String>,
}
#[derive(Debug, Clone)]
pub struct IrRequestBody {
pub body_type: IrType,
pub required: bool,
pub content_type: String,
pub description: Option<String>,
pub encoding: Option<Vec<IrFieldEncoding>>,
}