Skip to content

Commit 96c9c81

Browse files
committed
editoast: add utoipa annotation to infra list endpoint
1 parent b4cbfd5 commit 96c9c81

File tree

4 files changed

+59
-95
lines changed

4 files changed

+59
-95
lines changed

editoast/openapi.yaml

+19-21
Original file line numberDiff line numberDiff line change
@@ -9287,42 +9287,40 @@ paths:
92879287
/infra/:
92889288
get:
92899289
parameters:
9290-
- description: Page number
9291-
in: query
9290+
- in: query
92929291
name: page
9292+
required: false
92939293
schema:
92949294
default: 1
9295+
format: int64
92959296
minimum: 1
92969297
type: integer
9297-
- description: Number of elements by page
9298-
in: query
9298+
- in: query
92999299
name: page_size
9300+
required: false
93009301
schema:
93019302
default: 25
9302-
maximum: 10000
9303+
format: int64
93039304
minimum: 1
9305+
nullable: true
93049306
type: integer
93059307
responses:
93069308
'200':
93079309
content:
93089310
application/json:
93099311
schema:
9310-
properties:
9311-
count:
9312-
type: number
9313-
next: {}
9314-
previous: {}
9315-
results:
9316-
items:
9317-
$ref: '#/components/schemas/Infra'
9318-
type: array
9319-
required:
9320-
- count
9321-
- next
9322-
- previous
9323-
type: object
9324-
description: The infras list
9325-
summary: Paginated list of all available infras
9312+
allOf:
9313+
- $ref: '#/components/schemas/PaginationStats'
9314+
- properties:
9315+
results:
9316+
items:
9317+
$ref: '#/components/schemas/InfraWithState'
9318+
type: array
9319+
required:
9320+
- results
9321+
type: object
9322+
description: All infras, paginated
9323+
summary: Lists all infras along with their current loading state in Core
93269324
tags:
93279325
- infra
93289326
post:

editoast/openapi_legacy.yaml

-37
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,6 @@ tags:
2222

2323
paths:
2424
/infra/:
25-
get:
26-
tags:
27-
- infra
28-
summary: Paginated list of all available infras
29-
parameters:
30-
- description: Page number
31-
in: query
32-
name: page
33-
schema:
34-
default: 1
35-
minimum: 1
36-
type: integer
37-
- description: Number of elements by page
38-
in: query
39-
name: page_size
40-
schema:
41-
default: 25
42-
maximum: 10000
43-
minimum: 1
44-
type: integer
45-
responses:
46-
200:
47-
description: The infras list
48-
content:
49-
application/json:
50-
schema:
51-
type: object
52-
properties:
53-
count:
54-
type: number
55-
next: {}
56-
previous: {}
57-
results:
58-
type: array
59-
items:
60-
$ref: "#/components/schemas/Infra"
61-
required: [count, next, previous]
6225
post:
6326
tags:
6427
- infra

editoast/src/views/infra/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ crate::routes! {
7676
get_voltages,
7777
get_switch_types,
7878
},
79+
list,
7980
get_all_voltages,
8081
railjson::routes(),
8182
},
@@ -218,7 +219,14 @@ struct InfraListResponse {
218219
results: Vec<InfraWithState>,
219220
}
220221

