From 05636f5c3ee8f9513a8d0a99b43e7b8543621d4b Mon Sep 17 00:00:00 2001 From: giacomobelluardo <118342586+giacomobelluardo@users.noreply.github.com> Date: Fri, 5 Jun 2026 17:00:27 +0200 Subject: [PATCH] feat(navigation): added compute path endpoint --- dist/clients/faculty/openapi.yaml | 249 ++++++++++++++++++++++++++++++ dist/clients/student/openapi.yaml | 249 ++++++++++++++++++++++++++++++ src/examples/common/places.tsp | 34 +++- src/routes/common/places.tsp | 78 ++++++++++ 4 files changed, 608 insertions(+), 2 deletions(-) diff --git a/dist/clients/faculty/openapi.yaml b/dist/clients/faculty/openapi.yaml index a57bf43..adc8304 100644 --- a/dist/clients/faculty/openapi.yaml +++ b/dist/clients/faculty/openapi.yaml @@ -1546,6 +1546,59 @@ paths: $ref: '#/components/schemas/ErrorResponse' tags: - Places + /directions/{startPlaceId}/to/{endPlaceId}: + get: + operationId: Directions_getDirections + summary: Get directions | Ottieni indicazioni + parameters: + - name: startPlaceId + in: path + required: true + schema: + type: string + - name: endPlaceId + in: path + required: true + schema: + type: string + - name: avoidStairs + in: query + required: false + schema: + type: boolean + explode: false + - name: usePrivate + in: query + required: false + schema: + type: boolean + explode: false + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/NavigationResponse' + required: + - data + '400': + description: The server could not understand the request due to invalid syntax. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Server error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + tags: + - Places /event-admissions: get: operationId: EventAdmission_getEventAdmissions @@ -3983,6 +4036,87 @@ components: freeTo: type: string format: date-time + GeoJSONFeatureGeometry: + type: object + required: + - type + - geometry + - properties + properties: + type: + type: string + enum: + - Feature + example: Feature + geometry: + type: object + properties: + type: + type: string + enum: + - LineString + example: LineString + coordinates: + type: array + items: + type: array + items: + type: number + example: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + required: + - type + - coordinates + properties: + type: object + properties: + bl_id: + type: string + example: B1 + fn_fl_id: + type: string + example: F1 + required: + - bl_id + - fn_fl_id + example: + type: Feature + geometry: + type: LineString + coordinates: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + properties: + bl_id: B1 + fn_fl_id: F1 + GeoJSONPoint: + type: object + required: + - type + - coordinates + properties: + type: + type: string + enum: + - Point + example: Point + coordinates: + type: array + items: + type: number + example: + - 45.064254 + - 7.657823 + example: + type: Point + coordinates: + - 45.064254 + - 7.657823 GeoJsonPolygon: type: object required: @@ -4229,6 +4363,121 @@ components: description: |- Additional information about the MFA session. Present only if status is `active` or `locked` + NavigationResponse: + type: object + required: + - type + - totDistance + - stairsCount + - elevatorsCount + - stepsCount + - features + properties: + type: + type: string + enum: + - FeatureCollection + example: FeatureCollection + totDistance: + type: number + example: 1240 + stairsCount: + type: number + example: 2 + elevatorsCount: + type: number + example: 1 + stepsCount: + type: number + example: 18 + features: + type: array + items: + $ref: '#/components/schemas/NavigationResponseFeature' + example: + type: FeatureCollection + totDistance: 1240 + stairsCount: 2 + elevatorsCount: 1 + stepsCount: 18 + features: + - type: FeatureCollection + startPoint: + type: Point + coordinates: + - 45.064254 + - 7.657823 + endPoint: + type: Point + coordinates: + - 7.658123 + - 45.064754 + segmentId: 1 + isPrivate: false + features: + type: Feature + geometry: + type: LineString + coordinates: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + properties: + bl_id: B1 + fn_fl_id: F1 + NavigationResponseFeature: + type: object + required: + - type + - startPoint + - endPoint + - segmentId + - isPrivate + - features + properties: + type: + type: string + enum: + - FeatureCollection + example: FeatureCollection + startPoint: + $ref: '#/components/schemas/GeoJSONPoint' + endPoint: + $ref: '#/components/schemas/GeoJSONPoint' + segmentId: + type: integer + example: 1 + isPrivate: + type: boolean + features: + $ref: '#/components/schemas/GeoJSONFeatureGeometry' + example: + type: FeatureCollection + startPoint: + type: Point + coordinates: + - 45.064254 + - 7.657823 + endPoint: + type: Point + coordinates: + - 7.658123 + - 45.064754 + segmentId: 1 + isPrivate: false + features: + type: Feature + geometry: + type: LineString + coordinates: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + properties: + bl_id: B1 + fn_fl_id: F1 NewsItem: type: object required: diff --git a/dist/clients/student/openapi.yaml b/dist/clients/student/openapi.yaml index c63f2c0..25b292a 100644 --- a/dist/clients/student/openapi.yaml +++ b/dist/clients/student/openapi.yaml @@ -1624,6 +1624,59 @@ paths: $ref: '#/components/schemas/ErrorResponse' tags: - Places + /directions/{startPlaceId}/to/{endPlaceId}: + get: + operationId: Directions_getDirections + summary: Get directions | Ottieni indicazioni + parameters: + - name: startPlaceId + in: path + required: true + schema: + type: string + - name: endPlaceId + in: path + required: true + schema: + type: string + - name: avoidStairs + in: query + required: false + schema: + type: boolean + explode: false + - name: usePrivate + in: query + required: false + schema: + type: boolean + explode: false + responses: + '200': + description: The request has succeeded. + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/NavigationResponse' + required: + - data + '400': + description: The server could not understand the request due to invalid syntax. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Server error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + tags: + - Places /esc: delete: operationId: Esc_escDelete @@ -5835,6 +5888,87 @@ components: freeTo: type: string format: date-time + GeoJSONFeatureGeometry: + type: object + required: + - type + - geometry + - properties + properties: + type: + type: string + enum: + - Feature + example: Feature + geometry: + type: object + properties: + type: + type: string + enum: + - LineString + example: LineString + coordinates: + type: array + items: + type: array + items: + type: number + example: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + required: + - type + - coordinates + properties: + type: object + properties: + bl_id: + type: string + example: B1 + fn_fl_id: + type: string + example: F1 + required: + - bl_id + - fn_fl_id + example: + type: Feature + geometry: + type: LineString + coordinates: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + properties: + bl_id: B1 + fn_fl_id: F1 + GeoJSONPoint: + type: object + required: + - type + - coordinates + properties: + type: + type: string + enum: + - Point + example: Point + coordinates: + type: array + items: + type: number + example: + - 45.064254 + - 7.657823 + example: + type: Point + coordinates: + - 45.064254 + - 7.657823 GeoJsonPolygon: type: object required: @@ -6258,6 +6392,121 @@ components: description: |- Additional information about the MFA session. Present only if status is `active` or `locked` + NavigationResponse: + type: object + required: + - type + - totDistance + - stairsCount + - elevatorsCount + - stepsCount + - features + properties: + type: + type: string + enum: + - FeatureCollection + example: FeatureCollection + totDistance: + type: number + example: 1240 + stairsCount: + type: number + example: 2 + elevatorsCount: + type: number + example: 1 + stepsCount: + type: number + example: 18 + features: + type: array + items: + $ref: '#/components/schemas/NavigationResponseFeature' + example: + type: FeatureCollection + totDistance: 1240 + stairsCount: 2 + elevatorsCount: 1 + stepsCount: 18 + features: + - type: FeatureCollection + startPoint: + type: Point + coordinates: + - 45.064254 + - 7.657823 + endPoint: + type: Point + coordinates: + - 7.658123 + - 45.064754 + segmentId: 1 + isPrivate: false + features: + type: Feature + geometry: + type: LineString + coordinates: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + properties: + bl_id: B1 + fn_fl_id: F1 + NavigationResponseFeature: + type: object + required: + - type + - startPoint + - endPoint + - segmentId + - isPrivate + - features + properties: + type: + type: string + enum: + - FeatureCollection + example: FeatureCollection + startPoint: + $ref: '#/components/schemas/GeoJSONPoint' + endPoint: + $ref: '#/components/schemas/GeoJSONPoint' + segmentId: + type: integer + example: 1 + isPrivate: + type: boolean + features: + $ref: '#/components/schemas/GeoJSONFeatureGeometry' + example: + type: FeatureCollection + startPoint: + type: Point + coordinates: + - 45.064254 + - 7.657823 + endPoint: + type: Point + coordinates: + - 7.658123 + - 45.064754 + segmentId: 1 + isPrivate: false + features: + type: Feature + geometry: + type: LineString + coordinates: + - - 7.657823 + - 45.064254 + - - 7.658123 + - 45.064754 + properties: + bl_id: B1 + fn_fl_id: F1 NewsItem: type: object required: diff --git a/src/examples/common/places.tsp b/src/examples/common/places.tsp index 5960a39..3e8717d 100644 --- a/src/examples/common/places.tsp +++ b/src/examples/common/places.tsp @@ -1,7 +1,5 @@ import "@typespec/http"; -using Http; - namespace PolitoAPI; const _ex_geo_location = #{ latitude: 45.064254, longitude: 7.657823 }; @@ -15,6 +13,38 @@ const _ex_place_category = #{ highlighted: false, }; +const _ex_geo_json_point = #{ + type: "Point", + coordinates: #[45.064254, 7.657823], +}; + +const _ex_geo_json_feature_geometry = #{ + type: "Feature", + geometry: #{ + type: "LineString", + coordinates: #[#[7.657823, 45.064254], #[7.658123, 45.064754]], + }, + properties: #{ bl_id: "B1", fn_fl_id: "F1" }, +}; + +const _ex_navigation_response_feature = #{ + type: "FeatureCollection", + startPoint: _ex_geo_json_point, + endPoint: #{ type: "Point", coordinates: #[7.658123, 45.064754] }, + segmentId: 1, + isPrivate: false, + features: _ex_geo_json_feature_geometry, +}; + +const _ex_navigation_response = #{ + type: "FeatureCollection", + totDistance: 1240, + stairsCount: 2, + elevatorsCount: 1, + stepsCount: 18, + features: #[_ex_navigation_response_feature], +}; + const _ex_place = #{ id: "TO_CIT09_XPTE_088", capacity: 300 }; const _ex_getDepartments_resp = #{ diff --git a/src/routes/common/places.tsp b/src/routes/common/places.tsp index 0455c69..98a8016 100644 --- a/src/routes/common/places.tsp +++ b/src/routes/common/places.tsp @@ -50,6 +50,71 @@ model GeoJsonPolygon { }; } +@example(_ex_geo_json_point) +model GeoJSONPoint { + @example("Point") + type: "Point"; + + @example(#[45.064254, 7.657823]) + coordinates: numeric[]; +} + +@example(_ex_geo_json_feature_geometry) +model GeoJSONFeatureGeometry { + @example("Feature") + type: "Feature"; + + geometry: { + @example("LineString") + type: "LineString"; + + @example(#[#[7.657823, 45.064254], #[7.658123, 45.064754]]) + coordinates: numeric[][]; + }; + properties: { + @example("B1") + bl_id: string; + + @example("F1") + fn_fl_id: string; + }; +} + +@example(_ex_navigation_response_feature) +model NavigationResponseFeature { + @example("FeatureCollection") + type: "FeatureCollection"; + + startPoint: GeoJSONPoint; + endPoint: GeoJSONPoint; + + @example(1) + segmentId: integer; + + isPrivate: boolean; + features: GeoJSONFeatureGeometry; +} + +@example(_ex_navigation_response) +model NavigationResponse { + @example("FeatureCollection") + type: "FeatureCollection"; + + @example(1240) + totDistance: numeric; + + @example(2) + stairsCount: numeric; + + @example(1) + elevatorsCount: numeric; + + @example(18) + stepsCount: numeric; + + features: NavigationResponseFeature[]; +} + @example(_ex_geo_location) model GeoLocation { @example(45.064254) @@ -222,3 +287,16 @@ interface Departments { @query departmentType?: string, ): OkDataResponse | BaseErrors; } + +@tag("Places") +@route("/directions/{startPlaceId}/to/{endPlaceId}") +interface Directions { + @get + @summary("Get directions | Ottieni indicazioni") + getDirections( + @path startPlaceId: string, + @path endPlaceId: string, + @query avoidStairs?: boolean, + @query usePrivate?: boolean, + ): OkDataResponse | BaseErrors; +}