Skip to content

Commit

Permalink
front: create/update API is now correctly defined in OpenAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
woshilapin committed Dec 18, 2023
1 parent e3b89a8 commit 9b99b89
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 22 deletions.
7 changes: 1 addition & 6 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1638,14 +1638,9 @@ components:
properties:
obj_type:
$ref: '#/components/schemas/ObjectType'
operation_type:
enum:
- CREATE
type: string
railjson:
$ref: '#/components/schemas/Railjson'
required:
- operation_type
- obj_type
- railjson
RangeAllowance:
Expand Down Expand Up @@ -4133,7 +4128,7 @@ paths:
application/json:
schema:
items:
$ref: '#/components/schemas/Railjson'
$ref: '#/components/schemas/RailjsonObject'
type: array
description: An array containing infos about the operations processed
summary: Update/Create/Delete an object of the infra
Expand Down
7 changes: 1 addition & 6 deletions editoast/openapi_legacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ paths:
schema:
type: array
items:
$ref: "#/components/schemas/Railjson"
$ref: "#/components/schemas/RailjsonObject"

put:
tags:
Expand Down Expand Up @@ -890,14 +890,9 @@ components:

RailjsonObject:
required:
- operation_type
- obj_type
- railjson
properties:
operation_type:
type: string
enum:
- CREATE
obj_type:
$ref: "#/components/schemas/ObjectType"
railjson:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export const PointEditionLeftPanel: FC<{ type: EditoastType }> = <Entity extends
: { create: [savedEntity] }
)
);
const railjson = res[0];
const { railjson } = res[0];
const { id } = railjson;
if (id && id !== savedEntity.properties.id) {
const saveEntity = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ function getRangeEditionTool<T extends EditorRange>({
: { create: [entity] }
)
);
const { entityId } = res[0];
const { railjson } = res[0];
const { entityId } = railjson;

const savedEntity =
entityId && entityId !== entity.properties.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export const SwitchEditionLeftPanel: FC = () => {
: { create: [entityToSave] }
)
);
const { id } = res[0];
const { railjson } = res[0];
const { id } = railjson;

if (id && id !== entityToSave.properties.id) {
const savedEntity = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export const TrackEditionLeftPanel: FC = () => {
: { create: [injectGeometry(savedEntity)] }
)
);
const railjson = res[0];
const { railjson } = res[0];
const savedTrack = {
objType: 'TrackSection',
type: 'Feature',
Expand Down
11 changes: 5 additions & 6 deletions front/src/common/api/osrdEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ export type GetInfraByIdApiArg = {
id: number;
};
export type PostInfraByIdApiResponse =
/** status 200 An array containing infos about the operations processed */ Railjson[];
/** status 200 An array containing infos about the operations processed */ RailjsonObject[];
export type PostInfraByIdApiArg = {
/** infra id */
id: number;
Expand Down Expand Up @@ -1381,10 +1381,6 @@ export type RailjsonFile = {
track_sections?: any;
version?: string;
};
export type Railjson = {
id: string;
[key: string]: any;
};
export type ObjectType =
| 'TrackSection'
| 'Signal'
Expand All @@ -1396,9 +1392,12 @@ export type ObjectType =
| 'Route'
| 'OperationalPoint'
| 'Catenary';
export type Railjson = {
id: string;
[key: string]: any;
};
export type RailjsonObject = {
obj_type: ObjectType;
operation_type: 'CREATE';
railjson: Railjson;
};
export type Patch = {
Expand Down

0 comments on commit 9b99b89

Please sign in to comment.