readium / r2-shared-swift

BSD 3-Clause "New" or "Revised" License
10 stars 41 forks source link

Links parsing inside a collection is broken #18

Closed ghost closed 6 years ago

ghost commented 6 years ago

OPDS 2 parser throws OPDS2ParserError.invalidCollection with this links key:

fb_json.png

llemeurfr commented 6 years ago

I suppose that series links are not yet in our model. if it is the case, the parser should not choke when seeing unknown structures.

HadrienGardeur commented 6 years ago

@llemeurfr that's not the case, series are part of the current model: https://github.com/readium/r2-shared-swift/blob/master/r2-shared-swift/BelongsTo.swift#L13

ghost commented 6 years ago

If you take a look at the related parser code, you will see that the JSON value called v is getting casted to [[String: Any]].

This is where it fails, only a cast to [String: Any] could be successful with the provided JSON.

This snippet works with the feed used in this issue:

case "links":
  guard let link = v as? [String: Any] else {
    throw OPDS2ParserError.invalidCollection
  }
  c.links.append(try parseLink(linkDict: link))

So, my question is: does the JSON links key above could have multiple link entry?

HadrienGardeur commented 6 years ago

This is probably an error on the preprod catalog since links should always be an array.

ghost commented 6 years ago

I close this one since it was an issue due to the feed itself.