jsonapi-rb / jsonapi-parser

Validate JSON API documents.
http://jsonapi-rb.org
MIT License
27 stars 10 forks source link

fix top-level resource optional id & add test cases for type/id requirements #13

Open nruth opened 6 years ago

nruth commented 6 years ago

on client requesting to create a resource on the server

This happened after seeing https://github.com/jsonapi-rb/jsonapi-deserializable/issues/21 and trying to figure out whether I can use that or not (after having false starts with a lot of ruby json-api libraries).

The code was already structured to handle the optional top-level id, it just seems be wired up wrong and was missing a test case. This will need a review as I'm not 100% sure of what the spec says, especially about the case where the top-level is an array of resource objects rather than a single one. I think this makes sense, but it might be wrong.

codecov-io commented 6 years ago

Codecov Report

Merging #13 into master will increase coverage by 0.84%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
+ Coverage   80.67%   81.51%   +0.84%     
==========================================
  Files           5        5              
  Lines         119      119              
==========================================
+ Hits           96       97       +1     
+ Misses         23       22       -1
Impacted Files Coverage Δ
lib/jsonapi/parser/document.rb 84.26% <100%> (+1.12%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1ab3d35...4625478. Read the comment docs.