babelshift / SteamWebAPI2

🎮 C# / .NET library that makes it easy to use the Steam Web API. It conveniently wraps around all of the JSON data and ugly API details with clean methods, structures and classes.
MIT License
263 stars 43 forks source link

Error mapping types: PublishedFileDetailsModel.FileUrl #98

Closed oliver4888 closed 4 years ago

oliver4888 commented 4 years ago

I'm using the SteamRemoteStorage interface to get information on a workshop item. It appears that the file_url property is "" which throws a UriFormatException. I have checked a couple of workshop mods and the file_url property is always an empty string, I did check one collection which had a valid url.

I took a quick look and I believe changing the mappings in Mappings/SteamRemoteStorageProfile to something like opts.MapFrom(source => string.IsNullOrWhiteSpace(source.FileUrl) ? null : new Uri(source.FileUrl)) should fix this issue.

Let me know if you'd be interested in a PR, it might be useful to add this check any Uri fields (I see there are two in SteamRemoteStorageProfile and a bunch in SteamProfileProfile.

babelshift commented 4 years ago

Thanks for the catch. I've fixed on commit f7cbdd40f633e4f51cdb040d5046bc90e6610339 and release 4.2.2. I've also added a unit test for this endpoint. Let me know if it works for you.

oliver4888 commented 4 years ago

FileUrl works, looks like a typo got added that causes PreviewUrl to be null if FileUrl is null. source.FileUrl should be source.PreviewUrl on this line: https://github.com/babelshift/SteamWebAPI2/blob/9de9651da9548214121157d28836dcc6e2711738/src/SteamWebAPI2/Mappings/SteamRemoteStorageProfile.cs#L21

babelshift commented 4 years ago

Ugh. That's what I get for rushing a fix late at night. I think you should still be OK for now since the asset you were looking for didn't have a PreviewUrl anyway. I'll get this fixed today.

babelshift commented 4 years ago

Fixed on commit dd037ac8a9522dcec07f510c8ed6a09ca82c23b0 and release 4.2.3.

oliver4888 commented 4 years ago

Working perfectly now. Thanks for the awesome library!