-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Using generics in response causing invalid swagger.json #2661
Comments
Hi, try config |
Do you mind explaining that a bit more? I'm not sure how im supposed to reference my class in that. |
It says the |
Hi. any updates on that issue? It seems that either return type or properties in DTOs defined as generic have the same issue - meaning that generated name in openapi definition contains full assembly name as it is mentioned in the original post. |
@scphantm the problem is that you are probably using the extensionMethod CustomSchemaIds when using SB. I had this issue to, because by default we were doing: options.CustomSchemaIds(x => x.FullName) I had to change it to: options.CustomSchemaIds(x =>
{
var arguments = x.GetGenericArguments();
if (arguments.Length > 0)
{
var result = $"{x.FullName.Split('`').First()}{arguments.Select(genericArg => genericArg.Name).Aggregate((previous, current) => previous + current)}";
return result;
}
return x.FullName;
}) In case this solves your issue please close it |
@martincostello I think the issue is related to the CustomsIds. There is no response from the author but SB will not do this behaviour by default. |
we are using the latest version of swashbuckle.
I have this class
We use this class all over the place in our 200 responses back to the javascript front end. We never had a problem before, everything on the application side works perfectly, has for a long time and still works. But, we are in the process of importing our services into an APIM and realized for the first time that for some reason, that class causes json key names to be invalid.
Whenever we put that class into our http definition like this
When swagger translates the
ListModel<VendorReportModel>
in the json to the schema, it generates a key name that looks like this"bla.bla.ListModel'1[[bla.bla.VendorReportModel, bla.CommonVendorProfileLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"
which generates the error message
we tried to drop the annotation, but, if the method is defined like this
The response is the same. we have been working on this for days now and got nothing. Anyone have any ideas for me here?
The text was updated successfully, but these errors were encountered: