holyturt / SwiftOverpassWrapper

A wrapper of the Overpass API for Swift.
MIT License
16 stars 2 forks source link

Feature: Make xml parsing publicly available (#14) #15

Closed wtimme closed 6 years ago

wtimme commented 6 years ago

This branch implements #14. It makes the XML parsing available to the public, allowing for it to be used e. g. when parsing OpenStreetMap API responses for /api/0.6/map when retrieving map data by bounding box.

As the XML parsing might encounter errors, e. g. because of malformed data, initializing the response throws an Error to propagate this. I'm not sure whether this is the right approach. Could you have a look, @holyturt? Is there a better solution?

The parsing is somewhat tested, at least the happy flows:

As always, feedback is highly appreciated!

wtimme commented 6 years ago

Thanks for the feedback you provided in #14, @holyturt!

requestQuery and xml, are made for checking actual query and response when the API returns errors but it seems inappropriate for here and is for developers of this project rather than users. I think such properties have to move into Error if they are needed. Therefore they should be removed from OverpassResponse and make the initializer have the response only.

That's a great idea! I've added a custom error to the project that will contain

This should allow for easier debugging of errors, in case a developer is interested in this information.

What do you think of the changes? Is there anything that you feel needs to be done before we can merge this request? Thanks in advance for your feedback!

holyturt commented 6 years ago

LGTM! Thank you for adapting and great codes. 😄 I will merge them!