Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

User Registration endpoint inconsistent in docs / swagger / Postman collection #626

Open
mdhender opened this issue Mar 27, 2021 · 3 comments
Labels
Status: Approved approved for next version v2 changelog

Comments

@mdhender
Copy link

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."

@JCass149
Copy link
Contributor

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

image

@JCass149
Copy link
Contributor

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/#": {
      "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/#UserRequest"
            }
          }
        ],
        "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"
            }
          }
        }
      }
    }

@mdhender
Copy link
Author

I think that is correct.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Status: Approved approved for next version v2 changelog
Projects
None yet
Development

No branches or pull requests

3 participants