| 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 | } |