From f95d7c195304a3c5f8ec7092bd820e160b69a24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= <julian.baeume@open-xchange.com> Date: Fri, 1 Oct 2021 14:47:55 +0200 Subject: [PATCH] change API for manifests and dependencies remove /api prefix and be more restful. This should help to simplify ingress objects --- spec/server_test.js | 12 ++++++------ src/createApp.js | 4 ++-- src/swagger.yaml | 24 ++++++++++++++++++------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/spec/server_test.js b/spec/server_test.js index ac2daf9..541c136 100644 --- a/spec/server_test.js +++ b/spec/server_test.js @@ -41,13 +41,13 @@ describe('Manifest service', () => { }) it('fetches manifest data', async () => { - const response = await request(app).get('/api/manifest.json') + const response = await request(app).get('/manifests') expect(response.statusCode).toBe(200) expect(response.body).toEqual([{ namespace: 'test', path: 'example' }]) }) it('caches manifest data', async () => { - const response = await request(app).get('/api/manifest.json') + const response = await request(app).get('/manifests') expect(response.statusCode).toBe(200) expect(response.body).toEqual([{ namespace: 'test', path: 'example' }]) @@ -59,7 +59,7 @@ describe('Manifest service', () => { await new Promise(resolve => setTimeout(resolve, 150)) - const response2 = await request(app).get('/api/manifest.json') + const response2 = await request(app).get('/manifests') expect(response2.statusCode).toBe(200) expect(response2.body).toEqual([{ namespace: 'test', path: 'example' }]) }) @@ -68,7 +68,7 @@ describe('Manifest service', () => { process.env.CACHE_TTL = 1 app = createApp() - const response = await request(app).get('/api/manifest.json') + const response = await request(app).get('/manifests') expect(response.statusCode).toBe(200) expect(response.body).toEqual([{ namespace: 'test', path: 'example' }]) @@ -81,7 +81,7 @@ describe('Manifest service', () => { // wait some time await new Promise(resolve => setTimeout(resolve, 10)) - const response2 = await request(app).get('/api/manifest.json') + const response2 = await request(app).get('/manifests') expect(response2.statusCode).toBe(200) expect(response2.body).toEqual([{ namespace: 'other', path: 'example' }]) }) @@ -104,7 +104,7 @@ describe('Manifest service', () => { const app = createApp() await request(app) - .get('/api/manifest.json') + .get('/manifests') .then(response => { expect(response.statusCode).toBe(200) expect(response.body).toEqual([ diff --git a/src/createApp.js b/src/createApp.js index ef28280..9022ebe 100644 --- a/src/createApp.js +++ b/src/createApp.js @@ -62,7 +62,7 @@ export function createApp () { app.use('/swagger.json', (req, res) => res.json(swaggerDocument)) app.timeout = 30000 - app.get('/api/manifest.json', async (req, res, next) => { + app.get('/manifests', async (req, res, next) => { try { res.json(await getOxManifests()) } catch (err) { @@ -70,7 +70,7 @@ export function createApp () { } }) - app.get('/api/deps.json', async (req, res, next) => { + app.get('/dependencies', async (req, res, next) => { try { res.json(await getDependencies()) } catch (err) { diff --git a/src/swagger.yaml b/src/swagger.yaml index 8cab3b3..0765cbf 100644 --- a/src/swagger.yaml +++ b/src/swagger.yaml @@ -4,12 +4,12 @@ info: version: 1.0.0 description: Micro service that collects manifest files from different services and merge them into a single file paths: - /api/manifest.json: + /manifests: get: - summary: Returns merged manifest.json + summary: App Suite UI compatible version of manifests data responses: '200': - description: manifest.json file + description: manifests data in JSON format content: application/json: schema: @@ -41,6 +41,18 @@ paths: device: type: string example: '!smartphone' - - - + /dependencies: + get: + summary: Mapping of all files to all of its dependencies + responses: + '200': + description: dependency information for all files of the manifest + content: + application/json: + schema: + type: object + properties: + dependency: + type: array + items: + type: string -- GitLab