-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import * as path from 'path'; | ||
import { expect } from 'chai'; | ||
import * as request from 'supertest'; | ||
import { createApp } from './common/app'; | ||
|
||
const apiSpecPath = path.join('test', 'resources', 'formats.yaml'); | ||
|
||
describe('path params', () => { | ||
let app = null; | ||
|
||
before(async () => { | ||
// set up express app | ||
app = await createApp( | ||
{ apiSpec: apiSpecPath }, | ||
3005, | ||
(app) => { | ||
app.get(`${app.basePath}/fees`, (req, res) => { | ||
res.json([req.query]); | ||
}); | ||
app.use((err, req, res, next) => { | ||
console.error(err); | ||
res.status(err.status ?? 500).json({ | ||
message: err.message, | ||
code: err.status ?? 500, | ||
}); | ||
}); | ||
}, | ||
false, | ||
); | ||
return app; | ||
}); | ||
|
||
after(() => { | ||
app.server.close(); | ||
}); | ||
|
||
// TODO add tests for min and max float values | ||
// TODO add tests for min max float and max min float | ||
|
||
it('should handle float type with negative', async () => | ||
request(app) | ||
.get(`${app.basePath}/fees`) | ||
.query({ | ||
id: 10, | ||
amount: -10.0, | ||
}) | ||
.expect(200) | ||
.then((r) => { | ||
const body = r.body; | ||
console.log(body); | ||
expect(body[0]).to.have.property('amount').that.equals(-10.0); | ||
})); | ||
|
||
it('should handle float type with 0 value', async () => | ||
request(app) | ||
.get(`${app.basePath}/fees`) | ||
.query({ | ||
id: 10, | ||
amount: -0.0, | ||
}) | ||
.expect(200) | ||
.then((r) => { | ||
const body = r.body; | ||
console.log(body); | ||
expect(body[0]).to.have.property('amount').that.equals(0.0); | ||
})); | ||
it('should handle float type with positive value', async () => | ||
request(app) | ||
.get(`${app.basePath}/fees`) | ||
.query({ | ||
id: 10, | ||
amount: 10.0, | ||
}) | ||
.expect(200) | ||
.then((r) => { | ||
const body = r.body; | ||
console.log(body); | ||
expect(body[0]).to.have.property('amount').that.equals(10.0); | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
openapi: 3.0.0 | ||
info: | ||
version: 1.0.0 | ||
title: test bug OpenApiValidator | ||
servers: | ||
- url: '/v1' | ||
paths: | ||
/fees: | ||
get: | ||
parameters: | ||
- name: id | ||
in: query | ||
required: true | ||
schema: | ||
type: number | ||
- name: amount | ||
in: query | ||
required: true | ||
schema: | ||
type: number | ||
format: float | ||
minimum: -10.0 | ||
responses: | ||
'200': | ||
description: response | ||
|