oag_core/ir/
operations.rs1use super::schemas::IrType;
2use super::types::NormalizedName;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6pub enum HttpMethod {
7 Get,
8 Post,
9 Put,
10 Delete,
11 Patch,
12 Options,
13 Head,
14 Trace,
15}
16
17impl HttpMethod {
18 pub fn as_str(&self) -> &'static str {
19 match self {
20 HttpMethod::Get => "GET",
21 HttpMethod::Post => "POST",
22 HttpMethod::Put => "PUT",
23 HttpMethod::Delete => "DELETE",
24 HttpMethod::Patch => "PATCH",
25 HttpMethod::Options => "OPTIONS",
26 HttpMethod::Head => "HEAD",
27 HttpMethod::Trace => "TRACE",
28 }
29 }
30}
31
32#[derive(Debug, Clone)]
34pub struct IrOperation {
35 pub name: NormalizedName,
36 pub method: HttpMethod,
37 pub path: String,
38 pub summary: Option<String>,
39 pub description: Option<String>,
40 pub tags: Vec<String>,
41 pub parameters: Vec<IrParameter>,
42 pub request_body: Option<IrRequestBody>,
43 pub return_type: IrReturnType,
44 pub deprecated: bool,
45}
46
47#[derive(Debug, Clone)]
49pub enum IrReturnType {
50 Standard(IrResponse),
52 Sse(IrSseReturn),
54 Void,
56}
57
58#[derive(Debug, Clone)]
60pub struct IrSseReturn {
61 pub event_type: IrType,
63 pub variants: Vec<IrType>,
65 pub event_type_name: Option<String>,
67 pub also_has_json: bool,
69 pub json_response: Option<IrResponse>,
71}
72
73#[derive(Debug, Clone)]
75pub struct IrResponse {
76 pub response_type: IrType,
77 pub description: Option<String>,
78}
79
80#[derive(Debug, Clone)]
82pub struct IrParameter {
83 pub name: NormalizedName,
84 pub original_name: String,
85 pub location: IrParameterLocation,
86 pub param_type: IrType,
87 pub required: bool,
88 pub description: Option<String>,
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq)]
93pub enum IrParameterLocation {
94 Path,
95 Query,
96 Header,
97 Cookie,
98}
99
100#[derive(Debug, Clone)]
102pub struct IrRequestBody {
103 pub body_type: IrType,
104 pub required: bool,
105 pub content_type: String,
106 pub description: Option<String>,
107}