Skip to content

Commit

Permalink
CsharpDotNet2Client - Use clientPackage in additionalProperties (#6581)
Browse files Browse the repository at this point in the history
* CsharpDotNet2Client - Use clientPackage in additionalProperties if provided

* Give execution rights for csharp-dotnet2-petstore.sh

* Fix generation of C#.net2 apiPackage, modelPackage, clientPackage

* Fix modelPackage property missing when generating models

* Initialize clientPackage in constructor
  • Loading branch information
pierredeman authored and wing328 committed Oct 3, 2017
1 parent 1896e96 commit 74e3169
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 130 deletions.
Empty file modified bin/csharp-dotnet2-petstore.sh
100644 → 100755
Empty file.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
package io.swagger.codegen.languages;

import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.codegen.CliOption;

import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

public class CsharpDotNet2ClientCodegen extends AbstractCSharpCodegen {
public static final String CLIENT_PACKAGE = "clientPackage";
protected String clientPackage = "IO.Swagger.Client";
protected String apiDocPath = "docs/";
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";

public CsharpDotNet2ClientCodegen() {
Expand All @@ -33,8 +23,9 @@ public CsharpDotNet2ClientCodegen() {
modelTemplateFiles.put("model.mustache", ".cs");
apiTemplateFiles.put("api.mustache", ".cs");

setApiPackage("IO.Swagger.Api");
setModelPackage("IO.Swagger.Model");
setApiPackage(packageName + ".Api");
setModelPackage(packageName + ".Model");
setClientPackage(packageName + ".Client");
setSourceFolder("src" + File.separator + "main" + File.separator + this.getName());

modelDocTemplateFiles.put("model_doc.mustache", ".md");
Expand All @@ -57,7 +48,7 @@ public void processOpts() {
super.processOpts();

if (additionalProperties.containsKey(CLIENT_PACKAGE)) {
this.setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
} else {
additionalProperties.put(CLIENT_PACKAGE, getClientPackage());
}
Expand Down Expand Up @@ -90,8 +81,8 @@ public String modelPackage() {
return packageName + ".Model";
}

public String getClientPackage(){
return packageName + ".Client";
public String getClientPackage() {
return clientPackage;
}

public void setClientPackage(String clientPackage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using Newtonsoft.Json;
using RestSharp;
using RestSharp.Extensions;

namespace {{packageName}}.Client
namespace {{clientPackage}}
{
/// <summary>
/// API client is mainly responible for making the HTTP call to the API backend.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace {{packageName}}.Client {
namespace {{clientPackage}} {
/// <summary>
/// API Exception
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using System.IO;
using System.Linq;
using System.Text;

namespace {{packageName}}.Client
namespace {{clientPackage}}
{
/// <summary>
/// Represents a set of configuration settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ Run the following command to generate the DLL

Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
```csharp
using {{packageName}}.{{apiPackage}};
using {{packageName}}.Client;
using {{packageName}}.{{modelPackage}};
using {{apiPackage}};
using {{clientPackage}};
using {{modelPackage}};
```
<a name="getting-started"></a>
## Getting Started
Expand All @@ -52,7 +52,7 @@ using {{packageName}}.{{modelPackage}};
using System;
using System.Diagnostics;
using {{apiPackage}};
using {{packageName}}.Client;
using {{clientPackage}};
using {{modelPackage}};

namespace Example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using RestSharp;
using {{packageName}}.Client;
{{#hasImport}}using {{packageName}}.Model;
using {{clientPackage}};
{{#hasImport}}using {{modelPackage}};
{{/hasImport}}

namespace {{packageName}}.Api
namespace {{apiPackage}}
{
{{#operations}}
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# {{packageName}}.{{apiPackage}}.{{classname}}{{#description}}
# {{apiPackage}}.{{classname}}{{#description}}
{{description}}{{/description}}

All URIs are relative to *{{{basePath}}}*
Expand All @@ -22,8 +22,8 @@ Method | HTTP request | Description
```csharp
using System;
using System.Diagnostics;
using {{packageName}}.Api;
using {{packageName}}.Client;
using {{apiPackage}};
using {{clientPackage}};
using {{modelPackage}};

namespace Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Newtonsoft.Json;

{{#models}}
{{#model}}
namespace {{packageName}}.Model {
namespace {{modelPackage}} {
/// <summary>
/// {{description}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#models}}
{{#model}}
# {{{packageName}}}.Model.{{{classname}}}
# {{{modelPackage}}}.{{{classname}}}
## Properties

Name | Type | Description | Notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ Run the following command to generate the DLL

Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
```csharp
using IO.Swagger.IO.Swagger.Api;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.IO.Swagger.Model;
using IO.Swagger.Model;
```
<a name="getting-started"></a>
## Getting Started
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IO.Swagger..PetApi
# IO.Swagger.Api.PetApi

All URIs are relative to *http://petstore.swagger.io/v2*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IO.Swagger..StoreApi
# IO.Swagger.Api.StoreApi

All URIs are relative to *http://petstore.swagger.io/v2*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# IO.Swagger..UserApi
# IO.Swagger.Api.UserApi

All URIs are relative to *http://petstore.swagger.io/v2*

Expand Down

0 comments on commit 74e3169

Please sign in to comment.