diff --git a/editoast/openapi.yaml b/editoast/openapi.yaml index 85dadce1ad7..d51a4cf0762 100644 --- a/editoast/openapi.yaml +++ b/editoast/openapi.yaml @@ -4072,7 +4072,7 @@ components: properties: electrifications: allOf: - - description: Property string values along a path. Each value is associated to a range of the path. + - description: Electrification property along a path. Each value is associated to a range of the path. properties: boundaries: description: |- @@ -4086,7 +4086,39 @@ components: values: description: List of `n+1` values associated to the ranges items: - type: string + oneOf: + - description: Elecrtified section with a given voltage + properties: + type: + enum: + - electrification + type: string + voltage: + type: string + required: + - voltage + - type + type: object + - description: Neutral section with a lower pantograph instruction or just a dead section + properties: + lower_pantograph: + type: boolean + type: + enum: + - neutral_section + type: string + required: + - lower_pantograph + - type + type: object + - properties: + type: + enum: + - non_electrified + type: string + required: + - type + type: object type: array required: - boundaries @@ -4173,7 +4205,7 @@ components: type: object PathPropertiesInput: properties: - rolling_stock_supported_electrification: + rolling_stock_supported_electrifications: description: |- List of supported electrification modes. Empty if does not support any electrification diff --git a/editoast/src/views/v2/path/properties.rs b/editoast/src/views/v2/path/properties.rs index e89ad6a2897..01f3276ec08 100644 --- a/editoast/src/views/v2/path/properties.rs +++ b/editoast/src/views/v2/path/properties.rs @@ -58,7 +58,7 @@ struct PathProperties { gradients: Option, /// Electrification modes and neutral section along the path #[schema(inline)] - electrifications: Option, + electrifications: Option, /// Geometry of the path geometry: Option, /// Operational points along the path @@ -129,18 +129,26 @@ struct PropertyValuesF64 { values: Vec, } -/// Property string values along a path. Each value is associated to a range of the path. -#[derive(Debug, Clone, Serialize, Deserialize, ToSchema, Derivative)] -#[derivative(Default)] -struct PropertyValuesString { +/// Electrification property along a path. Each value is associated to a range of the path. +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +struct PropertyElectrificationValues { /// List of `n` boundaries of the ranges. /// A boundary is a distance from the beginning of the path in mm. - #[derivative(Default(value = "vec![1000]"))] boundaries: Vec, #[schema(inline)] /// List of `n+1` values associated to the ranges - #[derivative(Default(value = r#"vec!["1500V".into(), "25000V".into()]"#))] - values: Vec, + values: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] +#[serde(tag = "type", rename_all = "snake_case")] +enum PropertyElectrificationValue { + /// Elecrtified section with a given voltage + Electrification { voltage: String }, + /// Neutral section with a lower pantograph instruction or just a dead section + NeutralSection { lower_pantograph: bool }, + /// Non electrified section + NonElectrified, } /// Operational point along a path. @@ -164,7 +172,7 @@ struct PathPropertiesInput { /// List of supported electrification modes. /// Empty if does not support any electrification #[serde(default)] - rolling_stock_supported_electrification: Vec, + rolling_stock_supported_electrifications: Vec, } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] @@ -243,7 +251,15 @@ pub async fn post( let computed_path_properties = PathProperties { slopes: Some(Default::default()), gradients: Some(Default::default()), - electrifications: Some(Default::default()), + electrifications: Some(PropertyElectrificationValues { + boundaries: vec![1000], + values: vec![ + PropertyElectrificationValue::Electrification { + voltage: "25kV".to_string(), + }, + PropertyElectrificationValue::NonElectrified, + ], + }), geometry: Some( serde_json::from_str(r#"{"type":"LineString","coordinates":[[0,0],[1,1]]}"#) .unwrap(), @@ -290,7 +306,7 @@ async fn retrieve_path_properties( .await? .unwrap_or_default(); - let elec_property: Option = redis_conn + let elec_property: Option = redis_conn .json_get_ex(&path_elec_property_hash, CACHE_PATH_EXPIRATION) .await?; diff --git a/front/src/common/api/osrdEditoastApi.ts b/front/src/common/api/osrdEditoastApi.ts index 66c74c7dfca..c05c913f624 100644 --- a/front/src/common/api/osrdEditoastApi.ts +++ b/front/src/common/api/osrdEditoastApi.ts @@ -2899,7 +2899,19 @@ export type PathProperties = { A boundary is a distance from the beginning of the path in mm. */ boundaries: number[]; /** List of `n+1` values associated to the ranges */ - values: string[]; + values: ( + | { + type: 'electrification'; + voltage: string; + } + | { + lower_pantograph: boolean; + type: 'neutral_section'; + } + | { + type: 'non_electrified'; + } + )[]; } | null; geometry?: GeoJsonLineString | null; gradients?: { @@ -2930,7 +2942,7 @@ export type PathProperties = { export type PathPropertiesInput = { /** List of supported electrification modes. Empty if does not support any electrification */ - rolling_stock_supported_electrification?: string[]; + rolling_stock_supported_electrifications?: string[]; /** list of track sections */ track_ranges: TrackRange[]; }; diff --git a/openapi.yaml b/openapi.yaml new file mode 100644 index 00000000000..e69de29bb2d