Skip to content

Problem is that nswag client code generation from open api specification or swagger generates classes without generics. This tool can be used afterwards to make classes generic again

Notifications You must be signed in to change notification settings

fgilde/MakeGenericAgain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MakeGenericAgain

Problem is that nswag client code generation from open api specification or swagger generates classes without generics. This tool can be used afterwards to make classes generic again

More infos about the general problem can be found here

To install it on other projects, add this to the csproj:

  <Target Name="MakeGenericAgain" AfterTargets="NSwag" Condition="'$(Configuration)' == 'Debug'">
    <Exec IgnoreExitCode="true" Command="dotnet tool install --global makeGenericAgain" />
    <Exec Command="makeGenericAgain -f $(SolutionDir)src\SDK\Net\v1\ClientGenerated.cs" />
  </Target>

You can optionally provide names of types to ignore (should include any type names containing the word 'Of' as a minimum)

  <Target Name="MakeGenericAgain" AfterTargets="NSwag" Condition="'$(Configuration)' == 'Debug'">
    <Exec IgnoreExitCode="true" Command="dotnet tool install --global makeGenericAgain" />
    <Exec Command="makeGenericAgain -f $(SolutionDir)src\SDK\Net\v1\ClientGenerated.cs -i IgnorableOfType,AnotherOfIgnorable" />
  </Target>

To run int use

 makeGenericAgain -f "C:\Path\client.cs"

Or with ignorable type names

 makeGenericAgain -f "C:\Path\client.cs" -i "IgnorableOfType,AnotherOfIgnorable"

Also you can specify specific output file with -o

 makeGenericAgain -f "C:\Path\client.cs" -i "IgnorableOfType,AnotherOfIgnorable" -o "C:\Path\client_with_generics.cs"

Links

Github Repository | Nuget Package

About

Problem is that nswag client code generation from open api specification or swagger generates classes without generics. This tool can be used afterwards to make classes generic again

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages