use indexmap::IndexMap;
use serde_json::Value;
#[derive(Debug, Clone, PartialEq)]
pub enum ParamModel {
String {
description: Option<String>,
required: bool,
default: Option<Value>,
enum_values: Option<Vec<String>>,
},
Number {
description: Option<String>,
required: bool,
default: Option<Value>,
},
Boolean {
description: Option<String>,
required: bool,
default: Option<Value>,
},
Integer {
description: Option<String>,
required: bool,
default: Option<Value>,
},
Object {
description: Option<String>,
required: bool,
properties: IndexMap<String, ParamModel>,
},
Array {
description: Option<String>,
required: bool,
items: Box<ParamModel>,
},
Unsupported {
type_name: String,
},
}
impl ParamModel {
pub fn is_required(&self) -> bool {
match self {
Self::String { required, .. }
| Self::Number { required, .. }
| Self::Boolean { required, .. }
| Self::Integer { required, .. }
| Self::Object { required, .. }
| Self::Array { required, .. } => *required,
Self::Unsupported { .. } => false,
}
}
}