diff --git a/editoast/editoast_schemas/src/infra.rs b/editoast/editoast_schemas/src/infra.rs index 2d4993ae1ca..90f3cd68aa0 100644 --- a/editoast/editoast_schemas/src/infra.rs +++ b/editoast/editoast_schemas/src/infra.rs @@ -82,9 +82,27 @@ pub use track_section_source_extension::TrackSectionSourceExtension; pub use waypoint::Waypoint; editoast_common::schemas! { - track_offset::schemas(), - direction::schemas(), - track_location::schemas(), + applicable_directions::schemas(), + applicable_directions_track_range::schemas(), + buffer_stop::schemas(), + detector::schemas(), directional_track_range::schemas(), + direction::schemas(), electrical_profiles::schemas(), + electrification::schemas(), + endpoint::schemas(), + loading_gauge_limit::schemas(), + neutral_section::schemas(), + operational_point::schemas(), + route::schemas(), + side::schemas(), + signal::schemas(), + sign::schemas(), + speed_section::schemas(), + switch::schemas(), + switch_type::schemas(), + track_endpoint::schemas(), + track_location::schemas(), + track_offset::schemas(), + track_section::schemas(), } diff --git a/editoast/editoast_schemas/src/infra/applicable_directions.rs b/editoast/editoast_schemas/src/infra/applicable_directions.rs index c0d50107835..83e132a45df 100644 --- a/editoast/editoast_schemas/src/infra/applicable_directions.rs +++ b/editoast/editoast_schemas/src/infra/applicable_directions.rs @@ -1,8 +1,13 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; -#[derive(Debug, Derivative, Copy, Clone, Deserialize, Serialize, PartialEq, Eq)] +editoast_common::schemas! { + ApplicableDirections, +} + +#[derive(Debug, Derivative, Copy, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[derivative(Default)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum ApplicableDirections { diff --git a/editoast/editoast_schemas/src/infra/applicable_directions_track_range.rs b/editoast/editoast_schemas/src/infra/applicable_directions_track_range.rs index a203c02c672..b30c16e9f8d 100644 --- a/editoast/editoast_schemas/src/infra/applicable_directions_track_range.rs +++ b/editoast/editoast_schemas/src/infra/applicable_directions_track_range.rs @@ -1,15 +1,21 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::ApplicableDirections; use crate::primitives::Identifier; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + ApplicableDirectionsTrackRange, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct ApplicableDirectionsTrackRange { #[derivative(Default(value = r#""InvalidRef".into()"#))] + #[schema(inline)] pub track: Identifier, pub begin: f64, #[derivative(Default(value = "100."))] diff --git a/editoast/editoast_schemas/src/infra/buffer_stop.rs b/editoast/editoast_schemas/src/infra/buffer_stop.rs index f48432dd054..17db1491450 100644 --- a/editoast/editoast_schemas/src/infra/buffer_stop.rs +++ b/editoast/editoast_schemas/src/infra/buffer_stop.rs @@ -1,21 +1,29 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use crate::primitives::Identifier; use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + BufferStop, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct BufferStop { + #[schema(inline)] pub id: Identifier, #[derivative(Default(value = r#""InvalidRef".into()"#))] + #[schema(inline)] pub track: Identifier, pub position: f64, #[serde(default)] + #[schema(inline)] pub extensions: BufferStopExtension, } @@ -31,13 +39,14 @@ impl OSRDIdentified for BufferStop { } } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] pub struct BufferStopExtension { + #[schema(inline)] pub sncf: Option, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] pub struct BufferStopSncfExtension { pub kp: String, diff --git a/editoast/editoast_schemas/src/infra/detector.rs b/editoast/editoast_schemas/src/infra/detector.rs index b3ed4476251..07c5cd5adf6 100644 --- a/editoast/editoast_schemas/src/infra/detector.rs +++ b/editoast/editoast_schemas/src/infra/detector.rs @@ -1,21 +1,29 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use crate::primitives::Identifier; use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + Detector, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct Detector { + #[schema(inline)] pub id: Identifier, #[derivative(Default(value = r#""InvalidRef".into()"#))] + #[schema(inline)] pub track: Identifier, pub position: f64, #[serde(default)] + #[schema(inline)] pub extensions: DetectorExtension, } @@ -31,13 +39,14 @@ impl OSRDIdentified for Detector { } } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] pub struct DetectorExtension { + #[schema(inline)] pub sncf: DetectorSncfExtension, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] pub struct DetectorSncfExtension { pub kp: String, diff --git a/editoast/editoast_schemas/src/infra/electrification.rs b/editoast/editoast_schemas/src/infra/electrification.rs index cde61cfbd64..5813cfde788 100644 --- a/editoast/editoast_schemas/src/infra/electrification.rs +++ b/editoast/editoast_schemas/src/infra/electrification.rs @@ -2,6 +2,7 @@ use crate::primitives::NonBlankString; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::ApplicableDirectionsTrackRange; use crate::primitives::Identifier; @@ -9,11 +10,17 @@ use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + Electrification, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct Electrification { + #[schema(inline)] pub id: Identifier, + #[schema(inline)] pub voltage: NonBlankString, pub track_ranges: Vec, } diff --git a/editoast/editoast_schemas/src/infra/endpoint.rs b/editoast/editoast_schemas/src/infra/endpoint.rs index 2a6623e23f1..486711d04c5 100644 --- a/editoast/editoast_schemas/src/infra/endpoint.rs +++ b/editoast/editoast_schemas/src/infra/endpoint.rs @@ -1,7 +1,12 @@ use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; -#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Hash)] +editoast_common::schemas! { + Endpoint, +} + +#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Hash, ToSchema)] #[serde(rename_all = "UPPERCASE")] pub enum Endpoint { Begin, diff --git a/editoast/editoast_schemas/src/infra/loading_gauge_limit.rs b/editoast/editoast_schemas/src/infra/loading_gauge_limit.rs index e9ffaf7d0c5..bf1f6e15304 100644 --- a/editoast/editoast_schemas/src/infra/loading_gauge_limit.rs +++ b/editoast/editoast_schemas/src/infra/loading_gauge_limit.rs @@ -1,9 +1,14 @@ use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use crate::rolling_stock::LoadingGaugeType; -#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + LoadingGaugeLimit, +} + +#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] pub struct LoadingGaugeLimit { pub category: LoadingGaugeType, diff --git a/editoast/editoast_schemas/src/infra/neutral_section.rs b/editoast/editoast_schemas/src/infra/neutral_section.rs index 13ee8dac92c..4c010d99e6a 100644 --- a/editoast/editoast_schemas/src/infra/neutral_section.rs +++ b/editoast/editoast_schemas/src/infra/neutral_section.rs @@ -1,6 +1,7 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::DirectionalTrackRange; use super::Sign; @@ -9,30 +10,37 @@ use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; +editoast_common::schemas! { + NeutralSection, +} + /// Neutral sections are portions of track where trains aren't allowed to pull power from electrifications. They have to rely on inertia to cross such sections. /// /// In practice, neutral sections are delimited by signs. In OSRD, neutral sections are directional to allow accounting for different sign placement depending on the direction. /// /// For more details see [the documentation](https://osrd.fr/en/docs/explanation/neutral_sections/). -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct NeutralSection { + #[schema(inline)] pub id: Identifier, pub announcement_track_ranges: Vec, pub track_ranges: Vec, pub lower_pantograph: bool, // Whether the trains need to lower their pantograph to cross this section #[serde(default)] + #[schema(inline)] pub extensions: NeutralSectionExtensions, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] pub struct NeutralSectionExtensions { + #[schema(inline)] pub neutral_sncf: Option, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] pub struct NeutralSectionNeutralSncfExtension { announcement: Vec, diff --git a/editoast/editoast_schemas/src/infra/operational_point.rs b/editoast/editoast_schemas/src/infra/operational_point.rs index 5b22b625d26..2a66598a9ea 100644 --- a/editoast/editoast_schemas/src/infra/operational_point.rs +++ b/editoast/editoast_schemas/src/infra/operational_point.rs @@ -10,6 +10,11 @@ use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; +editoast_common::schemas! { + OperationalPoint, + OperationalPointPart, +} + #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] @@ -18,6 +23,7 @@ pub struct OperationalPoint { pub id: Identifier, pub parts: Vec, #[serde(default)] + #[schema(inline)] pub extensions: OperationalPointExtensions, } diff --git a/editoast/editoast_schemas/src/infra/route.rs b/editoast/editoast_schemas/src/infra/route.rs index 08c7326f177..1265c09629e 100644 --- a/editoast/editoast_schemas/src/infra/route.rs +++ b/editoast/editoast_schemas/src/infra/route.rs @@ -4,6 +4,7 @@ use crate::primitives::Identifier; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::Direction; use super::DirectionalTrackRange; @@ -12,16 +13,23 @@ use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)] +editoast_common::schemas! { + Route, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct Route { + #[schema(inline)] pub id: Identifier, pub entry_point: Waypoint, #[derivative(Default(value = "Direction::StartToStop"))] pub entry_point_direction: Direction, pub exit_point: Waypoint, + #[schema(inline)] pub release_detectors: Vec, + #[schema(inline)] pub switches_directions: HashMap, } diff --git a/editoast/editoast_schemas/src/infra/side.rs b/editoast/editoast_schemas/src/infra/side.rs index 9e2b26dcd7d..1272bc7b72f 100644 --- a/editoast/editoast_schemas/src/infra/side.rs +++ b/editoast/editoast_schemas/src/infra/side.rs @@ -1,8 +1,13 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)] +editoast_common::schemas! { + Side, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[derivative(Default)] #[serde(rename_all = "UPPERCASE")] pub enum Side { diff --git a/editoast/editoast_schemas/src/infra/sign.rs b/editoast/editoast_schemas/src/infra/sign.rs index e431497667c..25ee144b5cb 100644 --- a/editoast/editoast_schemas/src/infra/sign.rs +++ b/editoast/editoast_schemas/src/infra/sign.rs @@ -3,21 +3,28 @@ use crate::primitives::NonBlankString; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::Direction; use super::Side; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + Sign, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[derivative(Default)] #[serde(deny_unknown_fields)] pub struct Sign { #[derivative(Default(value = r#""InvalidRef".into()"#))] + #[schema(inline)] pub track: Identifier, pub position: f64, pub side: Side, #[derivative(Default(value = r#"Direction::StartToStop"#))] pub direction: Direction, #[serde(rename = "type")] + #[schema(inline)] pub sign_type: NonBlankString, pub value: String, pub kp: String, diff --git a/editoast/editoast_schemas/src/infra/signal.rs b/editoast/editoast_schemas/src/infra/signal.rs index 01c81593c09..5a8e7a2ef09 100644 --- a/editoast/editoast_schemas/src/infra/signal.rs +++ b/editoast/editoast_schemas/src/infra/signal.rs @@ -1,23 +1,30 @@ use std::collections::HashMap; -use crate::primitives::Identifier; -use crate::primitives::NonBlankString; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::Direction; use super::Side; +use crate::primitives::Identifier; +use crate::primitives::NonBlankString; use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + Signal, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct Signal { + #[schema(inline)] pub id: Identifier, #[derivative(Default(value = r#""InvalidRef".into()"#))] + #[schema(inline)] pub track: Identifier, pub position: f64, #[derivative(Default(value = "Direction::StartToStop"))] @@ -25,33 +32,41 @@ pub struct Signal { #[derivative(Default(value = "400."))] pub sight_distance: f64, #[serde(default)] + #[schema(inline)] pub logical_signals: Vec, #[serde(default)] + #[schema(inline)] pub extensions: SignalExtensions, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] pub struct LogicalSignal { pub signaling_system: String, pub next_signaling_systems: Vec, + #[schema(inline)] pub settings: HashMap, + #[schema(inline)] pub default_parameters: HashMap, + #[schema(inline)] pub conditional_parameters: Vec, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] pub struct ConditionalParameters { + #[schema(inline)] pub on_route: NonBlankString, + #[schema(inline)] pub parameters: HashMap, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] pub struct SignalExtensions { + #[schema(inline)] pub sncf: Option, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] pub struct SignalSncfExtension { pub label: String, diff --git a/editoast/editoast_schemas/src/infra/speed_section.rs b/editoast/editoast_schemas/src/infra/speed_section.rs index eb680cfc726..a6a00f259c8 100644 --- a/editoast/editoast_schemas/src/infra/speed_section.rs +++ b/editoast/editoast_schemas/src/infra/speed_section.rs @@ -1,32 +1,42 @@ use std::collections::HashMap; -use crate::primitives::Identifier; -use crate::primitives::NonBlankString; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::ApplicableDirectionsTrackRange; use super::Sign; +use crate::primitives::Identifier; +use crate::primitives::NonBlankString; use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Serialize, PartialEq, Copy)] +editoast_common::schemas! { + SpeedSection, +} + +#[derive(Debug, Derivative, Clone, Serialize, PartialEq, Copy, ToSchema)] pub struct Speed(pub f64); -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[derivative(Default)] #[serde(deny_unknown_fields)] pub struct SpeedSection { + #[schema(inline)] pub id: Identifier, #[derivative(Default(value = "Some(Speed(80.))"))] + #[schema(inline)] pub speed_limit: Option, + #[schema(inline)] pub speed_limit_by_tag: HashMap, pub track_ranges: Vec, #[serde(skip_serializing_if = "Option::is_none")] + #[schema(inline)] pub on_routes: Option>, #[serde(default)] + #[schema(inline)] pub extensions: SpeedSectionExtensions, } @@ -47,13 +57,14 @@ impl<'de> Deserialize<'de> for Speed { } } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] pub struct SpeedSectionExtensions { + #[schema(inline)] pub psl_sncf: Option, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] pub struct SpeedSectionPslSncfExtension { announcement: Vec, diff --git a/editoast/editoast_schemas/src/infra/switch.rs b/editoast/editoast_schemas/src/infra/switch.rs index 267274080fa..09895980434 100644 --- a/editoast/editoast_schemas/src/infra/switch.rs +++ b/editoast/editoast_schemas/src/infra/switch.rs @@ -1,37 +1,47 @@ use std::collections::HashMap; -use crate::primitives::Identifier; -use crate::primitives::NonBlankString; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::TrackEndpoint; +use crate::primitives::Identifier; +use crate::primitives::NonBlankString; use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + Switch, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct Switch { + #[schema(inline)] pub id: Identifier, + #[schema(inline)] pub switch_type: Identifier, pub group_change_delay: f64, pub ports: HashMap, #[serde(default)] + #[schema(inline)] pub extensions: SwitchExtensions, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] pub struct SwitchExtensions { + #[schema(inline)] sncf: Option, } -#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] pub struct SwitchSncfExtension { + #[schema(inline)] pub label: NonBlankString, } diff --git a/editoast/editoast_schemas/src/infra/switch_type.rs b/editoast/editoast_schemas/src/infra/switch_type.rs index 92a8c26cf7a..dc90a4445bd 100644 --- a/editoast/editoast_schemas/src/infra/switch_type.rs +++ b/editoast/editoast_schemas/src/infra/switch_type.rs @@ -1,10 +1,11 @@ use std::collections::HashMap; -use crate::primitives::Identifier; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; +use crate::primitives::Identifier; use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; @@ -15,11 +16,18 @@ type NodeType = &'static str; type NodePorts = &'static [&'static str]; type NodeGroups = &'static [&'static [StaticMap]]; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)] +editoast_common::schemas! { + SwitchType, + SwitchPortConnection, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct SwitchType { + #[schema(inline)] pub id: Identifier, + #[schema(inline)] pub ports: Vec, pub groups: HashMap>, } @@ -36,11 +44,13 @@ impl OSRDIdentified for SwitchType { } } -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)] +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, Hash, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct SwitchPortConnection { + #[schema(inline)] pub src: Identifier, + #[schema(inline)] pub dst: Identifier, } diff --git a/editoast/editoast_schemas/src/infra/track_endpoint.rs b/editoast/editoast_schemas/src/infra/track_endpoint.rs index a07c11bb4f9..522b6c1006e 100644 --- a/editoast/editoast_schemas/src/infra/track_endpoint.rs +++ b/editoast/editoast_schemas/src/infra/track_endpoint.rs @@ -1,18 +1,24 @@ -use crate::primitives::Identifier; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::Direction; use super::Endpoint; +use crate::primitives::Identifier; + +editoast_common::schemas! { + TrackEndpoint, +} -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, Hash)] +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, Hash, ToSchema)] #[derivative(Default)] #[serde(deny_unknown_fields)] pub struct TrackEndpoint { #[derivative(Default(value = "Endpoint::Begin"))] pub endpoint: Endpoint, #[derivative(Default(value = r#""InvalidRef".into()"#))] + #[schema(inline)] pub track: Identifier, } diff --git a/editoast/editoast_schemas/src/infra/track_location.rs b/editoast/editoast_schemas/src/infra/track_location.rs index c0beacf0c2d..4fe9f7a2a5e 100644 --- a/editoast/editoast_schemas/src/infra/track_location.rs +++ b/editoast/editoast_schemas/src/infra/track_location.rs @@ -1,8 +1,9 @@ -use crate::primitives::Identifier; use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +use crate::primitives::Identifier; + editoast_common::schemas! { TrackLocation, } diff --git a/editoast/editoast_schemas/src/infra/track_offset.rs b/editoast/editoast_schemas/src/infra/track_offset.rs index 236acc0582d..ac1ccc3421c 100644 --- a/editoast/editoast_schemas/src/infra/track_offset.rs +++ b/editoast/editoast_schemas/src/infra/track_offset.rs @@ -1,8 +1,9 @@ -use crate::primitives::Identifier; use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; +use crate::primitives::Identifier; + editoast_common::schemas! { TrackOffset, } diff --git a/editoast/editoast_schemas/src/infra/track_section.rs b/editoast/editoast_schemas/src/infra/track_section.rs index 8020f24cf38..acb7b6129e3 100644 --- a/editoast/editoast_schemas/src/infra/track_section.rs +++ b/editoast/editoast_schemas/src/infra/track_section.rs @@ -1,23 +1,29 @@ -use crate::primitives::Identifier; use derivative::Derivative; use geojson::Geometry; use geojson::Value::LineString; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::Curve; use super::LoadingGaugeLimit; use super::Slope; use super::TrackSectionExtensions; use crate::primitives::BoundingBox; +use crate::primitives::Identifier; use crate::primitives::OSRDIdentified; use crate::primitives::OSRDTyped; use crate::primitives::ObjectType; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] +editoast_common::schemas! { + TrackSection, +} + +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct TrackSection { + #[schema(inline)] pub id: Identifier, #[derivative(Default(value = "100."))] pub length: f64, @@ -30,6 +36,7 @@ pub struct TrackSection { #[derivative(Default(value = "Geometry::new(LineString(vec![]))"))] pub sch: Geometry, #[serde(default)] + #[schema(inline)] pub extensions: TrackSectionExtensions, } diff --git a/editoast/editoast_schemas/src/infra/track_section_extensions.rs b/editoast/editoast_schemas/src/infra/track_section_extensions.rs index d2a54d4742b..f195579cb10 100644 --- a/editoast/editoast_schemas/src/infra/track_section_extensions.rs +++ b/editoast/editoast_schemas/src/infra/track_section_extensions.rs @@ -1,11 +1,15 @@ -use crate::infra::TrackSectionSncfExtension; -use crate::infra::TrackSectionSourceExtension; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; + +use crate::infra::TrackSectionSncfExtension; +use crate::infra::TrackSectionSourceExtension; -#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] pub struct TrackSectionExtensions { + #[schema(inline)] pub sncf: Option, + #[schema(inline)] pub source: Option, } diff --git a/editoast/editoast_schemas/src/infra/track_section_sncf_extension.rs b/editoast/editoast_schemas/src/infra/track_section_sncf_extension.rs index 0005e4011c6..158d068f842 100644 --- a/editoast/editoast_schemas/src/infra/track_section_sncf_extension.rs +++ b/editoast/editoast_schemas/src/infra/track_section_sncf_extension.rs @@ -1,16 +1,20 @@ -use crate::primitives::NonBlankString; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; + +use crate::primitives::NonBlankString; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct TrackSectionSncfExtension { pub line_code: i32, #[derivative(Default(value = r#""line_test".into()"#))] + #[schema(inline)] pub line_name: NonBlankString, pub track_number: i32, #[derivative(Default(value = r#""track_test".into()"#))] + #[schema(inline)] pub track_name: NonBlankString, } diff --git a/editoast/editoast_schemas/src/infra/track_section_source_extension.rs b/editoast/editoast_schemas/src/infra/track_section_source_extension.rs index 00b40e97c89..e77397331f7 100644 --- a/editoast/editoast_schemas/src/infra/track_section_source_extension.rs +++ b/editoast/editoast_schemas/src/infra/track_section_source_extension.rs @@ -1,12 +1,16 @@ -use crate::primitives::NonBlankString; use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; + +use crate::primitives::NonBlankString; -#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)] +#[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq, ToSchema)] #[serde(deny_unknown_fields)] #[derivative(Default)] pub struct TrackSectionSourceExtension { + #[schema(inline)] pub name: NonBlankString, + #[schema(inline)] pub id: NonBlankString, } diff --git a/editoast/editoast_schemas/src/primitives.rs b/editoast/editoast_schemas/src/primitives.rs index 03626695ba1..c0560de09bb 100644 --- a/editoast/editoast_schemas/src/primitives.rs +++ b/editoast/editoast_schemas/src/primitives.rs @@ -18,6 +18,7 @@ editoast_common::schemas! { object_type::schemas(), zone::schemas(), bounding_box::schemas(), + object_ref::schemas(), } /// This trait should be implemented by all struct that represents an OSRD type. diff --git a/editoast/editoast_schemas/src/primitives/object_ref.rs b/editoast/editoast_schemas/src/primitives/object_ref.rs index 1fa869cf4c1..b98dae79882 100644 --- a/editoast/editoast_schemas/src/primitives/object_ref.rs +++ b/editoast/editoast_schemas/src/primitives/object_ref.rs @@ -1,10 +1,15 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; +use utoipa::ToSchema; use super::ObjectType; -#[derive(Deserialize, Derivative, Serialize, Clone, Debug, PartialEq, Eq, Hash)] +editoast_common::schemas! { + ObjectRef, +} + +#[derive(Deserialize, Derivative, Serialize, Clone, Debug, PartialEq, Eq, Hash, ToSchema)] #[derivative(Default)] #[serde(deny_unknown_fields)] pub struct ObjectRef { diff --git a/editoast/openapi.yaml b/editoast/openapi.yaml index 6ad31e87d0d..29b6140a11d 100644 --- a/editoast/openapi.yaml +++ b/editoast/openapi.yaml @@ -65,6 +65,33 @@ components: - percentage - value_type type: object + ApplicableDirections: + enum: + - START_TO_STOP + - STOP_TO_START + - BOTH + type: string + ApplicableDirectionsTrackRange: + additionalProperties: false + properties: + applicable_directions: + $ref: '#/components/schemas/ApplicableDirections' + begin: + format: double + type: number + end: + format: double + type: number + track: + maxLength: 255 + minLength: 1 + type: string + required: + - track + - begin + - end + - applicable_directions + type: object BatchDeletionRequest: properties: ids: @@ -90,6 +117,39 @@ components: maxItems: 2 minItems: 2 type: array + BufferStop: + additionalProperties: false + properties: + extensions: + additionalProperties: false + properties: + sncf: + allOf: + - additionalProperties: false + properties: + kp: + type: string + required: + - kp + type: object + nullable: true + type: object + id: + maxLength: 255 + minLength: 1 + type: string + position: + format: double + type: number + track: + maxLength: 255 + minLength: 1 + type: string + required: + - id + - track + - position + type: object Comfort: enum: - STANDARD @@ -225,6 +285,39 @@ components: description: force the deletion even if it’s used type: boolean type: object + Detector: + additionalProperties: false + properties: + extensions: + additionalProperties: false + properties: + sncf: + additionalProperties: false + properties: + kp: + type: string + required: + - kp + type: object + required: + - sncf + type: object + id: + maxLength: 255 + minLength: 1 + type: string + position: + format: double + type: number + track: + maxLength: 255 + minLength: 1 + type: string + required: + - id + - track + - position + type: object Direction: enum: - START_TO_STOP @@ -2840,6 +2933,25 @@ components: - levels - level_order type: object + Electrification: + additionalProperties: false + properties: + id: + maxLength: 255 + minLength: 1 + type: string + track_ranges: + items: + $ref: '#/components/schemas/ApplicableDirectionsTrackRange' + type: array + voltage: + minLength: 1 + type: string + required: + - id + - voltage + - track_ranges + type: object ElectrificationRange: properties: electrificationUsage: @@ -2913,6 +3025,11 @@ components: - electrification_ranges - warnings type: object + Endpoint: + enum: + - BEGIN + - END + type: string EnergySource: description: energy source of a rolling stock oneOf: @@ -3514,6 +3631,22 @@ components: - type - coordinates type: object + LoadingGaugeLimit: + additionalProperties: false + properties: + begin: + format: double + type: number + category: + $ref: '#/components/schemas/LoadingGaugeType' + end: + format: double + type: number + required: + - category + - begin + - end + type: object LoadingGaugeType: enum: - G1 @@ -3667,6 +3800,64 @@ components: - type - coordinates type: object + NeutralSection: + additionalProperties: false + description: |- + Neutral sections are portions of track where trains aren't allowed to pull power from electrifications. They have to rely on inertia to cross such sections. + + In practice, neutral sections are delimited by signs. In OSRD, neutral sections are directional to allow accounting for different sign placement depending on the direction. + + For more details see [the documentation](https://osrd.fr/en/docs/explanation/neutral_sections/). + properties: + announcement_track_ranges: + items: + $ref: '#/components/schemas/DirectionalTrackRange' + type: array + extensions: + additionalProperties: false + properties: + neutral_sncf: + allOf: + - additionalProperties: false + properties: + announcement: + items: + $ref: '#/components/schemas/Sign' + type: array + end: + items: + $ref: '#/components/schemas/Sign' + type: array + exe: + $ref: '#/components/schemas/Sign' + rev: + items: + $ref: '#/components/schemas/Sign' + type: array + required: + - announcement + - exe + - end + - rev + type: object + nullable: true + type: object + id: + maxLength: 255 + minLength: 1 + type: string + lower_pantograph: + type: boolean + track_ranges: + items: + $ref: '#/components/schemas/DirectionalTrackRange' + type: array + required: + - id + - announcement_track_ranges + - track_ranges + - lower_pantograph + type: object NewDocumentResponse: properties: document_key: @@ -3675,6 +3866,17 @@ components: required: - document_key type: object + ObjectRef: + additionalProperties: false + properties: + obj_id: + type: string + type: + $ref: '#/components/schemas/ObjectType' + required: + - type + - obj_id + type: object ObjectType: enum: - TrackSection @@ -3721,6 +3923,65 @@ components: required: - operation_type type: object + OperationalPoint: + additionalProperties: false + properties: + extensions: + additionalProperties: false + properties: + identifier: + allOf: + - additionalProperties: false + properties: + name: + minLength: 1 + type: string + uic: + format: int64 + type: integer + required: + - name + - uic + type: object + nullable: true + sncf: + allOf: + - additionalProperties: false + properties: + ch: + type: string + ch_long_label: + minLength: 1 + type: string + ch_short_label: + minLength: 1 + type: string + ci: + format: int64 + type: integer + trigram: + type: string + required: + - ci + - ch + - ch_short_label + - ch_long_label + - trigram + type: object + nullable: true + type: object + id: + maxLength: 255 + minLength: 1 + type: string + parts: + items: + $ref: '#/components/schemas/OperationalPointPart' + type: array + required: + - id + - parts + type: object OperationalPointExtensions: additionalProperties: false properties: @@ -5789,6 +6050,39 @@ components: required: - liveries type: object + Route: + additionalProperties: false + properties: + entry_point: + $ref: '#/components/schemas/Waypoint' + entry_point_direction: + $ref: '#/components/schemas/Direction' + exit_point: + $ref: '#/components/schemas/Waypoint' + id: + maxLength: 255 + minLength: 1 + type: string + release_detectors: + items: + maxLength: 255 + minLength: 1 + type: string + type: array + switches_directions: + additionalProperties: + maxLength: 255 + minLength: 1 + type: string + type: object + required: + - id + - entry_point + - entry_point_direction + - exit_point + - release_detectors + - switches_directions + type: object RoutePath: properties: route: @@ -6413,6 +6707,131 @@ components: - line_name - line_code type: object + Side: + enum: + - LEFT + - RIGHT + - CENTER + type: string + Sign: + additionalProperties: false + properties: + direction: + $ref: '#/components/schemas/Direction' + kp: + type: string + position: + format: double + type: number + side: + $ref: '#/components/schemas/Side' + track: + maxLength: 255 + minLength: 1 + type: string + type: + minLength: 1 + type: string + value: + type: string + required: + - track + - position + - side + - direction + - type + - value + - kp + type: object + Signal: + additionalProperties: false + properties: + direction: + $ref: '#/components/schemas/Direction' + extensions: + additionalProperties: false + properties: + sncf: + allOf: + - additionalProperties: false + properties: + kp: + type: string + label: + type: string + side: + $ref: '#/components/schemas/Side' + required: + - label + - side + - kp + type: object + nullable: true + type: object + id: + maxLength: 255 + minLength: 1 + type: string + logical_signals: + items: + properties: + conditional_parameters: + items: + properties: + on_route: + minLength: 1 + type: string + parameters: + additionalProperties: + minLength: 1 + type: string + type: object + required: + - on_route + - parameters + type: object + type: array + default_parameters: + additionalProperties: + minLength: 1 + type: string + type: object + next_signaling_systems: + items: + type: string + type: array + settings: + additionalProperties: + minLength: 1 + type: string + type: object + signaling_system: + type: string + required: + - signaling_system + - next_signaling_systems + - settings + - default_parameters + - conditional_parameters + type: object + type: array + position: + format: double + type: number + sight_distance: + format: double + type: number + track: + maxLength: 255 + minLength: 1 + type: string + required: + - id + - track + - position + - direction + - sight_distance + type: object SignalSighting: properties: offset: @@ -6786,6 +7205,63 @@ components: - speeds - powers type: object + SpeedSection: + additionalProperties: false + properties: + extensions: + additionalProperties: false + properties: + psl_sncf: + allOf: + - additionalProperties: false + properties: + announcement: + items: + $ref: '#/components/schemas/Sign' + type: array + r: + items: + $ref: '#/components/schemas/Sign' + type: array + z: + $ref: '#/components/schemas/Sign' + required: + - announcement + - z + - r + type: object + nullable: true + type: object + id: + maxLength: 255 + minLength: 1 + type: string + on_routes: + items: + maxLength: 255 + minLength: 1 + type: string + nullable: true + type: array + speed_limit: + allOf: + - format: double + type: number + nullable: true + speed_limit_by_tag: + additionalProperties: + format: double + type: number + type: object + track_ranges: + items: + $ref: '#/components/schemas/ApplicableDirectionsTrackRange' + type: array + required: + - id + - speed_limit_by_tag + - track_ranges + type: object StandardAllowance: properties: capacity_speed_limit: @@ -6967,6 +7443,84 @@ components: required: - scenarios_count type: object + Switch: + additionalProperties: false + properties: + extensions: + additionalProperties: false + properties: + sncf: + allOf: + - additionalProperties: false + properties: + label: + minLength: 1 + type: string + required: + - label + type: object + nullable: true + type: object + group_change_delay: + format: double + type: number + id: + maxLength: 255 + minLength: 1 + type: string + ports: + additionalProperties: + $ref: '#/components/schemas/TrackEndpoint' + type: object + switch_type: + maxLength: 255 + minLength: 1 + type: string + required: + - id + - switch_type + - group_change_delay + - ports + type: object + SwitchPortConnection: + additionalProperties: false + properties: + dst: + maxLength: 255 + minLength: 1 + type: string + src: + maxLength: 255 + minLength: 1 + type: string + required: + - src + - dst + type: object + SwitchType: + additionalProperties: false + properties: + groups: + additionalProperties: + items: + $ref: '#/components/schemas/SwitchPortConnection' + type: array + type: object + id: + maxLength: 255 + minLength: 1 + type: string + ports: + items: + maxLength: 255 + minLength: 1 + type: string + type: array + required: + - id + - ports + - groups + type: object Tags: items: type: string @@ -7194,6 +7748,19 @@ components: required: - train_schedule_summaries type: object + TrackEndpoint: + additionalProperties: false + properties: + endpoint: + $ref: '#/components/schemas/Endpoint' + track: + maxLength: 255 + minLength: 1 + type: string + required: + - endpoint + - track + type: object TrackLocation: description: A track location is a track section and an offset properties: @@ -7246,6 +7813,82 @@ components: - end - direction type: object + TrackSection: + additionalProperties: false + properties: + curves: + items: + $ref: '#/components/schemas/Curve' + type: array + extensions: + additionalProperties: false + properties: + sncf: + allOf: + - additionalProperties: false + properties: + line_code: + format: int32 + type: integer + line_name: + minLength: 1 + type: string + track_name: + minLength: 1 + type: string + track_number: + format: int32 + type: integer + required: + - line_code + - line_name + - track_number + - track_name + type: object + nullable: true + source: + allOf: + - additionalProperties: false + properties: + id: + minLength: 1 + type: string + name: + minLength: 1 + type: string + required: + - name + - id + type: object + nullable: true + type: object + geo: + $ref: '#/components/schemas/Geometry' + id: + maxLength: 255 + minLength: 1 + type: string + length: + format: double + type: number + loading_gauge_limits: + items: + $ref: '#/components/schemas/LoadingGaugeLimit' + type: array + sch: + $ref: '#/components/schemas/Geometry' + slopes: + items: + $ref: '#/components/schemas/Slope' + type: array + required: + - id + - length + - slopes + - curves + - geo + - sch + type: object TrainImportReport: properties: error: