Skip to content

Commit

Permalink
Try reproducing issue #43
Browse files Browse the repository at this point in the history
  • Loading branch information
Santeri Hiltunen committed Nov 5, 2018
1 parent c647e29 commit 09032d7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/OpenApiValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ describe("OpenApiValidator", () => {
expect(err).toBeUndefined();
});

test("validating several path parameters", async () => {
const validate = getValidator("get", "/parameters/several/{a}/a/{b}/b/{c}");
let err = await validate({ params: { a: "abc", b: "bc" } });
expect(err).toBeInstanceOf(ValidationError);
expect(err).toMatchSnapshot();

err = await validate({ params: { a: "a", b: "b", c: "c" } });
expect(err).toBeUndefined();
});

test("validating bodies with null fields and nullable property is schema", async () => {
const validate = getValidator("post", "/nullable");
let err = await validate({ body: { bar: null } });
Expand Down
2 changes: 2 additions & 0 deletions test/__snapshots__/OpenApiValidator.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ exports[`OpenApiValidator validating response headers with several required head

exports[`OpenApiValidator validating response of echo endpoint 1`] = `"Error while validating response: response.body should have required property 'output'"`;

exports[`OpenApiValidator validating several path parameters 1`] = `[ValidationError: Error while validating request: request.params should have required property 'c']`;

exports[`OpenApiValidator validating signed cookies generated by cookie-parser 1`] = `[ValidationError: Error while validating request: request.cookies should have required property 'session']`;

exports[`OpenApiValidator validating signed cookies generated by cookie-parser 2`] = `[ValidationError: Error while validating request: request.cookies.session should NOT be shorter than 1 characters]`;
Expand Down
21 changes: 21 additions & 0 deletions test/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,27 @@ paths:
responses:
"200":
description: Response
/parameters/several/{a}/a/{b}/b/{c}:
get:
parameters:
- name: a
in: path
required: true
schema:
type: string
- name: b
in: path
required: true
schema:
type: string
- name: c
in: path
required: true
schema:
type: string
responses:
"200":
description: Response
/ref-parameter:
get:
parameters:
Expand Down

0 comments on commit 09032d7

Please sign in to comment.