Constrain civic manifest schema discriminator
This commit is contained in:
parent
2427f24010
commit
6e9e7043d9
2 changed files with 20 additions and 0 deletions
|
|
@ -661,6 +661,7 @@ struct CompiledResidentCivicKnowledge {
|
|||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
|
||||
struct CompiledCivicSystemReconciliation {
|
||||
#[schemars(with = "crate::domain::CivicSystemManifestSchemaV1")]
|
||||
schema: String,
|
||||
jurisdiction_location_id: String,
|
||||
governing_institution_ids: BTreeSet<String>,
|
||||
|
|
@ -6362,6 +6363,17 @@ mod tests {
|
|||
crate::model_connector::project_strict_responses_schema(&mut expansion).unwrap();
|
||||
assert_eq!(expansion["properties"]["origin_routes"]["type"], "array");
|
||||
assert_eq!(expansion["properties"]["locations"]["type"], "array");
|
||||
assert_eq!(
|
||||
expansion["$defs"]["CivicSystemManifestSchemaV1"]["enum"],
|
||||
serde_json::json!(["ghostlight.civic_system_manifest.v1"])
|
||||
);
|
||||
let mut civic_reconciliation =
|
||||
serde_json::to_value(schema_for!(CompiledCivicReconciliation)).unwrap();
|
||||
crate::model_connector::project_strict_responses_schema(&mut civic_reconciliation).unwrap();
|
||||
assert_eq!(
|
||||
civic_reconciliation["$defs"]["CivicSystemManifestSchemaV1"]["enum"],
|
||||
serde_json::json!(["ghostlight.civic_system_manifest.v1"])
|
||||
);
|
||||
|
||||
let mut fission = serde_json::to_value(schema_for!(CompiledFissionSeed)).unwrap();
|
||||
crate::model_connector::project_strict_responses_schema(&mut fission).unwrap();
|
||||
|
|
|
|||
|
|
@ -1213,8 +1213,16 @@ pub struct RegionExpansion {
|
|||
pub civic_system: Option<CivicSystemManifest>,
|
||||
}
|
||||
|
||||
#[derive(JsonSchema)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum CivicSystemManifestSchemaV1 {
|
||||
#[schemars(rename = "ghostlight.civic_system_manifest.v1")]
|
||||
V1,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
pub struct CivicSystemManifest {
|
||||
#[schemars(with = "CivicSystemManifestSchemaV1")]
|
||||
pub schema: String,
|
||||
#[serde(default)]
|
||||
pub version: u64,
|
||||
|
|
|
|||
Loading…
Reference in a new issue