MCPcopy Create free account
hub / github.com/astral-sh/ruff / json_schema

Method json_schema

crates/ruff_python_ast/src/python_version.rs:216–241  ·  view source on GitHub ↗
(_gen: &mut SchemaGenerator)

Source from the content-addressed store, hash-verified

214 }
215
216 fn json_schema(_gen: &mut SchemaGenerator) -> Schema {
217 let mut any_of: Vec<Value> = vec![
218 schemars::json_schema!({
219 "type": "string",
220 "pattern": r"^\d+\.\d+$",
221 })
222 .into(),
223 ];
224
225 for version in Self::iter() {
226 let mut schema = schemars::json_schema!({
227 "const": version.to_string(),
228 });
229 schema.ensure_object().insert(
230 "description".to_string(),
231 Value::String(format!("Python {version}")),
232 );
233 any_of.push(schema.into());
234 }
235
236 let mut schema = Schema::default();
237 schema
238 .ensure_object()
239 .insert("anyOf".to_string(), Value::Array(any_of));
240 schema
241 }
242 }
243}

Callers

nothing calls this directly

Calls 5

defaultFunction · 0.50
ArrayClass · 0.50
insertMethod · 0.45
to_stringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected