-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value cannot be null exception #288
Comments
I see the issue seems caused by operation.parameters. If this one is null, then the error will throw out. however, I have no idea why this one could be null. |
Does the id parameter actually exist on the corresponding method signature? The swagger spec does not allow an empty parameters collection - if there are no parameters, then the parameters property should be omitted altogether. So, if an action accepts no parameters, then operation.parameters will be null. This could be causing your issue and if so you can resolve by simply removing the param node from your XML comments (which makes sense if the param doesn't actually exist). With all that said, SB should handle this a bit more gracefully - so I'll keep the issue open so I remember to address it when I get the chance. Richie |
Thanks, Richie. You're right. The parameter didn't exist on the corresponding method signature. After removing it, SB works fine now. Great thanks! |
I also discovered this bug. #293 is a pull request to fix it. |
Should be resolved in latest release - 5.2.0 |
Hi, I have an issue with the c.IncludeXmlComments()
I am using my own comments, however, the swachbuckle throw out the exception in below function.
private static void ApplyParamComments(Operation operation, XPathNavigator methodNode)
{
var paramNodes = methodNode.Select(ParameterExpression);
while (paramNodes.MoveNext())
{
var paramNode = paramNodes.Current;
var parameter =
operation.parameters.SingleOrDefault(param => param.name == paramNode.GetAttribute("name", ""));
if (parameter != null)
parameter.description = paramNode.Value.Trim();
}
}
Exception message is:
Value cannot be null. Parameter name: source
The XML of the paramNodes which throws the exception is like below:
<member name="getData">
<summary>
get resource data
</summary>
<param name="id">id</param>
<returns></returns>
</member>
Could some one help with this problem?
Thanks!
The text was updated successfully, but these errors were encountered: