Skip to content

Commit

Permalink
Merge branch 'master' into cmd/preprocess/visit-optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Jan 9, 2021
2 parents 979e310 + db15435 commit fa04dec
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/circular.spec.ts
@@ -0,0 +1,42 @@
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', 'circular.yaml');
app = await createApp({ apiSpec }, 3005, (app) =>
app.use(
`${app.basePath}`,
express.Router().post(`/circular`, (req, res) => res.json(req.body)),
),
);
});

after(() => {
app.server.close();
});

it('should validate circular ref successfully', async () =>
request(app)
.post(`${app.basePath}/circular`)
.send({
id: 1,
name: 'dad',
favorite: {
id: 1,
name: 'dad',
},
children: [
{ id: 2, name: 'tyler' },
{ id: 3, name: 'taylor' },
],
})
.expect(200));
});
40 changes: 40 additions & 0 deletions test/resources/circular.yaml
@@ -0,0 +1,40 @@
openapi: '3.0.3'
info:
version: 1.0.0
title: Swagger
servers:
- url: /v1
paths:
/circular:
post:
description: creates user
requestBody:
description: creates user
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
'200':
description: Updated

components:
schemas:
User:
type: object
required:
- id
properties:
id:
type: number
name:
type: string
favorite:
$ref: '#/components/schemas/User'
children:
type: array
items:
$ref: '#/components/schemas/User'


0 comments on commit fa04dec

Please sign in to comment.