many-to-one 7/9: Update JSON schema

This commit is contained in:
Martin Fischer 2023-02-03 03:31:17 +01:00 committed by Charlie Marsh
parent c314e10e54
commit 849b947b3e
3 changed files with 19 additions and 10 deletions

View File

@ -15,6 +15,11 @@ pub(crate) fn get_redirect(code: &str) -> Option<(&'static str, &'static str)> {
static REDIRECTS: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| {
HashMap::from_iter([
("C", "C4"),
("C9", "C90"),
("T", "T10"),
("T1", "T10"),
("T2", "T20"),
// TODO(charlie): Remove by 2023-02-01.
("R", "RET"),
("R5", "RET5"),

View File

@ -1,5 +1,6 @@
use std::str::FromStr;
use itertools::Itertools;
use schemars::_serde_json::Value;
use schemars::schema::{InstanceType, Schema, SchemaObject};
use schemars::JsonSchema;
@ -181,11 +182,19 @@ impl JsonSchema for RuleSelector {
instance_type: Some(InstanceType::String.into()),
enum_values: Some(
std::iter::once("ALL".to_string())
.chain(RuleCodePrefix::iter().map(|p| {
let prefix = p.linter().common_prefix();
let code = p.short_code();
format!("{prefix}{code}")
}))
.chain(
RuleCodePrefix::iter()
.map(|p| {
let prefix = p.linter().common_prefix();
let code = p.short_code();
format!("{prefix}{code}")
})
.chain(Linter::iter().filter_map(|l| {
let prefix = l.common_prefix();
(!prefix.is_empty()).then(|| prefix.to_string())
}))
.sorted(),
)
.map(Value::String)
.collect(),
),

View File

@ -1376,7 +1376,6 @@
"BLE0",
"BLE00",
"BLE001",
"C",
"C4",
"C40",
"C400",
@ -1396,7 +1395,6 @@
"C415",
"C416",
"C417",
"C9",
"C90",
"C901",
"COM",
@ -1939,11 +1937,8 @@
"SLF0",
"SLF00",
"SLF001",
"T",
"T1",
"T10",
"T100",
"T2",
"T20",
"T201",
"T203",