Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created issue_589 spec file and yaml #590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 35 additions & 0 deletions test/issue_589.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as path from 'path';
import * as express from 'express';
import * as request from 'supertest';
import * as assert from 'assert';
import { createApp } from './common/app';

describe("DateFormats", () => {
let app = null;

before(async () => {
// Set up the express app
const apiSpec = path.join('test', 'resources', 'issue_589.yaml');
app = await createApp({ apiSpec }, 1996, (app) =>
app.use(
`${app.basePath}`,
express.Router().get(`/user`, (req, res) => res.json({id: 0, name: "Nick", date: new Date("1996-01-03T22:00:00.000Z")})),
),
);
});

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

it('should get the correct date', async () =>
request(app)
.get(`${app.basePath}/user`)
.expect(200).then((res)=>
{
assert.strictEqual(res.body.id, 0);
assert.strictEqual(res.body.name, "Nick");
assert.strictEqual(res.body.date, "1996-01-04");
})
);
});
54 changes: 54 additions & 0 deletions test/resources/issue_589.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
openapi: 3.0.0
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/babaliaris/test/1.0.0
- description: My Computer
url: http://localhost:1996
- description: Express Open Api Validator
url: /v1/
info:
description: This is a simple API
version: "1.0.0"
title: Simple Inventory API
contact:
email: you@your-company.com
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'

paths:
/user:
get:
tags:
- Users
summary: Get a user.
operationId: getUser

responses:

'200':
description: Get the json user data.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
default:
description: Something went wrong.

components:
schemas:
User:
type: object
required:
- id
- name
- date
properties:
id:
type: integer
name:
type: string
date:
type: string
format: date