Skip to content
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

[C#][.NET 2.0] Use clientPackage in additionalProperties #6581

Merged
merged 6 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Down Expand Up @@ -57,8 +47,9 @@ public void processOpts() {
super.processOpts();

if (additionalProperties.containsKey(CLIENT_PACKAGE)) {
this.setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
setClientPackage((String) additionalProperties.get(CLIENT_PACKAGE));
} else {
setClientPackage(packageName + ".Client");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done in the constructor, or the setClientPackage backed by a field with a default like others? If using this generator manually from code, we'll now have no default unless the user invokes processOpts.

If clientPackage has a sane default in the base type, please ignore. I haven't looked yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, just pushed new commit with initialization in constructor

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