Skip to content

Commit

Permalink
feature: Add Route Point Metadata definition to Resources OpenAPI (#1548
Browse files Browse the repository at this point in the history
)
  • Loading branch information
panaaj committed Apr 17, 2023
1 parent 171587a commit 599c62f
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 6 deletions.
60 changes: 54 additions & 6 deletions src/api/resources/openApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,60 @@
"properties": {
"description": "Additional feature properties",
"type": "object",
"additionalProperties": true
"additionalProperties": true,
"properties": {
"coordinatesMeta": {
"type": "array",
"title": "Route point details",
"description": "Metadata for each point within the route. Array length MUST be the same as length of coordinates array!",
"items": {
"oneOf": [
{
"$ref": "#/components/schemas/RoutePointMeta"
},
{
"$ref": "#/components/schemas/HrefAttribute"
}
]
},
"example": [
{
"name": "RtePt001"
},
{
"href": "/resources/waypoints/ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a"
},
{
"name": "RtePt003"
},
{
"name": "RtePt004"
},
{
"name": "RtePt005"
}
]
}
}
}
}
}
}
},
"RoutePointMeta": {
"type": "object",
"title": "Route point metadata",
"description": "Attributes of a point within the route",
"required": ["name"],
"additionalProperties": true,
"properties": {
"name": {
"description": "Point name / identifier",
"type": "string",
"example": "RtePt001"
}
}
},
"Waypoint": {
"description": "Signal K Waypoint resource",
"type": "object",
Expand Down Expand Up @@ -817,7 +865,7 @@
],
"responses": {
"default": {
"description": "List of route resources identified by their UUID",
"description": "An object containing Route resources, keyed by their UUID.",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -947,7 +995,7 @@
],
"responses": {
"default": {
"description": "List of waypoint resources identified by their UUID",
"description": "An object containing Waypoint resources, keyed by their UUID.",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -1077,7 +1125,7 @@
],
"responses": {
"default": {
"description": "List of region resources identified by their UUID",
"description": "An object containing Region resources, keyed by their UUID.",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -1218,7 +1266,7 @@
],
"responses": {
"default": {
"description": "List of note resources identified by their UUID",
"description": "An object containing Note resources, keyed by their UUID.",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -1334,7 +1382,7 @@
"summary": "Retrieve chart resources",
"responses": {
"default": {
"description": "List of chart resources identified by their UUID",
"description": "An object containing Chart resources, keyed by their UUID.",
"content": {
"application/json": {
"schema": {
Expand Down
45 changes: 45 additions & 0 deletions test/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,49 @@ describe('Resources Api', () => {
returnedIds[0].should.equal(resourceIds[1])
})
})

it('Create route with route point metadata', async function() {
const {
post,
stop
} = await startServer()


const route = {
feature: {
type: "Feature",
geometry: {
type: "LineString",
coordinates: [[3.3452,65.4567],[3.3352, 65.5567],[3.3261,65.5777]]
},
properties: {
coordinatesMeta: [
{
name: "Start point",
description: "Start of route."
},
{
name: "Mid-point marker",
description: "Turn here."
},
{
name: "Destination",
description: "End of route."
}
]
}
}
}

const { id } = await post('/resources/routes', route)
.then(response => {
response.status.should.equal(201)
return response.json()
})
id.length.should.equal(
'ac3a3b2d-07e8-4f25-92bc-98e7c92f7f1a'.length
)

stop()
})
})

0 comments on commit 599c62f

Please sign in to comment.