diff --git a/test/component.params.spec.ts b/test/component.params.spec.ts new file mode 100644 index 00000000..0a4c83ba --- /dev/null +++ b/test/component.params.spec.ts @@ -0,0 +1,37 @@ +import * as path from 'path'; +import * as express from 'express'; +import { expect } from 'chai'; +import * as request from 'supertest'; +import { createApp } from './common/app'; +import * as packageJson from '../package.json'; + +describe(packageJson.name, () => { + let app = null; + + before(async () => { + // Set up the express app + const apiSpec = path.join('test', 'resources', 'component.params.yaml'); + app = await createApp({ apiSpec }, 3005, app => + app.use( + `/`, + express + .Router() + .get(`/api/v1/meeting/:id`, (req, res) => res.json(req.params)), + ), + ); + }); + + after(() => { + app.server.close(); + }); + + it('should handle components.parameter $refs', async () => { + const id = `01701deb-34cb-46c2-972d-6eeea3850342`; + request(app) + .get(`/api/v1/meeting/${id}`) + .expect(200) + .then(r => { + expect(r.body.id).to.equal(id); + }); + }); +}); diff --git a/test/resources/component.params.yaml b/test/resources/component.params.yaml new file mode 100644 index 00000000..0810ef8c --- /dev/null +++ b/test/resources/component.params.yaml @@ -0,0 +1,49 @@ +openapi: 3.0.0 +info: + title: Manual Handling + description: API documentation for manual handling. + version: 0.1.9 +servers: + - url: / + description: Self + - url: http://localhost:3010 + description: local + - url: https://mhcore.quinoid.in + description: Development server +paths: + /api/v1/meeting/{meetingId}: + get: + description: Get meeting details by meeting id + summary: Get meeting details by meeting id + tags: + - Meeting + parameters: + - $ref: '#/components/parameters/MeetingId' + # - name: meetingId + # in: path + # required: true + # description: Meeting id + # schema: + # $ref: '#/components/parameters/MeetingId' + responses: + '200': + description: Meeting token obtained successfully + content: + application/json: + schema: + $ref: '#/components/parameters/MeetingId' +components: + securitySchemes: + bearerAuth: + type: http + scheme: bearer + bearerFormat: JWT + parameters: + MeetingId: + name: meetingId + description: Meeting id of the session + required: true + in: path + example: 01701deb-34cb-46c2-972d-6eeea3850342 + schema: + type: string