-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathopenapi.libsonnet
More file actions
181 lines (168 loc) · 4.76 KB
/
openapi.libsonnet
File metadata and controls
181 lines (168 loc) · 4.76 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{
// Parameter helpers
stringParam(name, description):: {
name: name,
'in': 'path',
required: true,
description: description,
schema: { type: 'string' },
},
workspaceIdParam():: self.stringParam('workspaceId', 'ID of the workspace'),
policyIdParam():: self.stringParam('policyId', 'ID of the policy'),
resourceIdParam():: self.stringParam('resourceId', 'ID of the resource'),
resourceIdentifierParam():: self.stringParam('resourceIdentifier', 'Identifier of the resource'),
deploymentIdParam():: self.stringParam('deploymentId', 'ID of the deployment'),
deploymentVersionIdParam():: self.stringParam('deploymentVersionId', 'ID of the deployment version'),
environmentIdParam():: self.stringParam('environmentId', 'ID of the environment'),
systemIdParam():: self.stringParam('systemId', 'ID of the system'),
releaseTargetKeyParam():: self.stringParam('releaseTargetKey', 'Key of the release target'),
releaseIdParam():: self.stringParam('releaseId', 'ID of the release'),
jobAgentIdParam():: self.stringParam('jobAgentId', 'ID of the job agent'),
jobIdParam():: self.stringParam('jobId', 'ID of the job'),
nameParam():: self.stringParam('name', 'Name of the resource provider'),
identifierParam():: self.stringParam('identifier', 'Identifier of the resource'),
providerIdParam():: self.stringParam('providerId', 'ID of the resource provider'),
relationshipRuleIdParam():: self.stringParam('relationshipRuleId', 'ID of the relationship rule'),
workflowIdParam():: self.stringParam('workflowId', 'ID of the workflow'),
limitParam(defaultValue=50):: {
name: 'limit',
'in': 'query',
required: false,
description: 'Maximum number of items to return',
schema: {
type: 'integer',
minimum: 1,
maximum: 1000,
default: defaultValue,
},
},
offsetParam():: {
name: 'offset',
'in': 'query',
required: false,
description: 'Number of items to skip',
schema: {
type: 'integer',
minimum: 0,
default: 0,
},
},
orderParam():: {
name: 'order',
'in': 'query',
required: false,
description: 'Sort order for results',
schema: {
type: 'string',
enum: ['asc', 'desc'],
default: 'desc',
},
},
celParam():: {
name: 'cel',
'in': 'query',
required: false,
description: 'CEL expression to filter the results',
schema: {
type: 'string',
},
},
// Response helpers
schemaRef(name, nullable=false):: (
if nullable then
{ '$ref': '#/components/schemas/' + name, nullable: true }
else
{ '$ref': '#/components/schemas/' + name }
),
okResponse(schema, description='OK response'):: {
'200': {
description: description,
content: {
'application/json': {
schema: schema,
},
},
},
},
acceptedResponse(schema, description='Accepted response'):: {
'202': {
description: description,
content: {
'application/json': {
schema: schema,
},
},
},
},
createdResponse(schema, description='Resource created successfully'):: {
'201': {
description: description,
content: {
'application/json': {
schema: schema,
},
},
},
},
notFoundResponse():: {
'404': {
description: 'Resource not found',
content: {
'application/json': {
schema: { '$ref': '#/components/schemas/ErrorResponse' },
},
},
},
},
badRequestResponse():: {
'400': {
description: 'Invalid request',
content: {
'application/json': {
schema: { '$ref': '#/components/schemas/ErrorResponse' },
},
},
},
},
internalServerError():: {
'500': {
description: 'Internal server error',
content: {
'application/json': {
schema: { '$ref': '#/components/schemas/ErrorResponse' },
},
},
},
},
paginatedResponse(itemsSchema, description='Paginated list of items'):: {
'200': {
description: description,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
items: {
type: 'array',
items: itemsSchema,
},
total: {
type: 'integer',
description: 'Total number of items available',
},
limit: {
type: 'integer',
description: 'Maximum number of items returned',
},
offset: {
type: 'integer',
description: 'Number of items skipped',
},
},
required: ['items', 'total', 'limit', 'offset'],
},
},
},
},
},
}