brandonchinn178 / aeson-schemas

Easily consume JSON data on-demand with type-safety
http://hackage.haskell.org/package/aeson-schemas
BSD 3-Clause "New" or "Revised" License
53 stars 1 forks source link

Fix referencing a schema using a non-imported type #49

Closed brandon-leapyear closed 4 years ago

brandon-leapyear commented 4 years ago

:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:


44 broke the use-case where a schema uses an imported scalar type in module A, which is included in a schema in module B:

-- module A
import Foo.Bar (Foo)

type MySchema = [schema| { foo: Foo } |]

-- module B
-- does NOT import Foo.Bar

type MySchema2 = [schema| { a: #MySchema } |]

This broke because we now completely reify included schemas as if the schema were defined inline.

This PR adds a NameLike feature where SchemaScalars can be either a String (referencing a type that must be imported) or a Name which is persisted after reifying a SchemaScalar.

codecov-commenter commented 4 years ago

Codecov Report

Merging #49 into master will increase coverage by 0.13%. The diff coverage is 95.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
+ Coverage   87.36%   87.50%   +0.13%     
==========================================
  Files          12       12              
  Lines         451      456       +5     
  Branches       17       17              
==========================================
+ Hits          394      399       +5     
  Misses         50       50              
  Partials        7        7              
Impacted Files Coverage Δ
src/Data/Aeson/Schema/TH/Utils.hs 69.66% <92.85%> (+0.69%) :arrow_up:
src/Data/Aeson/Schema/TH/Schema.hs 92.59% <100.00%> (ø)
src/Data/Aeson/Schema/Type.hs 93.10% <100.00%> (+0.79%) :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 b83f61e...0448f9d. Read the comment docs.