mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
fix(core): avoid duplicate operationId (#6574)
avoid duplication operationId
This commit is contained in:
parent
318550cab4
commit
1383aafebb
3 changed files with 10 additions and 3 deletions
|
@ -2,8 +2,8 @@
|
|||
"paths": {
|
||||
"/api/experience/profile": {
|
||||
"post": {
|
||||
"operationId": "UpdateUserProfile",
|
||||
"summary": "Update user profile data",
|
||||
"operationId": "AddUserProfile",
|
||||
"summary": "Add user profile",
|
||||
"description": "Adds user profile data to the current experience interaction. <br/>- For `Register`: The profile data provided before the identification request will be used to create a new user account. <br/>- For `SignIn` and `Register`: The profile data provided after the user is identified will be used to update the user's profile when the interaction is submitted. <br/>- `ForgotPassword`: Not supported.",
|
||||
"requestBody": {
|
||||
"content": {
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
},
|
||||
"/api/experience/verification/verification-code/verify": {
|
||||
"post": {
|
||||
"operationId": "VerifyVerificationCode",
|
||||
"operationId": "VerifyVerificationCodeVerification",
|
||||
"summary": "Verify verification code",
|
||||
"description": "Verify the provided verification code against the user's identifier. If successful, the verification record will be marked as verified.",
|
||||
"requestBody": {
|
||||
|
|
|
@ -192,6 +192,8 @@ export const validateSupplement = (
|
|||
* @throws {TypeError} if the document is invalid.
|
||||
*/
|
||||
export const validateSwaggerDocument = (document: OpenAPIV3.Document) => {
|
||||
const operationIdSet = new Set<string>();
|
||||
|
||||
for (const [path, operations] of Object.entries(document.paths)) {
|
||||
if (path.startsWith('/api/interaction')) {
|
||||
devConsole.warn(`Path \`${path}\` is not documented. Do something!`);
|
||||
|
@ -236,6 +238,11 @@ export const validateSwaggerDocument = (document: OpenAPIV3.Document) => {
|
|||
operation.operationId,
|
||||
`Path \`${path}\` and operation \`${method}\` must have an operationId.`
|
||||
);
|
||||
assert(
|
||||
!operationIdSet.has(operation.operationId),
|
||||
`Operation ID \`${operation.operationId}\` is duplicated.`
|
||||
);
|
||||
operationIdSet.add(operation.operationId);
|
||||
}
|
||||
|
||||
for (const tag of document.tags ?? []) {
|
||||
|
|
Loading…
Reference in a new issue