Skip to content

Commit 53f2739

Browse files
Merge pull request #39 from tomtom-international/fix/inputschema
remove $ref from schema
2 parents 8e4df20 + fb3b7de commit 53f2739

File tree

4 files changed

+117
-9
lines changed

4 files changed

+117
-9
lines changed

src/indexHttp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { randomUUID } from "node:crypto";
2121
import express, { Request, Response } from "express";
2222
import cors from "cors";
2323
import { runWithSessionContext, setHttpMode } from "./services/base/tomtomClient";
24+
import { VERSION } from "./version";
2425

2526
// ============================================================================
2627
// Server Configuration
@@ -154,6 +155,7 @@ async function startHttpServer(): Promise<void> {
154155
status: "ok",
155156
backend: MAPS_BACKEND,
156157
mode: "http",
158+
version: VERSION
157159
});
158160
});
159161

src/schemas/map/dynamicMapSchema.ts

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,86 @@
1616

1717
import { z } from "zod";
1818

19+
20+
const waypointCoordinateSchema = z.object({
21+
lat: z
22+
.number()
23+
.describe(
24+
"Latitude coordinate (-90 to +90). Use precise coordinates from geocoding for best results."
25+
),
26+
lon: z
27+
.number()
28+
.describe(
29+
"Longitude coordinate (-180 to +180). Use precise coordinates from geocoding for best results."
30+
),
31+
label: z
32+
.string()
33+
.optional()
34+
.describe(
35+
"Optional custom label for this location. If not provided, defaults will be used (e.g., 'Start', 'End', 'Waypoint 1')"
36+
),
37+
});
38+
39+
1940
// Coordinate schema for reuse
20-
const coordinateSchema = z.object({
41+
const routeCoordinateSchema = z.object({
42+
lat: z
43+
.number()
44+
.describe(
45+
"Latitude coordinate (-90 to +90). Use precise coordinates from geocoding for best results."
46+
),
47+
lon: z
48+
.number()
49+
.describe(
50+
"Longitude coordinate (-180 to +180). Use precise coordinates from geocoding for best results."
51+
),
52+
label: z
53+
.string()
54+
.optional()
55+
.describe(
56+
"Optional custom label for this location. If not provided, defaults will be used (e.g., 'Start', 'End', 'Waypoint 1')"
57+
),
58+
});
59+
60+
const centerCoordinateSchema = z.object({
61+
lat: z
62+
.number()
63+
.describe(
64+
"Latitude coordinate (-90 to +90). Use precise coordinates from geocoding for best results."
65+
),
66+
lon: z
67+
.number()
68+
.describe(
69+
"Longitude coordinate (-180 to +180). Use precise coordinates from geocoding for best results."
70+
),
71+
label: z
72+
.string()
73+
.optional()
74+
.describe(
75+
"Optional custom label for this location. If not provided, defaults will be used (e.g., 'Start', 'End', 'Waypoint 1')"
76+
),
77+
});
78+
79+
const originCoordinateSchema = z.object({
80+
lat: z
81+
.number()
82+
.describe(
83+
"Latitude coordinate (-90 to +90). Use precise coordinates from geocoding for best results."
84+
),
85+
lon: z
86+
.number()
87+
.describe(
88+
"Longitude coordinate (-180 to +180). Use precise coordinates from geocoding for best results."
89+
),
90+
label: z
91+
.string()
92+
.optional()
93+
.describe(
94+
"Optional custom label for this location. If not provided, defaults will be used (e.g., 'Start', 'End', 'Waypoint 1')"
95+
),
96+
});
97+
98+
const destinationCoordinateSchema = z.object({
2199
lat: z
22100
.number()
23101
.describe(
@@ -60,7 +138,7 @@ const markerSchema = z.object({
60138

61139
// Route schema
62140
const routeSchema = z.object({
63-
points: z.array(coordinateSchema).describe("Array of route points in various coordinate formats"),
141+
points: z.array(routeCoordinateSchema).describe("Array of route points in various coordinate formats"),
64142
name: z.string().optional().describe("Optional route name"),
65143
color: z.string().optional().describe("Route color in hex format (e.g., '#0066cc')"),
66144
});
@@ -131,7 +209,7 @@ const polygonSchema = z.object({
131209
*/
132210
export const tomtomDynamicMapSchema = {
133211
// Map positioning - either center+zoom, bbox, or auto-calculated from content
134-
center: coordinateSchema
212+
center: centerCoordinateSchema
135213
.optional()
136214
.describe(
137215
"Map center coordinates. Optional if bbox provided or if markers/routes are used for auto-calculation."
@@ -196,20 +274,20 @@ export const tomtomDynamicMapSchema = {
196274
),
197275

198276
// Route planning mode (auto-detected when origin and destination provided)
199-
origin: coordinateSchema
277+
origin: originCoordinateSchema
200278
.optional()
201279
.describe(
202280
"Origin point for route planning. When provided with destination, triggers automatic route calculation. Can include optional 'label' field. Default label: 'Start'."
203281
),
204282

205-
destination: coordinateSchema
283+
destination: destinationCoordinateSchema
206284
.optional()
207285
.describe(
208286
"Destination point for route planning. When provided with origin, triggers automatic route calculation. Can include optional 'label' field. Default label: 'End'."
209287
),
210288

211289
waypoints: z
212-
.array(coordinateSchema)
290+
.array(waypointCoordinateSchema)
213291
.optional()
214292
.describe(
215293
"Optional waypoints for route planning. Each can include optional 'label' field. Default labels: 'Waypoint 1', 'Waypoint 2', etc."

src/schemas/routing/common.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { z } from "zod";
1818

19+
1920
// Common coordinate schema for reuse
2021
export const coordinateSchema = z.object({
2122
lat: z
@@ -30,6 +31,33 @@ export const coordinateSchema = z.object({
3031
),
3132
});
3233

34+
// Common coordinate schema for reuse
35+
export const originCoordinateSchema = z.object({
36+
lat: z
37+
.number()
38+
.describe(
39+
"Latitude coordinate (-90 to +90). Use precise coordinates from geocoding for best results."
40+
),
41+
lon: z
42+
.number()
43+
.describe(
44+
"Longitude coordinate (-180 to +180). Use precise coordinates from geocoding for best results."
45+
),
46+
});
47+
48+
export const destinationCoordinateSchema = z.object({
49+
lat: z
50+
.number()
51+
.describe(
52+
"Latitude coordinate (-90 to +90). Use precise coordinates from geocoding for best results."
53+
),
54+
lon: z
55+
.number()
56+
.describe(
57+
"Longitude coordinate (-180 to +180). Use precise coordinates from geocoding for best results."
58+
),
59+
});
60+
3361
// Common routing options schema for reuse
3462
export const routingOptionsSchema = {
3563
routeType: z

src/schemas/routing/routingSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616

1717
import { z } from "zod";
18-
import { coordinateSchema, routingOptionsSchema, vehicleSchema, sectionTypeSchema } from "./common";
18+
import { originCoordinateSchema, destinationCoordinateSchema, coordinateSchema, routingOptionsSchema, vehicleSchema, sectionTypeSchema } from "./common";
1919

2020
export const tomtomRoutingSchema = {
21-
origin: coordinateSchema.describe(
21+
origin: originCoordinateSchema.describe(
2222
"Starting point coordinates. Obtain from geocoding for best results."
2323
),
24-
destination: coordinateSchema.describe(
24+
destination: destinationCoordinateSchema.describe(
2525
"Destination coordinates. Obtain from geocoding for best results."
2626
),
2727
...routingOptionsSchema,

0 commit comments

Comments
 (0)