Skip to content

Commit

Permalink
adds tests for components.parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Jun 24, 2020
1 parent 850ed98 commit 421ba4b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
37 changes: 37 additions & 0 deletions 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);
});
});
});
49 changes: 49 additions & 0 deletions 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

0 comments on commit 421ba4b

Please sign in to comment.