realworld icon indicating copy to clipboard operation
realworld copied to clipboard

User Registration endpoint inconsistent in docs / swagger / Postman collection

Open mdhender opened this issue 4 years ago • 3 comments

In realworld/api/README.md, Registration is "POST /api/users."

In realworld/api/Conduit.postman_collection.json, the test is "raw": "{{APIURL}}/users" and path is ["users"].

In realworld/api/swagger.json, the operation to "Register a new user" is in the entry for "user": "post."

It looks like #612 changed the Swagger from "users" to "user."

mdhender avatar Mar 27 '21 15:03 mdhender

I think there's intentionally a subtle difference and some endpoints are meant to be "users" and some "user".

image

JCass149 avatar Apr 11 '21 21:04 JCass149

Oh I think I see the issue now. Whilst #612 fixed GET /user and PUT /user it broke POST /users (which should be POST /users, not POST /user). Is that correct?

Perhaps the swagger.json should be:

"/users/login": {
      "post": {
        "summary": "Existing user login",
        "description": "Login for existing user",
        "tags": [
          "User and Authentication"
        ],
        "operationId": "Login",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "description": "Credentials to use",
            "schema": {
              "$ref": "#/definitions/LoginUserRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/UserResponse"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "422": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/GenericErrorModel"
            }
          }
        }
      }
    },
    "/users": {
      "post": {
        "summary": "Register a new user",
        "description": "Register a new user",
        "tags": [
          "User and Authentication"
        ],
        "operationId": "CreateUser",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "description": "Details of the new user to register",
            "schema": {
              "$ref": "#/definitions/NewUserRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/UserResponse"
            }
          },
          "422": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/GenericErrorModel"
            }
          }
        }
      }
    },
    "/user": {
      "get": {
        "summary": "Get current user",
        "description": "Gets the currently logged-in user",
        "tags": [
          "User and Authentication"
        ],
        "security": [
          {
            "Token": []
          }
        ],
        "operationId": "GetCurrentUser",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/UserResponse"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "422": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/GenericErrorModel"
            }
          }
        }
      },
      "put": {
        "summary": "Update current user",
        "description": "Updated user information for current user",
        "tags": [
          "User and Authentication"
        ],
        "security": [
          {
            "Token": []
          }
        ],
        "operationId": "UpdateCurrentUser",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "description": "User details to update. At least **one** field is required.",
            "schema": {
              "$ref": "#/definitions/UpdateUserRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/UserResponse"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "422": {
            "description": "Unexpected error",
            "schema": {
              "$ref": "#/definitions/GenericErrorModel"
            }
          }
        }
      }
    }

JCass149 avatar Apr 11 '21 21:04 JCass149

I think that is correct.

mdhender avatar Apr 12 '21 18:04 mdhender