Currently, Swashbuckle handles generic types with the C#-style "TypeName[TypeParam]" nomenclature; however, the included templates in swagger-codegen for basically all languages break when used against a definition containing this.
Generics are not a good idea in a REST scenario, its true, but we have several legacy implementations that we need to describe via Swashbuckle and so handling this should be good. It's possible to just create non-generic types for each one, but that's a tedious process.
I think it would make sense to include some options in Swashbuckle to determine how to name and handle generic types; either an initial configuration option boolean or a function or filter that allows the naming to be controller by the developer.
I'd be happy to create a PR with these changes if you agree with the ideas.
I'm having the same issue.
This is already available. You can provide your own custom strategy for inferring schema Id's for API types. In your case, something along the following lines would work:
// SwaggerConfig.cs
c.SchemaIds(type => type.FriendlyId().Replace("[", "Of").Replace("]", ""));
Didn't see that feature, thanks a bunch! Working great now.
Thanks. Also missed the configuration option.
For people arriving on this page by Google, the syntax is now:
c.CustomSchemaIds(type => type.FriendlyId().Replace("[", "Of").Replace("]", ""));
With Swagger gen5 we are not getting the FriendlyId under type is there any alternative
@dssravi I ran into that, I needed to reference Swashbuckle.Core package directly in my PackageReferences. Found it in the source at https://github.com/domaindrivendev/Swashbuckle/blob/5489aca0d2dd7946f5569341f621f581720d4634/Swashbuckle.Core/Swagger/TypeExtensions.cs
Most helpful comment
For people arriving on this page by Google, the syntax is now: