update package name to confirm to csharp convention, fix default header

This commit is contained in:
wing328 2015-05-12 12:45:59 +08:00
parent e7b170bf3c
commit 2f5f2b367b
13 changed files with 146 additions and 20 deletions

View File

@ -7,7 +7,7 @@ import java.util.*;
import java.io.File;
public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String invokerPackage = "io.swagger.client";
protected String invokerPackage = "IO.Swagger.Client";
protected String groupId = "io.swagger";
protected String artifactId = "swagger-csharp-client";
protected String artifactVersion = "1.0.0";
@ -31,8 +31,8 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
modelTemplateFiles.put("model.mustache", ".cs");
apiTemplateFiles.put("api.mustache", ".cs");
templateDir = "csharp";
apiPackage = "io.swagger.Api";
modelPackage = "io.swagger.Model";
apiPackage = "IO.Swagger.Api";
modelPackage = "IO.Swagger.Model";
reservedWords = new HashSet<String> (
Arrays.asList(

View File

@ -52,6 +52,12 @@ namespace {{package}} {
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
{{/required}}{{/allParams}}
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
{{#pathParams}}_request.AddUrlSegment("{{baseName}}", ApiInvoker.ParameterToString({{{paramName}}})); // path (url segment) parameter
{{/pathParams}}

View File

@ -1,2 +1,2 @@
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll /target:library /out:bin/io.swagger.client.dll /recurse:src\*.cs /doc:bin/io.swagger.client.xml
%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll /target:library /out:bin/IO.Swagger.Client.dll /recurse:src\*.cs /doc:bin/IO.Swagger.Client.xml

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using RestSharp;
using io.swagger.client;
using io.swagger.Model;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace io.swagger.Api {
namespace IO.Swagger.Api {
public class PetApi {
string basePath;
@ -46,6 +46,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -80,6 +86,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -114,6 +126,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
if (Status != null) _request.AddParameter("status", ApiInvoker.ParameterToString(Status)); // query parameter
@ -148,6 +166,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
if (Tags != null) _request.AddParameter("tags", ApiInvoker.ParameterToString(Tags)); // query parameter
@ -185,6 +209,12 @@ namespace io.swagger.Api {
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling GetPetById");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@ -224,6 +254,12 @@ namespace io.swagger.Api {
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UpdatePetWithForm");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@ -264,6 +300,12 @@ namespace io.swagger.Api {
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling DeletePet");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter
@ -304,6 +346,12 @@ namespace io.swagger.Api {
if (PetId == null) throw new ApiException(400, "Missing required parameter 'PetId' when calling UploadFile");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("petId", ApiInvoker.ParameterToString(PetId)); // path (url segment) parameter

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using RestSharp;
using io.swagger.client;
using io.swagger.Model;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace io.swagger.Api {
namespace IO.Swagger.Api {
public class StoreApi {
string basePath;
@ -45,6 +45,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -78,6 +84,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -115,6 +127,12 @@ namespace io.swagger.Api {
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling GetOrderById");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter
@ -152,6 +170,12 @@ namespace io.swagger.Api {
if (OrderId == null) throw new ApiException(400, "Missing required parameter 'OrderId' when calling DeleteOrder");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("orderId", ApiInvoker.ParameterToString(OrderId)); // path (url segment) parameter

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using RestSharp;
using io.swagger.client;
using io.swagger.Model;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace io.swagger.Api {
namespace IO.Swagger.Api {
public class UserApi {
string basePath;
@ -46,6 +46,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -80,6 +86,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -114,6 +126,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -149,6 +167,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
if (Username != null) _request.AddParameter("username", ApiInvoker.ParameterToString(Username)); // query parameter
@ -183,6 +207,12 @@ namespace io.swagger.Api {
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
@ -219,6 +249,12 @@ namespace io.swagger.Api {
if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling GetUserByName");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter
@ -257,6 +293,12 @@ namespace io.swagger.Api {
if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling UpdateUser");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter
@ -295,6 +337,12 @@ namespace io.swagger.Api {
if (Username == null) throw new ApiException(400, "Missing required parameter 'Username' when calling DeleteUser");
// add default header, if any
foreach(KeyValuePair<string, string> defaultHeader in ApiInvoker.GetDefaultHeader())
{
_request.AddHeader(defaultHeader.Key, defaultHeader.Value);
}
_request.AddUrlSegment("format", "json"); // set format to json by default
_request.AddUrlSegment("username", ApiInvoker.ParameterToString(Username)); // path (url segment) parameter

View File

@ -4,7 +4,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace io.swagger.Model {
namespace IO.Swagger.Model {
[DataContract]
public class Category {

View File

@ -4,7 +4,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace io.swagger.Model {
namespace IO.Swagger.Model {
[DataContract]
public class Order {

View File

@ -4,7 +4,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace io.swagger.Model {
namespace IO.Swagger.Model {
[DataContract]
public class Pet {

View File

@ -4,7 +4,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace io.swagger.Model {
namespace IO.Swagger.Model {
[DataContract]
public class Tag {

View File

@ -4,7 +4,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace io.swagger.Model {
namespace IO.Swagger.Model {
[DataContract]
public class User {

View File

@ -1,6 +1,6 @@
using System;
namespace io.swagger.client {
namespace IO.Swagger.Client {
public class ApiException : Exception {
private int errorCode = 0;

View File

@ -6,7 +6,7 @@ using System.Net;
using System.Text;
using Newtonsoft.Json;
namespace io.swagger.client {
namespace IO.Swagger.Client {
public class ApiInvoker {
private static Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>();