From 477f0949bc7a559484fac91119bd31f8006f686b Mon Sep 17 00:00:00 2001 From: foorack Date: Fri, 3 Sep 2021 23:42:41 +0200 Subject: [PATCH 1/3] Split out PlayerModerationAPI --- .../components/paths/playermoderation.yaml | 155 +++++++++++++++++ .../PlayerModerationListResponse.yaml | 7 + .../PlayerModerationResponse.yaml | 5 + openapi/openapi.yaml | 158 +----------------- 4 files changed, 170 insertions(+), 155 deletions(-) create mode 100644 openapi/components/paths/playermoderation.yaml create mode 100644 openapi/components/responses/playermoderation/PlayerModerationListResponse.yaml create mode 100644 openapi/components/responses/playermoderation/PlayerModerationResponse.yaml diff --git a/openapi/components/paths/playermoderation.yaml b/openapi/components/paths/playermoderation.yaml new file mode 100644 index 00000000..18a70ba6 --- /dev/null +++ b/openapi/components/paths/playermoderation.yaml @@ -0,0 +1,155 @@ +openapi: 3.0.3 +info: + title: authentication + version: '1.0' + description: A +paths: + /auth/user/playermoderations: + get: + summary: Search Player Moderations + tags: + - playermoderation + responses: + '200': + $ref: ../responses/playermoderation/PlayerModerationListResponse.yaml + '401': + $ref: ../responses/MissingCredentialsError.yaml + operationId: getPlayerModerations + security: + - apiKeyCookie: [] + authCookie: [] + parameters: + - schema: + type: string + in: query + name: type + description: 'Must be one of PlayerModerationType, except unblock. Unblocking simply removes a block.' + - schema: + type: string + in: query + name: sourceUserId + description: Must be valid UserID. Trying to view someone else's moderations results with "Can't view someone else's player moderations" error. + x-internal: true + - schema: + type: string + in: query + name: targetUserId + description: Must be valid UserID. + description: |- + Returns a list of all player moderations made by **you**. + + This endpoint does not have pagination, and will return *all* results. Use query parameters to limit your query if needed. + post: + summary: Moderate User + operationId: moderateUser + security: + - apiKeyCookie: [] + authCookie: [] + responses: + '200': + $ref: ../responses/playermoderation/PlayerModerationResponse.yaml + '401': + $ref: ../responses/MissingCredentialsError.yaml + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: false + properties: + moderated: + $ref: ../schemas/UserID.yaml + type: + $ref: ../schemas/PlayerModerationType.yaml + required: + - moderated + - type + description: '' + description: 'Moderate a user, e.g. unmute them or show their avatar.' + tags: + - playermoderation + delete: + summary: Clear All Player Moderations + operationId: clearAllPlayerModerations + security: + - apiKeyCookie: [] + authCookie: [] + responses: + '200': + $ref: ../responses/OkSuccess.yaml + '401': + $ref: ../responses/MissingCredentialsError.yaml + description: ⚠️ **This will delete every single player moderation you've ever made.** + tags: + - playermoderation + /auth/user/unplayermoderate: + put: + summary: Unmoderate User + operationId: unmoderateUser + security: + - apiKeyCookie: [] + authCookie: [] + requestBody: + content: + application/json: + schema: + type: object + properties: + moderated: + $ref: ../schemas/UserID.yaml + type: + $ref: ../schemas/PlayerModerationType.yaml + required: + - type + description: 'Removes a player moderation previously added through `moderateUser`. E.g if you previuosly have shown their avatar, but now want to reset it to default.' + responses: + '200': + $ref: ../responses/PlayerModerationUnmoderatedSuccess.yaml + '401': + $ref: ../responses/MissingCredentialsError.yaml + tags: + - playermoderation + '/auth/user/playermoderations/{playerModerationId}': + get: + summary: Get Player Moderation + tags: + - playermoderation + responses: + '200': + $ref: ../responses/playermoderation/PlayerModerationResponse.yaml + '401': + $ref: ../responses/MissingCredentialsError.yaml + '404': + $ref: ../responses/PlayerModerationNotFoundError.yaml + operationId: getPlayerModeration + security: + - apiKeyCookie: [] + authCookie: [] + description: Returns a single Player Moderation. This returns the exact same amount of information as the more generalised `getPlayerModerations`. + delete: + summary: Delete Player Moderation + operationId: deletePlayerModeration + security: + - apiKeyCookie: [] + authCookie: [] + responses: + '200': + $ref: ../responses/PlayerModerationRemovedSuccess.yaml + '401': + $ref: ../responses/MissingCredentialsError.yaml + '403': + $ref: ../responses/PlayerModerationDeleteOthersError.yaml + description: Deletes a specific player moderation based on it's `pmod_` ID. The website uses `unmoderateUser` instead. You can delete the same player moderation multiple times successfully. + tags: + - playermoderation + parameters: + - schema: + type: string + name: playerModerationId + in: path + required: true +tags: + $ref: ../../openapi.yaml#/tags +components: + securitySchemes: + $ref: ../../openapi.yaml#/components/securitySchemes \ No newline at end of file diff --git a/openapi/components/responses/playermoderation/PlayerModerationListResponse.yaml b/openapi/components/responses/playermoderation/PlayerModerationListResponse.yaml new file mode 100644 index 00000000..85d16543 --- /dev/null +++ b/openapi/components/responses/playermoderation/PlayerModerationListResponse.yaml @@ -0,0 +1,7 @@ +description: Returns a list of PlayerModeration objects. +content: + application/json: + schema: + type: array + items: + $ref: ../../schemas/PlayerModeration.yaml \ No newline at end of file diff --git a/openapi/components/responses/playermoderation/PlayerModerationResponse.yaml b/openapi/components/responses/playermoderation/PlayerModerationResponse.yaml new file mode 100644 index 00000000..cfdd2781 --- /dev/null +++ b/openapi/components/responses/playermoderation/PlayerModerationResponse.yaml @@ -0,0 +1,5 @@ +description: Returns a single PlayerModeration object. +content: + application/json: + schema: + $ref: ../../schemas/PlayerModeration.yaml \ No newline at end of file diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index c5a1a731..d76c890b 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -107,149 +107,11 @@ paths: '/avatars/{avatarId}/select': $ref: ./components/paths/avatars.yaml#/paths/~1avatars~1{avatarId}~1select /auth/user/playermoderations: - get: - summary: Search Player Moderations - tags: - - playermoderation - responses: - '200': - $ref: '#/components/responses/PlayerModerationList' - '401': - $ref: ./components/responses/MissingCredentialsError.yaml - operationId: getPlayerModerations - security: - - apiKeyCookie: [] - authCookie: [] - parameters: - - schema: - type: string - in: query - name: type - description: 'Must be one of PlayerModerationType, except unblock. Unblocking simply removes a block.' - - schema: - type: string - in: query - name: sourceUserId - description: Must be valid UserID. Trying to view someone else's moderations results with "Can't view someone else's player moderations" error. - x-internal: true - - schema: - type: string - in: query - name: targetUserId - description: Must be valid UserID. - description: |- - Returns a list of all player moderations made by **you**. - - This endpoint does not have pagination, and will return *all* results. Use query parameters to limit your query if needed. - post: - summary: Moderate User - operationId: moderateUser - security: - - apiKeyCookie: [] - authCookie: [] - responses: - '200': - $ref: '#/components/responses/PlayerModeration' - '401': - $ref: ./components/responses/MissingCredentialsError.yaml - requestBody: - content: - application/json: - schema: - type: object - additionalProperties: false - properties: - moderated: - $ref: ./components/schemas/UserID.yaml - type: - $ref: ./components/schemas/PlayerModerationType.yaml - required: - - moderated - - type - description: '' - description: 'Moderate a user, e.g. unmute them or show their avatar.' - tags: - - playermoderation - delete: - summary: Clear All Player Moderations - operationId: clearAllPlayerModerations - security: - - apiKeyCookie: [] - authCookie: [] - responses: - '200': - $ref: ./components/responses/OkSuccess.yaml - '401': - $ref: ./components/responses/MissingCredentialsError.yaml - description: ⚠️ **This will delete every single player moderation you've ever made.** - tags: - - playermoderation + $ref: ./components/paths/playermoderation.yaml#/paths/~1auth~1user~1playermoderations /auth/user/unplayermoderate: - put: - summary: Unmoderate User - operationId: unmoderateUser - security: - - apiKeyCookie: [] - authCookie: [] - requestBody: - content: - application/json: - schema: - type: object - properties: - moderated: - $ref: ./components/schemas/UserID.yaml - type: - $ref: ./components/schemas/PlayerModerationType.yaml - required: - - type - description: 'Removes a player moderation previously added through `moderateUser`. E.g if you previuosly have shown their avatar, but now want to reset it to default.' - responses: - '200': - $ref: ./components/responses/PlayerModerationUnmoderatedSuccess.yaml - '401': - $ref: ./components/responses/MissingCredentialsError.yaml - tags: - - playermoderation + $ref: ./components/paths/playermoderation.yaml#/paths/~1auth~1user~1unplayermoderate '/auth/user/playermoderations/{playerModerationId}': - get: - summary: Get Player Moderation - tags: - - playermoderation - responses: - '200': - $ref: '#/components/responses/PlayerModeration' - '401': - $ref: ./components/responses/MissingCredentialsError.yaml - '404': - $ref: ./components/responses/PlayerModerationNotFoundError.yaml - operationId: getPlayerModeration - security: - - apiKeyCookie: [] - authCookie: [] - description: Returns a single Player Moderation. This returns the exact same amount of information as the more generalised `getPlayerModerations`. - delete: - summary: Delete Player Moderation - operationId: deletePlayerModeration - security: - - apiKeyCookie: [] - authCookie: [] - responses: - '200': - $ref: ./components/responses/PlayerModerationRemovedSuccess.yaml - '401': - $ref: ./components/responses/MissingCredentialsError.yaml - '403': - $ref: ./components/responses/PlayerModerationDeleteOthersError.yaml - description: Deletes a specific player moderation based on it's `pmod_` ID. The website uses `unmoderateUser` instead. You can delete the same player moderation multiple times successfully. - tags: - - playermoderation - parameters: - - schema: - type: string - name: playerModerationId - in: path - required: true + $ref: ./components/paths/playermoderation.yaml#/paths/~1auth~1user~1playermoderations~1{playerModerationId} /auth/permissions: $ref: ./components/paths/permissions.yaml#/paths/~1auth~1permissions /permissions: @@ -284,20 +146,6 @@ components: in: cookie description: 2FA device remembrance via Cookie responses: - PlayerModerationList: - description: Returns a list of PlayerModeration objects. - content: - application/json: - schema: - type: array - items: - $ref: ./components/schemas/PlayerModeration.yaml - PlayerModeration: - description: Returns a single PlayerModeration object. - content: - application/json: - schema: - $ref: ./components/schemas/PlayerModeration.yaml parameters: number: name: 'n' From 21370b9e97cbb9bb01c2e92cdcd2596c5033818f Mon Sep 17 00:00:00 2001 From: foorack Date: Fri, 3 Sep 2021 23:45:38 +0200 Subject: [PATCH 2/3] Clean up old PlayerModeration responses --- openapi/components/paths/playermoderation.yaml | 8 ++++---- .../PlayerModerationDeleteOthersError.yaml | 2 +- .../PlayerModerationNotFoundError.yaml | 2 +- .../PlayerModerationRemovedSuccess.yaml | 2 +- .../PlayerModerationUnmoderatedSuccess.yaml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename openapi/components/responses/{ => playermoderation}/PlayerModerationDeleteOthersError.yaml (88%) rename openapi/components/responses/{ => playermoderation}/PlayerModerationNotFoundError.yaml (86%) rename openapi/components/responses/{ => playermoderation}/PlayerModerationRemovedSuccess.yaml (86%) rename openapi/components/responses/{ => playermoderation}/PlayerModerationUnmoderatedSuccess.yaml (90%) diff --git a/openapi/components/paths/playermoderation.yaml b/openapi/components/paths/playermoderation.yaml index 18a70ba6..1f78993f 100644 --- a/openapi/components/paths/playermoderation.yaml +++ b/openapi/components/paths/playermoderation.yaml @@ -104,7 +104,7 @@ paths: description: 'Removes a player moderation previously added through `moderateUser`. E.g if you previuosly have shown their avatar, but now want to reset it to default.' responses: '200': - $ref: ../responses/PlayerModerationUnmoderatedSuccess.yaml + $ref: ../responses/playermoderation/PlayerModerationUnmoderatedSuccess.yaml '401': $ref: ../responses/MissingCredentialsError.yaml tags: @@ -120,7 +120,7 @@ paths: '401': $ref: ../responses/MissingCredentialsError.yaml '404': - $ref: ../responses/PlayerModerationNotFoundError.yaml + $ref: ../responses/playermoderation/PlayerModerationNotFoundError.yaml operationId: getPlayerModeration security: - apiKeyCookie: [] @@ -134,11 +134,11 @@ paths: authCookie: [] responses: '200': - $ref: ../responses/PlayerModerationRemovedSuccess.yaml + $ref: ../responses/playermoderation/PlayerModerationRemovedSuccess.yaml '401': $ref: ../responses/MissingCredentialsError.yaml '403': - $ref: ../responses/PlayerModerationDeleteOthersError.yaml + $ref: ../responses/playermoderation/PlayerModerationDeleteOthersError.yaml description: Deletes a specific player moderation based on it's `pmod_` ID. The website uses `unmoderateUser` instead. You can delete the same player moderation multiple times successfully. tags: - playermoderation diff --git a/openapi/components/responses/PlayerModerationDeleteOthersError.yaml b/openapi/components/responses/playermoderation/PlayerModerationDeleteOthersError.yaml similarity index 88% rename from openapi/components/responses/PlayerModerationDeleteOthersError.yaml rename to openapi/components/responses/playermoderation/PlayerModerationDeleteOthersError.yaml index 17a81d13..cdd2cd71 100644 --- a/openapi/components/responses/PlayerModerationDeleteOthersError.yaml +++ b/openapi/components/responses/playermoderation/PlayerModerationDeleteOthersError.yaml @@ -2,7 +2,7 @@ description: Error response when trying to delete someone else's player moderati content: application/json: schema: - $ref: ../schemas/Error.yaml + $ref: ../../schemas/Error.yaml examples: 403 Can't delete Player Moderation You Didn't Create: value: diff --git a/openapi/components/responses/PlayerModerationNotFoundError.yaml b/openapi/components/responses/playermoderation/PlayerModerationNotFoundError.yaml similarity index 86% rename from openapi/components/responses/PlayerModerationNotFoundError.yaml rename to openapi/components/responses/playermoderation/PlayerModerationNotFoundError.yaml index 98b84f86..42c0a894 100644 --- a/openapi/components/responses/PlayerModerationNotFoundError.yaml +++ b/openapi/components/responses/playermoderation/PlayerModerationNotFoundError.yaml @@ -2,7 +2,7 @@ description: Error response when trying to show information about a non-existent content: application/json: schema: - $ref: ../schemas/Error.yaml + $ref: ../../schemas/Error.yaml examples: 404 Player Moderation Not Found: value: diff --git a/openapi/components/responses/PlayerModerationRemovedSuccess.yaml b/openapi/components/responses/playermoderation/PlayerModerationRemovedSuccess.yaml similarity index 86% rename from openapi/components/responses/PlayerModerationRemovedSuccess.yaml rename to openapi/components/responses/playermoderation/PlayerModerationRemovedSuccess.yaml index f7976c0a..50714466 100644 --- a/openapi/components/responses/PlayerModerationRemovedSuccess.yaml +++ b/openapi/components/responses/playermoderation/PlayerModerationRemovedSuccess.yaml @@ -2,7 +2,7 @@ description: Success response after removing a PlayerModeration by ID. content: application/json: schema: - $ref: ../schemas/Error.yaml + $ref: ../../schemas/Success.yaml examples: 200 Player Moderation Removed: value: diff --git a/openapi/components/responses/PlayerModerationUnmoderatedSuccess.yaml b/openapi/components/responses/playermoderation/PlayerModerationUnmoderatedSuccess.yaml similarity index 90% rename from openapi/components/responses/PlayerModerationUnmoderatedSuccess.yaml rename to openapi/components/responses/playermoderation/PlayerModerationUnmoderatedSuccess.yaml index 68a09a15..c2a4a9fe 100644 --- a/openapi/components/responses/PlayerModerationUnmoderatedSuccess.yaml +++ b/openapi/components/responses/playermoderation/PlayerModerationUnmoderatedSuccess.yaml @@ -2,7 +2,7 @@ description: Success response after unmoderating a player moderation. content: application/json: schema: - $ref: ../schemas/Error.yaml + $ref: ../../schemas/Success.yaml examples: 200 Specific User Unmoderated: value: From 65f2e5f820c6616ca48eb6899bc3178c13a5a7cb Mon Sep 17 00:00:00 2001 From: foorack Date: Fri, 3 Sep 2021 23:47:14 +0200 Subject: [PATCH 3/3] lint: responses must be of type object --- openapi/openapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index d76c890b..89cb3abb 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -145,7 +145,7 @@ components: type: apiKey in: cookie description: 2FA device remembrance via Cookie - responses: + responses: {} parameters: number: name: 'n'