-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschema-stringifier.ts
54 lines (51 loc) · 1 KB
/
schema-stringifier.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import warden from "../src";
warden.debug = true;
// Returns optional request instance
const route = warden.register('schema', {
identifier: '{query.foo}',
schema: {
type: 'object',
properties: {
application: {
type: 'object',
properties: {
name: {
type: 'string',
},
environment: {
type: 'string'
},
framework: {
type: 'string'
},
list: {
type: "array",
items: {
type: 'string'
}
}
}
},
wardenVersion: {
type: 'number',
}
}
}
});
// You can use the request handler
route({
url: 'https://postman-echo.com/post',
method: 'post',
body: {
wardenVersion: 1.5,
application: {
name: 'Schema Parser Test',
environment: 'Node.Js',
framework: 'Puzzle',
list: ["Puzzle", "Warden"]
}
},
json: true
}, (err, res, body) => {
console.log(body);
});