From 2a461ee53e9b8ea790008374ba98b3e21e1d6bea Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Mon, 2 May 2016 20:58:50 -0700 Subject: [PATCH 1/6] update API for creating user, updating password and comment post return. --- docs/swagger.yaml | 94 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 404a0b431..588565b55 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -109,7 +109,7 @@ paths: tags: - Products responses: - 200: + 201: description: Project created successfully. 400: description: Unsatisfied with constraints of the project creation. @@ -383,6 +383,56 @@ paths: description: User does not have permission of admin role. 500: description: Unexpected internal errors. + post: + summary: Creates a new user account. + description: | + This endpoint is to create a user if the user does not already exist. + parameters: + - name: username + in: body + type: string + format: string + required: true + description: The username of the new created user. Maximum of 20 + characters. + - name: password + in: body + type: string + format: string + required: true + description: The password of the new created user. Maximum of 20 + characters. + - name: email + in: body + type: string + format: string + required: true + description: Publicly visible email address of the new created user. + - name: realname + in: body + type: string + format: string + required: true + description: Full name associated with the new created user. + Maximum of 20 characters. + - name: comment + in: body + type: string + format: string + required: false + description: Comments associated with the new created user. + Maximum of 30 characters. + tags: + - Products + responses: + 201: + description: User created successfully. + 400: + description: Unsatisfied with constraints of the user creation. + 403: + description: User registration can only be used by admin role user when self-registration is off. + 500: + description: Unexpected internal errors. /users/{user_id}: put: summary: Update a registered user to change to be an administrator of Harbor. @@ -438,6 +488,48 @@ paths: description: User ID does not exist. 500: description: Unexpected internal errors. + /users/{user_id}/password: + put: + summary: Change the password on a user that already exists. + description: | + This endpoint is for user to update password. Users with the admin + role can change any user's password. Guest users can change only + their own password. + parameters: + - name: user_id + in: path + type: integer + format: int32 + required: true + description: Registered user ID. + parameters: + - name: old_password + in: body + type: string + format: string + required: true + description: The user's existing password. + parameters: + - name: new_password + in: body + type: string + format: string + required: true + description: New password for marking as to be updated. + tags: + - Products + responses: + 200: + description: Updated password successfully. + 400: + description: Invalid user ID; Old password is blank; New password + is blank. + 401: + description: Old password is not correct. + 403: + description: Guests can only change their own account. + 500: + description: Unexpected internal errors. /repositories: get: summary: Get repositories accompany with relevant project and repo name. From ff429234015fc440d98939f3f18ae5e6dab5a80c Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Mon, 2 May 2016 21:05:06 -0700 Subject: [PATCH 2/6] update API for creating user, updating password and comment post return. --- docs/swagger.yaml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 588565b55..aeb95ea92 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -393,15 +393,13 @@ paths: type: string format: string required: true - description: The username of the new created user. Maximum of 20 - characters. + description: The username of the new created user. Maximum of 20 characters. - name: password in: body type: string format: string required: true - description: The password of the new created user. Maximum of 20 - characters. + description: The password of the new created user. Maximum of 20 characters. - name: email in: body type: string @@ -413,15 +411,13 @@ paths: type: string format: string required: true - description: Full name associated with the new created user. - Maximum of 20 characters. + description: Full name associated with the new created user. Maximum of 20 characters. - name: comment in: body type: string format: string required: false - description: Comments associated with the new created user. - Maximum of 30 characters. + description: Comments associated with the new created user. Maximum of 30 characters. tags: - Products responses: @@ -522,8 +518,7 @@ paths: 200: description: Updated password successfully. 400: - description: Invalid user ID; Old password is blank; New password - is blank. + description: Invalid user ID; Old password is blank; New password is blank. 401: description: Old password is not correct. 403: From 73fe2a30d6b50e87ec3792cbb9da9543c588e728 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Mon, 2 May 2016 22:43:50 -0700 Subject: [PATCH 3/6] remove duplicate parameters lines. --- docs/swagger.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index aeb95ea92..8c648819f 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -498,14 +498,12 @@ paths: format: int32 required: true description: Registered user ID. - parameters: - name: old_password in: body type: string format: string required: true description: The user's existing password. - parameters: - name: new_password in: body type: string From c7da848dd592d421022ef58e1ff3eb59474d110c Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 3 May 2016 18:27:07 -0700 Subject: [PATCH 4/6] pass on the swagger editor check. --- docs/swagger.yaml | 61 +++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 8c648819f..88bbb78ec 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -388,36 +388,12 @@ paths: description: | This endpoint is to create a user if the user does not already exist. parameters: - - name: username + - name: user in: body - type: string - format: string + description: New created user. required: true - description: The username of the new created user. Maximum of 20 characters. - - name: password - in: body - type: string - format: string - required: true - description: The password of the new created user. Maximum of 20 characters. - - name: email - in: body - type: string - format: string - required: true - description: Publicly visible email address of the new created user. - - name: realname - in: body - type: string - format: string - required: true - description: Full name associated with the new created user. Maximum of 20 characters. - - name: comment - in: body - type: string - format: string - required: false - description: Comments associated with the new created user. Maximum of 30 characters. + schema: + $ref: '#/definitions/User' tags: - Products responses: @@ -488,9 +464,7 @@ paths: put: summary: Change the password on a user that already exists. description: | - This endpoint is for user to update password. Users with the admin - role can change any user's password. Guest users can change only - their own password. + This endpoint is for user to update password. Users with the admin role can change any user's password. Guest users can change only their own password. parameters: - name: user_id in: path @@ -498,18 +472,12 @@ paths: format: int32 required: true description: Registered user ID. - - name: old_password + - name: password in: body - type: string - format: string + description: New updated password. required: true - description: The user's existing password. - - name: new_password - in: body - type: string - format: string - required: true - description: New password for marking as to be updated. + schema: + $ref: '#/definitions/Password' tags: - Products responses: @@ -522,7 +490,7 @@ paths: 403: description: Guests can only change their own account. 500: - description: Unexpected internal errors. + description: Unexpected internal errors. /repositories: get: summary: Get repositories accompany with relevant project and repo name. @@ -725,6 +693,15 @@ definitions: deleted: type: integer format: int32 + Password: + type: object + properties: + old_password: + type: string + description: The user's existing password. + new_password: + type: string + description: New password for marking as to be updated. AccessLog: type: object properties: From f4f716ad31c3918a1f54593404612d56798951bd Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 3 May 2016 18:39:37 -0700 Subject: [PATCH 5/6] pass on the swagger editor check. --- docs/swagger.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 88bbb78ec..98bc392b1 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -474,7 +474,7 @@ paths: description: Registered user ID. - name: password in: body - description: New updated password. + description: Password for updating. required: true schema: $ref: '#/definitions/Password' From b68f2e1d224102df041110d1db7eed03c8c31acb Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 3 May 2016 23:43:37 -0700 Subject: [PATCH 6/6] pass on the swagger parser check. --- docs/swagger.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 98bc392b1..20307cc49 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -474,7 +474,7 @@ paths: description: Registered user ID. - name: password in: body - description: Password for updating. + description: Password to be updated. required: true schema: $ref: '#/definitions/Password'