From 40865154fa2298488c61785112e985390cb76e62 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 22 Nov 2022 15:58:43 +0100 Subject: [PATCH] =?UTF-8?q?/stations=20OpenAPI=20response=20spec:=20array?= =?UTF-8?q?=20->=20object=20=F0=9F=90=9B=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #26 --- routes/stations.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/routes/stations.js b/routes/stations.js index a169ff8..37df43a 100644 --- a/routes/stations.js +++ b/routes/stations.js @@ -49,7 +49,6 @@ const complete = (req, res, next, q, allStations, onStation, onEnd) => { const completion = parse(q.completion) !== false const results = autocomplete(q.query, limit, fuzzy, completion) - const data = [] for (const result of results) { const station = allStations[result.id] if (!station) continue @@ -96,7 +95,7 @@ const stationsRoute = (req, res, next) => { pAllStations .then(({stations, timeModified, asJson, asNdjson}) => { res.setHeader('Last-Modified', timeModified.toUTCString()) - if (Object.keys(req.query).length === 0) { + if (Object.keys(q).length === 0) { const data = t === JSON_MIME ? asJson.data : asNdjson.data const etag = t === JSON_MIME ? asJson.etag : asNdjson.etag serveBuffer(req, res, data, {timeModified, etag}) @@ -151,12 +150,12 @@ Instead of receiving a JSON response, you can request [newline-delimited JSON](h }], responses: { '2XX': { - description: 'An array of stops/stations, in the [`db-stations@3` format](https://github.com/derhuerst/db-stations/blob/3.0.1/readme.md).', + description: 'An object of stops/stations in the [`db-stations@3` format](https://github.com/derhuerst/db-stations/blob/3.0.1/readme.md), with their IDs as the keys.', content: { 'application/json': { schema: { - type: 'array', - items: {type: 'object'}, // todo + // todo + type: 'object', }, // todo: example(s) },