algolia / instantsearch-ios

⚡️ A library of widgets and helpers to build instant-search applications on iOS.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/ios/
Apache License 2.0
591 stars 55 forks source link

Add custom JSONDecoder property to HitsInteractor #247

Closed VladislavFitz closed 1 year ago

VladislavFitz commented 1 year ago

Is your feature request related to a problem? Please describe 🙏

Described here. Client wants the Codable model variable names to be in camel case. HitsInteractor supports only the snake case since it uses the default JSONDecoder constructor, so the client might add CodingKeys per model.

Describe the solution you'd like 🤔 Add possibility to set a custom JSONDecoder property to HitsInteractor responsible for search hits decoding.

steffidg commented 1 year ago

@VladislavFitz
I found a minor issue on one of the constructor where the jsonDecoder parameter value is not passed.

  convenience public init(infiniteScrolling: InfiniteScrolling = Constants.Defaults.infiniteScrolling,
                          showItemsOnEmptyQuery: Bool = Constants.Defaults.showItemsOnEmptyQuery,
                          jsonDecoder: JSONDecoder = JSONDecoder()) {
    let settings = Settings(infiniteScrolling: infiniteScrolling,
                            showItemsOnEmptyQuery: showItemsOnEmptyQuery)
    self.init(settings: settings)
    // Expected
    // self.init(settings: settings,  jsonDecoder: jsonDecoder)
  }
VladislavFitz commented 1 year ago

Great catch @steffidg , the fix is on its way 👌