diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e586e52..a2618758f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ All changes that impact users of this module are documented in this file, in the [Common Changelog](https://common-changelog.org) format with some additional specifications defined in the CONTRIBUTING file. This codebase adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## Unreleased [minor] + +_Full changeset and discussions: [#1031](https://github.com/OpenTermsArchive/engine/pull/1031)._ + +> Development of this release was [supported](https://nlnet.nl/project/TOSDR-OTA/) by the [NGI0 Entrust Fund](https://nlnet.nl/entrust), a fund established by [NLnet](https://nlnet.nl/) with financial support from the European Commission's [Next Generation Internet](https://www.ngi.eu) programme, under the aegis of DG CNECT under grant agreement N°101069594. +### Added + +- Add `terms` attribute to `/services` API response, containing declared term types for each service ## 0.32.1 - 2023-10-18 diff --git a/src/api/routes/docs.test.js b/src/api/routes/docs.test.js index 6b9d261a0..e7480f722 100644 --- a/src/api/routes/docs.test.js +++ b/src/api/routes/docs.test.js @@ -57,7 +57,6 @@ describe('Docs API', () => { context('When requested as HTML', () => { before(async () => { response = await request(app).get(`${basePath}/v1/docs/`); - console.log(response); }); it('responds with 200 status code', () => { diff --git a/src/api/routes/services.js b/src/api/routes/services.js index ce42bed8c..daa56ff3d 100644 --- a/src/api/routes/services.js +++ b/src/api/routes/services.js @@ -72,12 +72,29 @@ const router = express.Router(); * schema: * type: array * items: - * $ref: '#/components/schemas/Service' + * type: object + * properties: + * id: + * type: string + * description: The ID of the service. + * name: + * type: string + * description: The name of the service. + * terms: + * type: array + * description: The declared terms types for this service. + * items: + * type: object + * properties: + * type: + * type: string + * description: The type of terms. */ router.get('/services', (req, res) => { res.status(200).json(Object.values(services).map(service => ({ id: service.id, name: service.name, + terms: service.getTermsTypes().map(type => ({ type })), }))); }); diff --git a/src/api/routes/services.test.js b/src/api/routes/services.test.js index a5843b115..29a67a3db 100644 --- a/src/api/routes/services.test.js +++ b/src/api/routes/services.test.js @@ -37,6 +37,20 @@ describe('Services API', () => { expect(service).to.have.property('name'); }); }); + + it('each service should have a terms array', () => { + response.body.forEach(service => { + expect(service).to.have.property('terms').that.is.an('array'); + }); + }); + + it('each terms should have a type', () => { + response.body.forEach(service => { + service.terms.forEach(terms => { + expect(terms).to.have.property('type'); + }); + }); + }); }); describe('GET /service/:serviceId', () => {