-
Notifications
You must be signed in to change notification settings - Fork 2
/
openapi-types-normalized.ts
110 lines (95 loc) · 2.42 KB
/
openapi-types-normalized.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
export interface IRRef {
$ref: string
}
export interface IRModelBase {
// Note: meaningless for top level objects, maybe we can exclude these somehow in that case
nullable: boolean /* false */
readOnly: boolean /* false */
}
export type IRModelNumericFormat = "int32" | "int64" | "float" | "double"
export interface IRModelNumeric extends IRModelBase {
type: "number"
format?: IRModelNumericFormat | string | undefined
enum?: number[] | undefined
minimum?: number | undefined
maximum?: number | undefined
}
export type IRModelStringFormat =
| "byte"
| "binary"
| "date"
| "date-time"
| "password"
| "email"
export interface IRModelString extends IRModelBase {
type: "string"
format?: IRModelStringFormat | string | undefined
enum?: string[] | undefined
}
export interface IRModelBoolean extends IRModelBase {
type: "boolean"
}
export interface IRModelObject extends IRModelBase {
allOf: MaybeIRModel[]
oneOf: MaybeIRModel[]
anyOf: MaybeIRModel[]
type: "object"
required: string[]
properties: {[propertyName: string]: MaybeIRModel}
additionalProperties: boolean | MaybeIRModel
}
export interface IRModelArray extends IRModelBase {
type: "array"
items: MaybeIRModel
}
export type IRModel =
| IRModelNumeric
| IRModelString
| IRModelBoolean
| IRModelObject
| IRModelArray
export type MaybeIRModel = IRModel | IRRef
export interface IRParameter {
name: string
in: "path" | "query" | "header" | "cookie" | "body"
schema: MaybeIRModel
description: string | undefined
required: boolean
deprecated: boolean
allowEmptyValue: boolean
}
export interface IROperation {
route: string
method: "GET" | "PUT" | "POST" | "PATCH" | "DELETE"
parameters: IRParameter[]
operationId: string
tags: string[]
requestBody?: IRRequestBody
responses?: {
[statusCode: number]: IRResponse
default?: IRResponse
}
summary?: string
description?: string
deprecated: boolean
}
export interface IRRequestBody {
description: string | undefined
required: boolean
content: {
[contentType: string]: IRMediaType
}
}
export interface IRResponse {
// todo: https://github.com/mnahkies/openapi-code-generator/issues/45
headers: unknown
description: string | undefined
content?: {
[contentType: string]: IRMediaType
}
}
export interface IRMediaType {
schema: MaybeIRModel
// todo: https://github.com/mnahkies/openapi-code-generator/issues/53
encoding: unknown
}