Skip to content

Commit

Permalink
test: test for #470
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Nov 27, 2020
1 parent 747a665 commit d690c9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/additional.props.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ describe(packageJson.name, () => {
app.server.close();
});

it('should return 400 if additionalProperties=false, and type is invalid', async () =>
request(app)
.post(`${app.basePath}/additional_props/false`)
.send({
name: 'test',
extra_prop: 'test',
age: '11',
})
.expect(400)
.then((r) => {
expect(r.body.errors).to.be.an('array');
expect(r.body.errors).to.have.length(2);
const m1 = r.body.errors[0].message;
expect(m1).to.equal('should NOT have additional properties');
const m2 = r.body.errors[1].message;
expect(m2).to.equal('should be number');
}));

it('should return 400 if additionalProperties=false, but extra props sent', async () =>
request(app)
.post(`${app.basePath}/additional_props/false`)
Expand Down
2 changes: 2 additions & 0 deletions test/resources/additional.properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ components:
type: string
tag:
type: string
age:
type: number

PetAdditionalTrue:
additionalProperties: true
Expand Down

0 comments on commit d690c9e

Please sign in to comment.