Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Since #2751325: All serialized values are strings, should be integers/booleans when appropriate has landed, but the output from JSONAPI still has Integer serialized as String. Below are steps to reproduce:
1. Fresh install Drupal 8.3.0-rc1
2. Download and Enable jsonapi module
3. Create an article at node/1
4. Access it from JSONAPI
curl -X GET -H "Cache-Control: no-cache" “***********/jsonapi/node/article?_format=api_json"
The result has "nid", "vid", and "promoted" values in String
Comment | File | Size | Author |
---|---|---|---|
#10 | 2858023-10.patch | 982 bytes | Wim Leers |
Comments
Comment #2
skyredwangComment #3
skyredwangComment #4
dawehnerLet's see what happens.
Comment #5
Wim LeersThis is why we need the JSON API test coverage to expand significantly.
Comment #6
e0ipsoI don't think that would have helped here, but I would love to see the test coverage increase.
Comment #7
e0ipso@skyredwang can we have testing for this? :-D
Comment #8
skyredwangI manually tested #4 patch, it works.
I don't know how to write automated tests in Drupal 8 yet. There is a big gap between https://phpunit.de/getting-started.html and https://www.drupal.org/docs/8/phpunit . I haven't got time to figure it out. Maybe one day, someone will write a simple PHPunit test for Drupal 8 tutorial or point me to one, then, I can get started on writing automated tests.
Comment #9
Wim Leers#6: it would have. See how #2751325: All serialized values are strings, should be integers/booleans when appropriate was forced to update functional test coverage. Functional tests assert the response bodies and hence would've covered this.
Comment #10
Wim LeersBTW, I'm not saying we should block committing this on adding test coverage. The existing JSON API test coverage focuses not on concrete serializations/normalizations, so it makes sense that this patch is not causing any tests to fail.
I do think #4 should get the same comment as #2751325: All serialized values are strings, should be integers/booleans when appropriate added to
\Drupal\hal\Normalizer\FieldItemNormalizer::normalize()
.Comment #12
Wim LeersI only added comments. How could this possibly fail? :O
Oh, wait. Due to a change in Drupal 8.4, JSON API HEAD is just failing on 8.4.x. See #2855693-21: Remove \Drupal\jsonapi\Controller\RequestHandler::renderJsonApiResponse(), add \Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber for the solution.
Comment #13
skyredwangComment #15
e0ipsoThanks all. This is committed and it's going to be the HEAD of our new beta release!!
Comment #16
Wim LeersYay!