221-
/// Return a list of infras
222+
/// Lists all infras along with their current loading state in Core
223+
#[utoipa::path(
224+
tag = "infra",
225+
params(PaginationQueryParam),
226+
responses(
227+
(status = 200, description = "All infras, paginated", body = inline(InfraListResponse))
228+
),
229+
)]
222230
#[get("")]
223231
async fn list(
224232
db_pool: Data<DbConnectionPool>,

front/src/common/api/osrdEditoastApi.ts

+31-36
Original file line numberDiff line numberDiff line change
@@ -1049,17 +1049,12 @@ export type GetElectricalProfileSetByElectricalProfileSetIdLevelOrderApiArg = {
10491049
};
10501050
export type GetHealthApiResponse = unknown;
10511051
export type GetHealthApiArg = void;
1052-
export type GetInfraApiResponse = /** status 200 The infras list */ {
1053-
count: number;
1054-
next: any;
1055-
previous: any;
1056-
results?: Infra[];
1052+
export type GetInfraApiResponse = /** status 200 All infras, paginated */ PaginationStats & {
1053+
results: InfraWithState[];
10571054
};
10581055
export type GetInfraApiArg = {
1059-
/** Page number */
10601056
page?: number;
1061-
/** Number of elements by page */
1062-
pageSize?: number;
1057+
pageSize?: number | null;
10631058
};
10641059
export type PostInfraApiResponse = /** status 201 The created infra */ Infra;
10651060
export type PostInfraApiArg = {
@@ -1894,6 +1889,20 @@ export type ElectricalProfileSet = {
18941889
id: number;
18951890
name: string;
18961891
};
1892+
export type PaginationStats = {
1893+
/** The total number of items */
1894+
count: number;
1895+
/** The current page number */
1896+
current: number;
1897+
/** The next page number, if any */
1898+
next: number | null;
1899+
/** The total number of pages */
1900+
page_count: number;
1901+
/** The number of items per page */
1902+
page_size: number;
1903+
/** The previous page number, if any */
1904+
previous: number | null;
1905+
};
18971906
export type Infra = {
18981907
created: string;
18991908
generated_version: string | null;
@@ -1904,6 +1913,20 @@ export type Infra = {
19041913
railjson_version: string;
19051914
version: string;
19061915
};
1916+
export type InfraState =
1917+
| 'NOT_LOADED'
1918+
| 'INITIALIZING'
1919+
| 'DOWNLOADING'
1920+
| 'PARSING_JSON'
1921+
| 'PARSING_INFRA'
1922+
| 'LOADING_SIGNALS'
1923+
| 'BUILDING_BLOCKS'
1924+
| 'CACHED'
1925+
| 'TRANSIENT_ERROR'
1926+
| 'ERROR';
1927+
export type InfraWithState = Infra & {
1928+
state: InfraState;
1929+
};
19071930
export type BufferStop = {
19081931
extensions?: {
19091932
sncf?: {
@@ -2267,20 +2290,6 @@ export type InfraError = {
22672290
obj_type: 'TrackSection' | 'Signal' | 'BufferStop' | 'Detector' | 'Switch' | 'Route';
22682291
};
22692292
};
2270-
export type InfraState =
2271-
| 'NOT_LOADED'
2272-
| 'INITIALIZING'
2273-
| 'DOWNLOADING'
2274-
| 'PARSING_JSON'
2275-
| 'PARSING_INFRA'
2276-
| 'LOADING_SIGNALS'
2277-
| 'BUILDING_BLOCKS'
2278-
| 'CACHED'
2279-
| 'TRANSIENT_ERROR'
2280-
| 'ERROR';
2281-
export type InfraWithState = Infra & {
2282-
state: InfraState;
2283-
};
22842293
export type BoundingBox = (number & number)[][];
22852294
export type PathfindingOutput = {
22862295
detectors: string[];
@@ -2469,20 +2478,6 @@ export type ElectrificationsOnPathResponse = {
24692478
electrification_ranges: RangedValue[];
24702479
warnings: InternalError[];
24712480
};
2472-
export type PaginationStats = {
2473-
/** The total number of items */
2474-
count: number;
2475-
/** The current page number */
2476-
current: number;
2477-
/** The next page number, if any */
2478-
next: number | null;
2479-
/** The total number of pages */
2480-
page_count: number;
2481-
/** The number of items per page */
2482-
page_size: number;
2483-
/** The previous page number, if any */
2484-
previous: number | null;
2485-
};
24862481
export type Tags = string[];
24872482
export type Project = {
24882483
budget?: number | null;

0 commit comments

Comments
 (0)