-
Notifications
You must be signed in to change notification settings - Fork 2
/
koa-router-ajv-swaggergen.d.ts
96 lines (91 loc) · 3.19 KB
/
koa-router-ajv-swaggergen.d.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
declare module "koa-router-ajv-swaggergen" {
import KoaRouter from "@koa/router"
import { JSONSchemaType } from "ajv"
import { PropertiesSchema } from "ajv/dist/types/json-schema"
// type SchemaRouterMethod = "del" | "get" | "post" | "put"
type Handler =
| ((
this: Router,
path: string,
schema: {
// schema: JSONSchemaType<any>,
schema: {
/** {type: 'object',
properties: {
'foo': { type: 'string' }
},
required: [<never>'foo']}
or
{
par1: { type: "string", nullable: true},
}
*/
querystring?: PropertiesSchema<any> | JSONSchemaType<{}>
/** {type: 'object',
properties: {
'foo': { type: 'string' }
},
required: [<never>'foo']}
or
{
par1: { type: "string", nullable: true},
}
*/
params?: PropertiesSchema<any> | JSONSchemaType<{}>
/** {type: 'object',
properties: {
'foo': { type: 'string' }
}
*/
body?: JSONSchemaType<any>
/** {type: 'object',
properties: {
'foo': { type: 'string' }
},
required: [<never>'foo']}
or
{
par1: { type: "string", nullable: true},
}
*/
headers?: PropertiesSchema<any> | JSONSchemaType<{}>
}
},
...handlers: KoaRouter.Middleware[]
) => ReturnType<KoaRouter.Middleware>)
// | ((
// this: Router,
// path: string,
// config: { schema?: object; pre?: KoaRouter.Middleware[] },
// ...handlers: KoaRouter.Middleware[]
// ) => ReturnType<KoaRouter.Middleware>)
export default class Router {
rootDoc: {
openapi: string
info: {
title: string
description: string
version: string
}
tags: string[]
servers: string[]
}
constructor(router: KoaRouter, prefix: string)
routes: KoaRouter["routes"]
use: KoaRouter["use"]
prefix: KoaRouter["prefix"]
param: KoaRouter["param"]
allowedMethods: KoaRouter["allowedMethods"]
// get(
// path: string,
// schema: JSONSchemaType<any>,
// ...handlers: KoaRouter.Middleware[]
// ): ReturnType<KoaRouter.Middleware>
get: Handler
post: Handler
put: Handler
del: Handler
// static setupSwaggerUI(router: Router, prefix: string): void
static setupJsonErrors(app: any): void
}
}