#![cfg(feature = "schemars")]
use schemars::Schema;
use serde_json::json;
pub fn integer_schema(_gen: &mut schemars::SchemaGenerator) -> Schema {
let map = json!({
"type": "integer",
"minimum": 0
})
.as_object()
.expect("json! object literal is always a Value::Object")
.clone();
Schema::from(map)
}
pub fn option_integer_schema(_gen: &mut schemars::SchemaGenerator) -> Schema {
let map = json!({
"type": ["integer", "null"],
"minimum": 0
})
.as_object()
.expect("json! object literal is always a Value::Object")
.clone();
Schema::from(map)
}
pub fn option_ast_limit_schema(_gen: &mut schemars::SchemaGenerator) -> Schema {
let map = json!({
"type": ["integer", "null"],
"minimum": 0
})
.as_object()
.expect("json! object literal is always a Value::Object")
.clone();
Schema::from(map)
}
pub const SUPPORTED_FILE_EXT_PATTERN: &str = r"(?i)\.(rs|py|go|ts|tsx|js|mjs|cjs|java|kt|kts|cs|cpp|cc|cxx|c|h|hpp|hxx|f|f77|f90|f95|f03|f08|for|ftn)$";
pub fn supported_file_path_schema(_gen: &mut schemars::SchemaGenerator) -> Schema {
let map = serde_json::json!({
"type": "string",
"pattern": SUPPORTED_FILE_EXT_PATTERN
})
.as_object()
.expect("json! object literal is always a Value::Object")
.clone();
Schema::from(map)
}
pub fn option_page_size_schema(_gen: &mut schemars::SchemaGenerator) -> Schema {
let map = json!({
"type": ["integer", "null"],
"minimum": 1
})
.as_object()
.expect("json! object literal is always a Value::Object")
.clone();
Schema::from(map)
}