Skip to content

Commit

Permalink
editoast add <stuff>-on-path views to utoipa
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste Prevot authored and Castavo committed Oct 23, 2023
1 parent 73afcfc commit 6e4a035
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 233 deletions.
2 changes: 2 additions & 0 deletions editoast/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions editoast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ members = [".", "editoast_derive", "osrd_containers"]
rangemap = "1.4.0"
serde = "1.0.188"
serde_derive = "1.0.188"
serde_json = "1.0.107"
utoipa = { version = "3.5.0", features = ["actix_extras", "chrono", "uuid"] }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down Expand Up @@ -56,7 +58,7 @@ sentry = "0.31.7"
sentry-actix = "0.31.7"
serde.workspace = true
serde_derive.workspace = true
serde_json = "1.0.107"
serde_json.workspace = true
serde_yaml = "0.9.25"
strum = "0.25.0"
strum_macros = "0.25.2"
Expand All @@ -75,7 +77,7 @@ reqwest = { version = "0.11.22", features = ["json"] }
osm4routing = "0.5.8"
osmpbfreader = "0.16.0"
itertools = "0.11.0"
utoipa = { version = "3.5.0", features = ["actix_extras", "chrono", "uuid"] }
utoipa.workspace = true
paste = "1.0.14"

[dev-dependencies]
Expand Down
119 changes: 53 additions & 66 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ components:
maxItems: 2
minItems: 2
type: array
CatenariesOnPathResponse:
description: |-
A list of ranges associated to catenary modes. When a profile overlapping another is found,
a warning is added to the list
properties:
catenary_ranges:
items:
$ref: '#/components/schemas/RangedValue'
type: array
warnings:
items:
$ref: '#/components/schemas/InternalError'
type: array
required:
- catenary_ranges
- warnings
type: object
Catenary:
description: energy source for a rolling stock representing a catenary
properties:
Expand Down Expand Up @@ -983,6 +1000,23 @@ components:
- stop
- code
- handled
ProfilesOnPathResponse:
description: |-
A list of ranges associated to electrical profile values. When a profile overlapping another is found,
a warning is added to the list
properties:
electrical_profile_ranges:
items:
$ref: '#/components/schemas/RangedValue'
type: array
warnings:
items:
$ref: '#/components/schemas/InternalError'
type: array
required:
- electrical_profile_ranges
- warnings
type: object
ProjectCreateRequest:
properties:
budget:
Expand Down Expand Up @@ -1172,14 +1206,15 @@ components:
- end_position
- value
RangedValue:
description: A struct to represent range maps in responses
properties:
begin:
example: 0.0
format: float
format: double
type: number
end:
example: 100.0
format: float
example: 10.0
format: double
type: number
value:
example: '25000'
Expand Down Expand Up @@ -3841,105 +3876,57 @@ paths:
- pathfinding
/pathfinding/{path_id}/catenaries/:
get:
description: Retrieve the catenary modes along a path, as seen by the rolling stock specified
parameters:
- description: The path's id
in: path
name: path_id
required: true
schema:
format: int64
type: integer
responses:
'200':
content:
application/json:
schema:
properties:
catenary_ranges:
items:
$ref: '#/components/schemas/RangedValue'
type: array
warnings:
items:
properties:
catenary_id:
type: string
overlapping_ranges:
items:
$ref: '#/components/schemas/TrackRange'
type: array
type:
enum:
- CatenaryOverlap
type: string
required:
- type
- catenary_id
- overlapping_ranges
type: object
type: array
required:
- catenary_ranges
- warnings
type: object
description: A list of ranges associated to catenary modes. When a catenary overlapping another is found, a warning is added to the list.
summary: Retrieve the modes of catenaries along a path
$ref: '#/components/schemas/CatenariesOnPathResponse'
description: ''
summary: Retrieve the catenary modes along a path, as seen by the rolling stock specified
tags:
- infra
/pathfinding/{path_id}/electrical_profiles/:
get:
description: Retrieve the electrical profiles along a path, as seen by the rolling stock specified
parameters:
- description: The path's id
in: path
name: path_id
required: true
schema:
format: int64
type: integer
- description: The electrical profile set's id
in: query
name: electrical_profile_set_id
- in: query
name: rolling_stock_id
required: true
schema:
format: int64
type: integer
- description: The id of the rolling stock you want to use
in: query
name: rolling stock id
- in: query
name: electrical_profile_set_id
required: true
schema:
format: int64
type: integer
responses:
'200':
content:
application/json:
schema:
properties:
electrical_profile_ranges:
items:
$ref: '#/components/schemas/RangedValue'
type: array
warnings:
items:
properties:
overlapping_ranges:
items:
$ref: '#/components/schemas/TrackRange'
type: array
type:
enum:
- ElectricalProfilesOverlap
type: string
required:
- type
- overlapping_ranges
type: object
type: array
required:
- electrical_profile_ranges
- warnings
type: object
description: A list of ranges associated to catenary modes. When a catenary overlapping another is found, a warning is added to the list.
$ref: '#/components/schemas/ProfilesOnPathResponse'
description: ''
summary: Retrieve the electrical profiles along a path, as seen by the rolling stock specified
tags:
- infra
- electrical_profiles
/projects/:
get:
Expand Down
110 changes: 0 additions & 110 deletions editoast/openapi_legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1878,100 +1878,6 @@ paths:
schema:
$ref: "#/components/schemas/ScenarioResult"

