Skip to content

Commit 74cb12f

Browse files
committed
added option to write csproj file on output code
1 parent d8e6554 commit 74cb12f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/main/java/io/swagger/codegen/v3/generators/dotnet/CsharpDotNet2ClientCodegen.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
public class CsharpDotNet2ClientCodegen extends AbstractCSharpCodegen {
1111
public static final String CLIENT_PACKAGE = "clientPackage";
12+
public static final String USE_CSPROJ_FILE = "useCsProjFile";
1213
protected String clientPackage = "IO.Swagger.Client";
1314
protected String apiDocPath = "docs/";
1415
protected String modelDocPath = "docs/";
@@ -68,6 +69,9 @@ public void processOpts() {
6869
supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor", "packages.config"));
6970
supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh"));
7071
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
72+
if (additionalProperties.containsKey(USE_CSPROJ_FILE) && Boolean.parseBoolean(additionalProperties.get(USE_CSPROJ_FILE).toString())) {
73+
supportingFiles.add(new SupportingFile("csproj.mustache", "", clientPackage + ".csproj"));
74+
}
7175

7276
}
7377

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<RootNamespace>{{clientPackage}}</RootNamespace>
6+
</PropertyGroup>
7+
8+
<PropertyGroup>
9+
<!-- Nuget Package Metadata -->
10+
<PackageId>{{packageName}}</PackageId>
11+
<PackageVersion>{{packageVersion}}</PackageVersion>
12+
<Authors>{{packageAuthors}}</Authors>
13+
<Owners>{{packageCompany}}</Owners>
14+
<Title>{{packageTitle}}</Title>
15+
<Description>{{packageDescription}}</Description>
16+
<Copyright>{{packageCopyright}}</Copyright>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
21+
<PackageReference Include="RestSharp" Version="105.0.1" />
22+
</ItemGroup>
23+
</Project>

0 commit comments

Comments
 (0)