Skip to content

Commit 978ce06

Browse files
authored
fix(docs-client-gen): add more readable operationId and response types, fix deps ZMS-188 (#759)
1 parent 7daa0e3 commit 978ce06

25 files changed

+4628
-4587
lines changed

docs/api/openapidocs.json

+4,380-4,450
Large diffs are not rendered by default.

lib/api/2fa/custom.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = (db, server, userHandler) => {
1717
path: '/users/:user/2fa/custom',
1818
tags: ['TwoFactorAuth'],
1919
summary: 'Enable custom 2FA for a user',
20+
name: 'enableCustom2FA',
2021
description: 'This method disables account password for IMAP/POP3/SMTP',
2122
validationObjs: {
2223
requestBody: {
@@ -25,7 +26,7 @@ module.exports = (db, server, userHandler) => {
2526
},
2627
queryParams: {},
2728
pathParams: { user: userId },
28-
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
29+
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
2930
}
3031
},
3132
tools.responseWrapper(async (req, res) => {
@@ -74,6 +75,7 @@ module.exports = (db, server, userHandler) => {
7475
path: '/users/:user/2fa/custom',
7576
tags: ['TwoFactorAuth'],
7677
summary: 'Disable custom 2FA for a user',
78+
name: 'disableCustom2FA',
7779
description: 'This method disables custom 2FA. If it was the only 2FA set up, then account password for IMAP/POP3/SMTP gets enabled again',
7880
validationObjs: {
7981
requestBody: {},
@@ -82,7 +84,7 @@ module.exports = (db, server, userHandler) => {
8284
ip: sessIPSchema
8385
},
8486
pathParams: { user: userId },
85-
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
87+
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
8688
}
8789
},
8890
tools.responseWrapper(async (req, res) => {

lib/api/2fa/totp.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = (db, server, userHandler) => {
1616
path: '/users/:user/2fa/totp/setup',
1717
tags: ['TwoFactorAuth'],
1818
summary: 'Generate TOTP seed',
19+
name: 'generateTOTPSeed',
1920
description: 'This method generates TOTP seed and QR code for 2FA. User needs to verify the seed value using 2fa/totp/enable endpoint',
2021
validationObjs: {
2122
requestBody: {
@@ -33,7 +34,7 @@ module.exports = (db, server, userHandler) => {
3334
success: successRes,
3435
seed: Joi.string().required().description('Generated TOTP seed value'),
3536
qrcode: Joi.string().required().description('Base64 encoded QR code')
36-
})
37+
}).$_setFlag('objectName', 'GenerateTOTPSeedResponse')
3738
}
3839
}
3940
}
@@ -86,6 +87,7 @@ module.exports = (db, server, userHandler) => {
8687
path: '/users/:user/2fa/totp/enable',
8788
tags: ['TwoFactorAuth'],
8889
summary: 'Enable TOTP seed',
90+
name: 'enableTOTPSeed',
8991
description: 'This method enables TOTP for a user by verifying the seed value generated from 2fa/totp/setup',
9092
validationObjs: {
9193
requestBody: {
@@ -95,7 +97,7 @@ module.exports = (db, server, userHandler) => {
9597
},
9698
queryParams: {},
9799
pathParams: { user: userId },
98-
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
100+
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
99101
}
100102
},
101103
tools.responseWrapper(async (req, res) => {
@@ -161,12 +163,13 @@ module.exports = (db, server, userHandler) => {
161163
path: '/users/:user/2fa/totp',
162164
tags: ['TwoFactorAuth'],
163165
summary: 'Disable TOTP auth',
166+
name: 'disableTOTPAuth',
164167
description: 'This method disables TOTP for a user. Does not affect other 2FA mechanisms a user might have set up',
165168
validationObjs: {
166169
requestBody: {},
167170
queryParams: { sess: sessSchema, ip: sessIPSchema },
168171
pathParams: { user: userId },
169-
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
172+
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
170173
}
171174
},
172175
tools.responseWrapper(async (req, res) => {
@@ -215,6 +218,7 @@ module.exports = (db, server, userHandler) => {
215218
path: '/users/:user/2fa/totp/check',
216219
tags: ['TwoFactorAuth'],
217220
summary: 'Validate TOTP Token',
221+
name: 'validateTOTPToken',
218222
description: 'This method checks if a TOTP token provided by a User is valid for authentication',
219223
validationObjs: {
220224
requestBody: {
@@ -224,7 +228,7 @@ module.exports = (db, server, userHandler) => {
224228
},
225229
queryParams: {},
226230
pathParams: { user: userId },
227-
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
231+
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
228232
}
229233
},
230234
tools.responseWrapper(async (req, res) => {
@@ -281,6 +285,7 @@ module.exports = (db, server, userHandler) => {
281285
path: '/users/:user/2fa',
282286
tags: ['TwoFactorAuth'],
283287
summary: 'Disable 2FA',
288+
name: 'disable2FA',
284289
description: 'This method disables all 2FA mechanisms a user might have set up',
285290
validationObjs: {
286291
requestBody: {},
@@ -289,7 +294,7 @@ module.exports = (db, server, userHandler) => {
289294
ip: sessIPSchema
290295
},
291296
pathParams: { user: userId },
292-
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }) } }
297+
response: { 200: { description: 'Success', model: Joi.object({ success: successRes }).$_setFlag('objectName', 'SuccessResponse') } }
293298
}
294299
},
295300
tools.responseWrapper(async (req, res) => {

lib/api/2fa/webauthn.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = (db, server, userHandler) => {
1414
path: '/users/:user/2fa/webauthn/credentials',
1515
tags: ['TwoFactorAuth'],
1616
summary: 'Get WebAuthN credentials for a user',
17+
name: 'getWebAuthN',
1718
description: 'This method returns the list of WebAuthN credentials for a given user',
1819
validationObjs: {
1920
requestBody: {},
@@ -43,7 +44,7 @@ module.exports = (db, server, userHandler) => {
4344
)
4445
.required()
4546
.description('List of credentials')
46-
})
47+
}).$_setFlag('objectName', 'GetWebAuthNResponse')
4748
}
4849
}
4950
}
@@ -115,6 +116,7 @@ module.exports = (db, server, userHandler) => {
115116
path: '/users/:user/2fa/webauthn/credentials/:credential',
116117
tags: ['TwoFactorAuth'],
117118
summary: 'Remove WebAuthN authenticator',
119+
name: 'deleteWebAuthN',
118120
description: 'This method deletes the given WebAuthN authenticator for given user.',
119121
validationObjs: {
120122
requestBody: {},
@@ -132,7 +134,7 @@ module.exports = (db, server, userHandler) => {
132134
model: Joi.object({
133135
success: successRes,
134136
deleted: booleanSchema.required().description('Specifies whether the given credential has been deleted')
135-
})
137+
}).$_setFlag('objectName', 'DeleteWebAuthNResponse')
136138
}
137139
}
138140
}
@@ -187,6 +189,7 @@ module.exports = (db, server, userHandler) => {
187189
path: '/users/:user/2fa/webauthn/registration-challenge',
188190
tags: ['TwoFactorAuth'],
189191
summary: 'Get the WebAuthN registration challenge',
192+
name: 'initiateWebAuthNRegistration',
190193
description: 'This method initiates the WebAuthN authenticator registration challenge',
191194
validationObjs: {
192195
requestBody: {
@@ -247,7 +250,7 @@ module.exports = (db, server, userHandler) => {
247250
)
248251
.description('List of credentials to exclude')
249252
})
250-
})
253+
}).$_setFlag('objectName', 'InitiateWebAuthNRegistrationResponse')
251254
}
252255
}
253256
}
@@ -299,6 +302,7 @@ module.exports = (db, server, userHandler) => {
299302
path: '/users/:user/2fa/webauthn/registration-attestation',
300303
tags: ['TwoFactorAuth'],
301304
summary: 'Attestate WebAuthN authenticator',
305+
name: 'attestateWebAuthNRegistration',
302306
description: 'Attestation is used to verify the authenticity of the authenticator and provide assurances about its features.',
303307
validationObjs: {
304308
requestBody: {
@@ -333,7 +337,7 @@ module.exports = (db, server, userHandler) => {
333337
rawId: Joi.string().hex().required().description('Credential RawID as a hex string'),
334338
description: Joi.string().required().description('Description for the authenticator'),
335339
authenticatorAttachment: Joi.string().required().description('Specifies whether authenticator is "platform" or "cross-platform"')
336-
})
340+
}).$_setFlag('objectName', 'AttestateWebAuthNRegistrationResponse')
337341
}
338342
}
339343
}
@@ -387,6 +391,7 @@ module.exports = (db, server, userHandler) => {
387391
path: '/users/:user/2fa/webauthn/authentication-challenge',
388392
tags: ['TwoFactorAuth'],
389393
summary: 'Begin WebAuthN authentication challenge',
394+
name: 'authenticateWebAuthN',
390395
description: 'This method retrieves the WebAuthN PublicKeyCredentialRequestOptions object to use it for authentication',
391396
validationObjs: {
392397
requestBody: {
@@ -431,7 +436,7 @@ module.exports = (db, server, userHandler) => {
431436
})
432437
.required()
433438
.description('PublicKeyCredentialRequestOptions object')
434-
})
439+
}).$_setFlag('objectName', 'AuthenticateWebAuthNResponse')
435440
}
436441
}
437442
}
@@ -483,6 +488,7 @@ module.exports = (db, server, userHandler) => {
483488
path: '/users/:user/2fa/webauthn/authentication-assertion',
484489
tags: ['TwoFactorAuth'],
485490
summary: 'WebAuthN authentication Assertion',
491+
name: 'assertWebAuthN',
486492
description: 'Assert WebAuthN authentication request and actually authenticate the user',
487493
validationObjs: {
488494
requestBody: {
@@ -529,7 +535,7 @@ module.exports = (db, server, userHandler) => {
529535
.required()
530536
.description('Auth data'),
531537
token: Joi.string().description('User auth token')
532-
})
538+
}).$_setFlag('objectName', 'AssertWebAuthNResponse')
533539
}
534540
}
535541
}

0 commit comments

Comments
 (0)