/pathfinding/{path_id}/catenaries/:
get:
tags:
- infra
summary: Retrieve the modes of catenaries along a path
parameters:
- in: path
name: path_id
schema:
type: integer
description: The path's id
required: true
responses:
200:
description: A list of ranges associated to catenary modes. When a catenary overlapping another is found, a warning is added to the list.
content:
application/json:
schema:
type: object
properties:
catenary_ranges:
type: array
items:
$ref: "#/components/schemas/RangedValue"
warnings:
type: array
items:
type: object
properties:
type:
type: string
enum: ["CatenaryOverlap"]
catenary_id:
type: string
overlapping_ranges:
type: array
items:
$ref: "#/components/schemas/TrackRange"
required: [type, catenary_id, overlapping_ranges]
required: [catenary_ranges, warnings]


/pathfinding/{path_id}/electrical_profiles/:
get:
tags:
- infra
- electrical_profiles
summary: Retrieve the electrical profiles along a path, as seen by the rolling stock specified
parameters:
- in: path
name: path_id
schema:
type: integer
description: The path's id
required: true
- in: query
name: electrical_profile_set_id
schema:
type: integer
description: The electrical profile set's id
required: true
- in: query
name: rolling stock id
schema:
type: integer
description: The id of the rolling stock you want to use
required: true
responses:
200:
description: A list of ranges associated to catenary modes. When a catenary overlapping another is found, a warning is added to the list.
content:
application/json:
schema:
type: object
properties:
electrical_profile_ranges:
type: array
items:
$ref: "#/components/schemas/RangedValue"
warnings:
type: array
items:
type: object
properties:
type:
type: string
enum: ["ElectricalProfilesOverlap"]
overlapping_ranges:
type: array
items:
$ref: "#/components/schemas/TrackRange"
required: [type, overlapping_ranges]
required: [electrical_profile_ranges, warnings]

/train_schedule/{id}/:
get:
tags:
Expand Down Expand Up @@ -3272,22 +3178,6 @@ components:
items:
$ref: "#/components/schemas/TrackRange"

RangedValue:
type: object
properties:
begin:
type: number
format: float
example: 0.0
end:
type: number
format: float
example: 100.0
value:
type: string
example: "25000"
required: [begin, end, value]

SearchQuery:
type: array
minItems: 1
Expand Down
2 changes: 2 additions & 0 deletions editoast/osrd_containers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ edition = "2021"
rangemap.workspace = true
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true
utoipa.workspace = true
6 changes: 5 additions & 1 deletion editoast/osrd_containers/src/rangemap_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rangemap::RangeMap;
use serde_derive::{Deserialize, Serialize};
use std::fmt::Debug;
use std::ops::Range;
use utoipa::ToSchema;

/// A struct to make f64 Ord, to use in RangeMap
#[derive(Debug, PartialEq, Copy, Clone, Serialize)]
Expand Down Expand Up @@ -93,10 +94,13 @@ pub fn extend_range_map<T: Eq + Clone>(
}

/// A struct to represent range maps in responses
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[derive(Debug, Deserialize, PartialEq, Serialize, ToSchema)]
pub struct RangedValue {
#[schema(example = 0.0)]
pub begin: f64,
#[schema(example = 10.0)]
pub end: f64,
#[schema(example = "25000")]
pub value: String,
}

Expand Down
Loading

0 comments on commit 6e4a035

Please sign in to comment.