Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[API] Users documentation specs doesn't match application results. #5493

Closed
skafandri opened this issue Jul 12, 2016 · 4 comments
Closed

[API] Users documentation specs doesn't match application results. #5493

skafandri opened this issue Jul 12, 2016 · 4 comments
Labels
Stale Issues and PRs with no recent activity, about to be closed soon.

Comments

@skafandri
Copy link

skafandri commented Jul 12, 2016

I am not sure if I am using the Users API correctly, I am following the Users API examples.

First, I installed Sylius Standard

Cloned Sylius/Sylius-Standard at v0.18.0 (ab01de007ea51c60130c001c650c635ae9e4343d)
composer install
app/console sylius:install
app/console sylius:install:sample-data
php app/console sylius:oauth-server:create-client \
--grant-type="password" --grant-type="refresh_token" --grant-type="token"
curl http://127.0.0.1:8000/oauth/v2/token -d "client_id"=id \
-d "client_secret"=secret -d "grant_type"=password -d "username"=api@example.com \
-d "password"=api 
#I get a token

Index of all users

curl http://127.0.0.1:8000/app_dev.php/api/users/  -H "Authorization: Bearer TOKEN"

This returns the following format:

{
  //Pagination
  },
  "_embedded": {
    "items": [
      {
        "id": 18,
        "username": "api@example.com",
        "username_canonical": "api@example.com",
        "roles": [
          "ROLE_API_ACCESS"
        ],
        "enabled": true
      }
    ]
  }
}

However the expected format of the embedded item from the documentation looks like:

{
  "credentials_expired": false,
  "email": "chelsie.witting@example.com",
  "email_canonical": "chelsie.witting@example.com",
  "enabled": true,
  "expired": false,
  "groups": [],
  "id": 481,
  "locked": false,
  "password": "EbOLtGHYxJKotA+...",
  "roles": [],
  "salt": "h9ltmmawvdsk08oocogkws4sg040k04",
  "username": "chelsie.witting@example.com",
  "username_canonical": "chelsie.witting@example.com"
}

Getting a single user The same Item format difference

Create a user

curl -X POST  http://127.0.0.1:8000/app_dev.php/api/users/ -d "firstName=first1" -d "lastName=last1" -d "email=email1@example.com" -d "plainPassword=password1"  -H "Authorization: Bearer TOKEN"

Result:

{
  "code": 400,
  "message": "Validation Failed",
  "errors": {
    "errors": [
      "This form should not contain extra fields."
    ],
    "children": {
      "plainPassword": {},
      "enabled": {},
      "authorizationRoles": {
        "children": {
        }
      }
    }
  }
}

I looked at Sylius\Bundle\CoreBundle\Form\Type\UserType and it confirmed the previous error, so I tried the following request providing only plainPassword:

curl -X POST  http://127.0.0.1:8000/app_dev.php/api/users/ -d "plainPassword=password1"  -H "Authorization: Bearer TOKEN"

Which oddly passes validation and causes a DbalException

{
  "code": 500,
  "message": "An exception occurred while executing 'INSERT INTO sylius_user (username, username_canonical, enabled, salt, password, last_login, confirmation_token, password_requested_at, locked, expires_at, credentials_expire_at, roles, created_at, updated_at, customer_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [null, null, 0, \"buaorc4j0yokos84gc0s04g004skg4o\", \"bF+DIfgkfp30g\\/lqF6EZHf8Jk2f0VtM+tkz7CzgrxRHpTgtxgbsT5TB8ueY0df62MpkyGEVe7VQcgkDS5UZGDw==\", null, null, null, 0, null, null, \"a:1:{i:0;s:9:\\\"ROLE_USER\\\";}\", \"2016-07-12 09:50:39\", \"2016-07-12 09:50:39\", null]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1048 Column 'customer_id' cannot be null"
}

Delete the logged in user

curl -X DELETE  http://127.0.0.1:8000/app_dev.php/api/users/18 -H "Authorization: Bearer TOKEN"
{"code":500,"message":""}

Deleting another user works correctly.

Thank you in advance for clarifying this.

@lchrusciel
Copy link
Member

This page of documentation is out-of-date. We are doing our best to stabilize Sylius and also put a lot of afford to document all of features (check this out) but it is a tough task. During our work on Sylius API we have introduced a serialization groups to the user object, thats why you have notice a difference. We are not able to keep it up-to-date without help of community.

Are you willing to help us with this? Maybe you have some time to at least upgrade our docs? Or, even maybe you can give a try to our api testing tool and help us with testing?

@skafandri
Copy link
Author

@lchrusciel Thanks for the quick reply.
I am willing to help. I will start testing the API and fix whatever is broken to match the documentation.
I will submit separate PRs for each fix.
Any milestones for 1.0?

@lchrusciel
Copy link
Member

We are preparing ourselves to release an alpha version in a nearest future. After that, beta milestones would be published.

skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
skafandri pushed a commit to skafandri/Sylius that referenced this issue Jul 14, 2016
@stale
Copy link

stale bot commented Dec 4, 2017

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Issues and PRs with no recent activity, about to be closed soon. label Dec 4, 2017
@stale stale bot closed this as completed Dec 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Issues and PRs with no recent activity, about to be closed soon.
Projects
None yet
2 participants