dotarj / PartialResponse

PartialResponse provides JSON partial response (partial resource) support for ASP.NET Web API.
Other
57 stars 26 forks source link

WebApi.PartialResponse throwing exception when using Microsoft.AspNet.WebApi.HelpPage #12

Closed jmm13 closed 6 years ago

jmm13 commented 6 years ago

Hi-

I recently installed WebApi.PartialReponse and everything was working great until I noticed an error on the help pages that are generated via Microsoft.AspNet.WebApi.HelpPage.

If I leave the config set as: GlobalConfiguration.Configuration.Formatters.Add(new JsonMediaTypeFormatter()); it generates the response format samples as expected: Sample: { "method": "200.8", "context": "USEPA", "desc": "Metals in Waters by ICP/MS" }

However, when I change the config so partial responses actually work: GlobalConfiguration.Configuration.Formatters.Add(new PartialJsonMediaTypeFormatter() {IgnoreCase = true });

I get the following error message when it tries to create the sample response:

An exception has occurred while using the formatter 'PartialJsonMediaTypeFormatter' to generate sample for media type 'application/json'. Exception message: Value cannot be null. Parameter name: request

It generates another, similar message for media type 'text/json' as well.

It seems like the helpfile stuff isn't recognized the PartialJsonMediaTypeFormatter as JSON, and I'm not sure if that's on their end or if there's some way to force it in the configuration. Thanks!

dotarj commented 6 years ago

Hi, I was able to reproduce the issue you described and the problem seems to be in the PartialResponse library. I will probably push an updated version of the library in the next week. I'll keep you posted.

jmm13 commented 6 years ago

Has the NuGet package for this been updated? Mine is still showing 0.1.4. Apologies if i'm doing this wrong, still trying to wrap my head around nuget/github/etc.

dotarj commented 6 years ago

I have some trouble getting code signing to work using the dotnet CLI tool. I think I'll release a beta version without code signing so you can update the package. A signed version will be made available when the code signing issue is resolved.

dotarj commented 6 years ago

Hi @jmm13, I've pushed a new version of the nuget package containing the fix: https://www.nuget.org/packages/WebApi.PartialResponse/1.0.0-beta1. Be sure to check the include prerelease checkbox when installing the update. You might need to uninstall the old version first. Please let me know if you run into any issues.

jmm13 commented 6 years ago

Updated to the pre-release, and now it can't find PartialResponse.Net.Http nor PartialJsonMediaTypeFormatter. I don't think i'm missing any dependencies, but I could be wrong. Did the namespace of the formatter change?

dotarj commented 6 years ago

The namespaces are the same. I’ve had similar issues, possibly because signing is removed. I’m not sure. Uninstalling and reinstalling solved the issue.

jmm13 commented 6 years ago

Weird. I've uninstalled 4-5 times now and still can't seem to find it. Even tried a dotnet restore in the package manager console to see if that would fix any missing dependencies. Still no dice. The strange thing is that PartialResponse shows up in the project's references, I just can't reference it in code at all.

Guess I'll wait til an official signed version is out and try again. Thanks!

jmm13 commented 6 years ago

One more thing- looked at Partialresponse in the object browser. Other projects i can navigate and see the methods within the namespace, but for PartialResponse i can't. image

Perhaps a versioning issue? My project targets .NET 4.5.2...

dotarj commented 6 years ago

Hi @jmm13, thanks for the extra info. You are right, something went wrong with the creation of the package. I've created a new version: https://www.nuget.org/packages/WebApi.PartialResponse/1.0.0-beta2. Sorry for the inconvenience.

jmm13 commented 6 years ago

That did it!! Thanks so much for the help and supporting this!