Omertron / api-omdb

API for the Open Movie Database
GNU General Public License v3.0
27 stars 20 forks source link

Documentation leak #14

Open trickert76 opened 5 years ago

trickert76 commented 5 years ago

Hi,

your API has a little documentation leak. I need several times to understand, when I make a OmdbAPI.search request with a OmbdBuilder.setTitle() parameter, the api-omdb-search doesn't return any results, because it makes a call to omdbapi.com/?t=... instead of omdbapi.com/?s=...

The reason is - the search() method wants to create a List of OmdbVideoBasic objects inside a SearchResult, but the builder produces a query with "t" Title - and then OmdbApi.com only returns one entry. And then the JSON Mapper doesn't match (matching an SearchResult entry to SearchResult) and the result is ok, but empty (List==null). I found a lot of AbstractJsonMapper trace log messages, that the JSON data couldnt be mapped...

So - either add an example to the documentation so that the search should only be used with OmdbBuilder.setSearchTerm() and never use OmdbBuilder.setTitle() in a search or make the builder/parser more robust against this issue.

trickert76 commented 5 years ago

Example:

This will never work, but makes no error nor message about wrong usage.

OmdbBuilder builder = getOmdbBuilder(); builder = builder.setTitle(mytitle); SearchResults r = omdb.search(builder.build());

This works. OmdbBuilder builder = getOmdbBuilder(); builder = builder.setSearchTerm(mytitle); SearchResults r = omdb.search(builder.build());