forked from loafle/openapi-generator-original
rebase with develop_2.0
This commit is contained in:
parent
7383520639
commit
836f7ecb95
@ -19,12 +19,14 @@ fi
|
||||
|
||||
cd $APP_DIR
|
||||
./bin/android-java-petstore.sh
|
||||
./bin/csharp-petstore.sh
|
||||
./bin/dynamic-html.sh
|
||||
./bin/html-petstore.sh
|
||||
./bin/jaxrs-petstore-server.sh
|
||||
./bin/java-petstore.sh
|
||||
./bin/php-petstore.sh
|
||||
./bin/python-petstore.sh
|
||||
./bin/ruby-petstore.sh
|
||||
./bin/objc-petstore.sh
|
||||
./bin/scala-petstore.sh
|
||||
./bin/tizen-petstore.sh
|
||||
|
36
bin/csharp-petstore.sh
Executable file
36
bin/csharp-petstore.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
root=./modules/swagger-codegen-distribution/pom.xml
|
||||
|
||||
# gets version of swagger-codegen
|
||||
version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
|
||||
|
||||
executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l csharp -o samples/client/petstore/csharp"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -0,0 +1,164 @@
|
||||
package com.wordnik.swagger.codegen.languages;
|
||||
|
||||
import com.wordnik.swagger.codegen.*;
|
||||
import com.wordnik.swagger.models.properties.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage = "io.swagger.client";
|
||||
protected String groupId = "io.swagger";
|
||||
protected String artifactId = "swagger-client";
|
||||
protected String artifactVersion = "1.0.0";
|
||||
protected String sourceFolder = "src/main/csharp";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "csharp";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a CSharp client library.";
|
||||
}
|
||||
|
||||
public CSharpClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/csharp";
|
||||
modelTemplateFiles.put("model.mustache", ".cs");
|
||||
apiTemplateFiles.put("api.mustache", ".cs");
|
||||
templateDir = "csharp";
|
||||
apiPackage = "io.swagger.Api";
|
||||
modelPackage = "io.swagger.Model";
|
||||
|
||||
reservedWords = new HashSet<String> (
|
||||
Arrays.asList(
|
||||
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while")
|
||||
);
|
||||
|
||||
additionalProperties.put("invokerPackage", invokerPackage);
|
||||
|
||||
supportingFiles.add(new SupportingFile("apiInvoker.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiInvoker.cs"));
|
||||
supportingFiles.add(new SupportingFile("apiException.mustache",
|
||||
(sourceFolder + File.separator + invokerPackage).replace(".", java.io.File.separator), "ApiException.cs"));
|
||||
supportingFiles.add(new SupportingFile("Newtonsoft.Json.dll", "bin", "Newtonsoft.Json.dll"));
|
||||
supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.cs"));
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"String",
|
||||
"boolean",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Integer",
|
||||
"Long",
|
||||
"Float",
|
||||
"Object")
|
||||
);
|
||||
instantiationTypes.put("array", "List");
|
||||
instantiationTypes.put("map", "Dictionary");
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("boolean", "bool?");
|
||||
typeMapping.put("integer", "int?");
|
||||
typeMapping.put("float", "float?");
|
||||
typeMapping.put("long", "long?");
|
||||
typeMapping.put("double", "double?");
|
||||
typeMapping.put("number", "double?");
|
||||
typeMapping.put("Date", "DateTime");
|
||||
typeMapping.put("file", "byte[]?");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
return name;
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => PetId
|
||||
name = camelize(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||
name = escapeReservedWord(name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// should be the same as variable name
|
||||
return toVarName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if(reservedWords.contains(name))
|
||||
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// should be the same as the model name
|
||||
return toModelName(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Property p) {
|
||||
if(p instanceof ArrayProperty) {
|
||||
ArrayProperty ap = (ArrayProperty) p;
|
||||
Property inner = ap.getItems();
|
||||
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
else if (p instanceof MapProperty) {
|
||||
MapProperty mp = (MapProperty) p;
|
||||
Property inner = mp.getAdditionalProperties();
|
||||
|
||||
return getSwaggerType(p) + "<String, " + getTypeDeclaration(inner) + ">";
|
||||
}
|
||||
return super.getTypeDeclaration(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSwaggerType(Property p) {
|
||||
String swaggerType = super.getSwaggerType(p);
|
||||
String type = null;
|
||||
if(typeMapping.containsKey(swaggerType)) {
|
||||
type = typeMapping.get(swaggerType);
|
||||
if(languageSpecificPrimitives.contains(type))
|
||||
return type;
|
||||
}
|
||||
else
|
||||
type = swaggerType;
|
||||
return type;
|
||||
}
|
||||
}
|
@ -15,3 +15,4 @@ com.wordnik.swagger.codegen.languages.TizenClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.PhpClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.RubyClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.PythonClientCodegen
|
||||
com.wordnik.swagger.codegen.languages.CSharpClientCodegen
|
||||
|
2
samples/client/petstore/csharp/JsonUtil.cs
Normal file
2
samples/client/petstore/csharp/JsonUtil.cs
Normal file
@ -0,0 +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
|
BIN
samples/client/petstore/csharp/Newtonsoft.Json.dll
Normal file
BIN
samples/client/petstore/csharp/Newtonsoft.Json.dll
Normal file
Binary file not shown.
Binary file not shown.
2
samples/client/petstore/csharp/compile.cs
Normal file
2
samples/client/petstore/csharp/compile.cs
Normal file
@ -0,0 +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
|
@ -0,0 +1,461 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using io.swagger.client;
|
||||
using io.swagger.Model;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace io.swagger.Api {
|
||||
|
||||
public class PetApi {
|
||||
string basePath;
|
||||
private readonly ApiInvoker apiInvoker = ApiInvoker.GetInstance();
|
||||
|
||||
public PetApi(String basePath = "http://petstore.swagger.io/v2")
|
||||
{
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
return apiInvoker;
|
||||
}
|
||||
|
||||
// Sets the endpoint base url for the services being accessed
|
||||
public void setBasePath(string basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
// Gets the endpoint base url for the services being accessed
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void updatePet (Pet body) {
|
||||
// create path and map variables
|
||||
var path = "/pet".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, com.wordnik.swagger.codegen.CodegenParameter@7ea4461e, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void addPet (Pet body) {
|
||||
// create path and map variables
|
||||
var path = "/pet".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@52f79c86, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by status Multiple status values can be provided with comma seperated strings
|
||||
/// </summary>
|
||||
/// <param name="status">Status values that need to be considered for filter</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public array<Pet> findPetsByStatus (array<string> status) {
|
||||
// create path and map variables
|
||||
var path = "/pet/findByStatus".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
if (status != null){
|
||||
string paramStr = (status is DateTime) ? ((DateTime)(object)status).ToString("u") : Convert.ToString(status);
|
||||
queryParams.Add("status", paramStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(array<Pet>) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as array<Pet>;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (array<Pet>) ApiInvoker.deserialize(response, typeof(array<Pet>));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
/// </summary>
|
||||
/// <param name="tags">Tags to filter by</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public array<Pet> findPetsByTags (array<string> tags) {
|
||||
// create path and map variables
|
||||
var path = "/pet/findByTags".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
if (tags != null){
|
||||
string paramStr = (tags is DateTime) ? ((DateTime)(object)tags).ToString("u") : Convert.ToString(tags);
|
||||
queryParams.Add("tags", paramStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(array<Pet>) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as array<Pet>;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (array<Pet>) ApiInvoker.deserialize(response, typeof(array<Pet>));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
/// </summary>
|
||||
/// <param name="petId">ID of pet that needs to be fetched</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public Pet getPetById (long? petId) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(Pet) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as Pet;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (Pet) ApiInvoker.deserialize(response, typeof(Pet));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates a pet in the store with form data
|
||||
/// </summary>
|
||||
/// <param name="petId">ID of pet that needs to be updated</param>
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void updatePetWithForm (string petId, string name, string status) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (name != null){
|
||||
if(name is byte[]) {
|
||||
formParams.Add("name", name);
|
||||
} else {
|
||||
string paramStr = (name is DateTime) ? ((DateTime)(object)name).ToString("u") : Convert.ToString(name);
|
||||
formParams.Add("name", paramStr);
|
||||
}
|
||||
}
|
||||
if (status != null){
|
||||
if(status is byte[]) {
|
||||
formParams.Add("status", status);
|
||||
} else {
|
||||
string paramStr = (status is DateTime) ? ((DateTime)(object)status).ToString("u") : Convert.ToString(status);
|
||||
formParams.Add("status", paramStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a pet
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void deletePet (string apiKey, long? petId) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
headerParams.Add("apiKey", apiKey);
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// uploads an image
|
||||
/// </summary>
|
||||
/// <param name="petId">ID of pet to update</param>
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void uploadFile (long? petId, string additionalMetadata, file file) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}/uploadImage".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (additionalMetadata != null){
|
||||
if(additionalMetadata is byte[]) {
|
||||
formParams.Add("additionalMetadata", additionalMetadata);
|
||||
} else {
|
||||
string paramStr = (additionalMetadata is DateTime) ? ((DateTime)(object)additionalMetadata).ToString("u") : Convert.ToString(additionalMetadata);
|
||||
formParams.Add("additionalMetadata", paramStr);
|
||||
}
|
||||
}
|
||||
if (file != null){
|
||||
if(file is byte[]) {
|
||||
formParams.Add("file", file);
|
||||
} else {
|
||||
string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file);
|
||||
formParams.Add("file", paramStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,225 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using io.swagger.client;
|
||||
using io.swagger.Model;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace io.swagger.Api {
|
||||
|
||||
public class StoreApi {
|
||||
string basePath;
|
||||
private readonly ApiInvoker apiInvoker = ApiInvoker.GetInstance();
|
||||
|
||||
public StoreApi(String basePath = "http://petstore.swagger.io/v2")
|
||||
{
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
return apiInvoker;
|
||||
}
|
||||
|
||||
// Sets the endpoint base url for the services being accessed
|
||||
public void setBasePath(string basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
// Gets the endpoint base url for the services being accessed
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
|
||||
/// <returns></returns>
|
||||
public map<String, int?> getInventory () {
|
||||
// create path and map variables
|
||||
var path = "/store/inventory".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(map<String, int?>) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as map<String, int?>;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (map<String, int?>) ApiInvoker.deserialize(response, typeof(map<String, int?>));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public Order placeOrder (Order body) {
|
||||
// create path and map variables
|
||||
var path = "/store/order".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(Order) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as Order;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@13887906, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (Order) ApiInvoker.deserialize(response, typeof(Order));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public Order getOrderById (string orderId) {
|
||||
// create path and map variables
|
||||
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(Order) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as Order;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (Order) ApiInvoker.deserialize(response, typeof(Order));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void deleteOrder (string orderId) {
|
||||
// create path and map variables
|
||||
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,423 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using io.swagger.client;
|
||||
using io.swagger.Model;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace io.swagger.Api {
|
||||
|
||||
public class UserApi {
|
||||
string basePath;
|
||||
private readonly ApiInvoker apiInvoker = ApiInvoker.GetInstance();
|
||||
|
||||
public UserApi(String basePath = "http://petstore.swagger.io/v2")
|
||||
{
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
return apiInvoker;
|
||||
}
|
||||
|
||||
// Sets the endpoint base url for the services being accessed
|
||||
public void setBasePath(string basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
// Gets the endpoint base url for the services being accessed
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void createUser (User body) {
|
||||
// create path and map variables
|
||||
var path = "/user".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@76995893, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void createUsersWithArrayInput (array<User> body) {
|
||||
// create path and map variables
|
||||
var path = "/user/createWithArray".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@4d8657b9, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void createUsersWithListInput (array<User> body) {
|
||||
// create path and map variables
|
||||
var path = "/user/createWithList".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@2ee95a72, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs user into the system
|
||||
/// </summary>
|
||||
/// <param name="username">The user name for login</param>
|
||||
/// <param name="password">The password for login in clear text</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public string loginUser (string username, string password) {
|
||||
// create path and map variables
|
||||
var path = "/user/login".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
if (username != null){
|
||||
string paramStr = (username is DateTime) ? ((DateTime)(object)username).ToString("u") : Convert.ToString(username);
|
||||
queryParams.Add("username", paramStr);
|
||||
}
|
||||
if (password != null){
|
||||
string paramStr = (password is DateTime) ? ((DateTime)(object)password).ToString("u") : Convert.ToString(password);
|
||||
queryParams.Add("password", paramStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(string) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as string;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (string) ApiInvoker.deserialize(response, typeof(string));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
|
||||
/// <returns></returns>
|
||||
public void logoutUser () {
|
||||
// create path and map variables
|
||||
var path = "/user/logout".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get user by user name
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
|
||||
|
||||
/// <returns></returns>
|
||||
public User getUserByName (string username) {
|
||||
// create path and map variables
|
||||
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(User) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as User;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (User) ApiInvoker.deserialize(response, typeof(User));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updated user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void updateUser (string username, User body) {
|
||||
// create path and map variables
|
||||
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, com.wordnik.swagger.codegen.CodegenParameter@5a310a6d, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be deleted</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void deleteUser (string username) {
|
||||
// create path and map variables
|
||||
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.Model {
|
||||
public class Category {
|
||||
|
||||
|
||||
|
||||
public long? id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Category {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" name: ").Append(name).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.Model {
|
||||
public class Order {
|
||||
|
||||
|
||||
|
||||
public long? id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public long? petId { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public int? quantity { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public DateTime shipDate { get; set; }
|
||||
|
||||
|
||||
|
||||
/* Order Status */
|
||||
|
||||
public string status { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public bool? complete { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Order {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" petId: ").Append(petId).Append("\n");
|
||||
|
||||
sb.Append(" quantity: ").Append(quantity).Append("\n");
|
||||
|
||||
sb.Append(" shipDate: ").Append(shipDate).Append("\n");
|
||||
|
||||
sb.Append(" status: ").Append(status).Append("\n");
|
||||
|
||||
sb.Append(" complete: ").Append(complete).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.Model {
|
||||
public class Pet {
|
||||
|
||||
|
||||
|
||||
public long? id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public Category category { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public array<string> photoUrls { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public array<Tag> tags { get; set; }
|
||||
|
||||
|
||||
|
||||
/* pet status in the store */
|
||||
|
||||
public string status { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Pet {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" category: ").Append(category).Append("\n");
|
||||
|
||||
sb.Append(" name: ").Append(name).Append("\n");
|
||||
|
||||
sb.Append(" photoUrls: ").Append(photoUrls).Append("\n");
|
||||
|
||||
sb.Append(" tags: ").Append(tags).Append("\n");
|
||||
|
||||
sb.Append(" status: ").Append(status).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.Model {
|
||||
public class Tag {
|
||||
|
||||
|
||||
|
||||
public long? id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Tag {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" name: ").Append(name).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.Model {
|
||||
public class User {
|
||||
|
||||
|
||||
|
||||
public long? id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string username { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string firstName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string lastName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string email { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string password { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public string phone { get; set; }
|
||||
|
||||
|
||||
|
||||
/* User Status */
|
||||
|
||||
public int? userStatus { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class User {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" username: ").Append(username).Append("\n");
|
||||
|
||||
sb.Append(" firstName: ").Append(firstName).Append("\n");
|
||||
|
||||
sb.Append(" lastName: ").Append(lastName).Append("\n");
|
||||
|
||||
sb.Append(" email: ").Append(email).Append("\n");
|
||||
|
||||
sb.Append(" password: ").Append(password).Append("\n");
|
||||
|
||||
sb.Append(" phone: ").Append(phone).Append("\n");
|
||||
|
||||
sb.Append(" userStatus: ").Append(userStatus).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace io.swagger.client {
|
||||
public class ApiException : Exception {
|
||||
|
||||
private int errorCode = 0;
|
||||
|
||||
public ApiException() {}
|
||||
|
||||
public int ErrorCode {
|
||||
get
|
||||
{
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
public ApiException(int errorCode, string message) : base(message) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,207 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace io.swagger.client {
|
||||
public class ApiInvoker {
|
||||
private static readonly ApiInvoker _instance = new ApiInvoker();
|
||||
private Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
public static ApiInvoker GetInstance() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public void addDefaultHeader(string key, string value) {
|
||||
defaultHeaderMap.Add(key, value);
|
||||
}
|
||||
|
||||
public string escapeString(string str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
public static object deserialize(string json, Type type) {
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject(json, type);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static string serialize(object obj) {
|
||||
try
|
||||
{
|
||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string invokeAPI(string host, string path, string method, Dictionary<String, String> queryParams, object body, Dictionary<String, String> headerParams, Dictionary<String, object> formParams)
|
||||
{
|
||||
return invokeAPIInternal(host, path, method, false, queryParams, body, headerParams, formParams) as string;
|
||||
}
|
||||
|
||||
public byte[] invokeBinaryAPI(string host, string path, string method, Dictionary<String, String> queryParams, object body, Dictionary<String, String> headerParams, Dictionary<String, object> formParams)
|
||||
{
|
||||
return invokeAPIInternal(host, path, method, true, queryParams, body, headerParams, formParams) as byte[];
|
||||
}
|
||||
|
||||
private object invokeAPIInternal(string host, string path, string method, bool binaryResponse, Dictionary<String, String> queryParams, object body, Dictionary<String, String> headerParams, Dictionary<String, object> formParams) {
|
||||
var b = new StringBuilder();
|
||||
|
||||
foreach (var queryParamItem in queryParams)
|
||||
{
|
||||
var value = queryParamItem.Value;
|
||||
if (value == null) continue;
|
||||
b.Append(b.ToString().Length == 0 ? "?" : "&");
|
||||
b.Append(escapeString(queryParamItem.Key)).Append("=").Append(escapeString(value));
|
||||
}
|
||||
|
||||
var querystring = b.ToString();
|
||||
|
||||
host = host.EndsWith("/") ? host.Substring(0, host.Length - 1) : host;
|
||||
|
||||
var client = WebRequest.Create(host + path + querystring);
|
||||
client.Method = method;
|
||||
|
||||
byte[] formData = null;
|
||||
if (formParams.Count > 0)
|
||||
{
|
||||
string formDataBoundary = String.Format("----------{0:N}", Guid.NewGuid());
|
||||
client.ContentType = "multipart/form-data; boundary=" + formDataBoundary;
|
||||
formData = GetMultipartFormData(formParams, formDataBoundary);
|
||||
client.ContentLength = formData.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
client.ContentType = "application/json";
|
||||
}
|
||||
|
||||
foreach (var headerParamsItem in headerParams)
|
||||
{
|
||||
client.Headers.Add(headerParamsItem.Key, headerParamsItem.Value);
|
||||
}
|
||||
foreach (var defaultHeaderMapItem in defaultHeaderMap.Where(defaultHeaderMapItem => !headerParams.ContainsKey(defaultHeaderMapItem.Key)))
|
||||
{
|
||||
client.Headers.Add(defaultHeaderMapItem.Key, defaultHeaderMapItem.Value);
|
||||
}
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case "GET":
|
||||
break;
|
||||
case "POST":
|
||||
case "PUT":
|
||||
case "DELETE":
|
||||
using (Stream requestStream = client.GetRequestStream())
|
||||
{
|
||||
if (formData != null)
|
||||
{
|
||||
requestStream.Write(formData, 0, formData.Length);
|
||||
}
|
||||
|
||||
var swRequestWriter = new StreamWriter(requestStream);
|
||||
swRequestWriter.Write(serialize(body));
|
||||
swRequestWriter.Close();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var webResponse = (HttpWebResponse)client.GetResponse();
|
||||
if (webResponse.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
webResponse.Close();
|
||||
throw new ApiException((int)webResponse.StatusCode, webResponse.StatusDescription);
|
||||
}
|
||||
|
||||
if (binaryResponse)
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
webResponse.GetResponseStream().CopyTo(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var responseReader = new StreamReader(webResponse.GetResponseStream()))
|
||||
{
|
||||
var responseData = responseReader.ReadToEnd();
|
||||
return responseData;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(WebException ex)
|
||||
{
|
||||
var response = ex.Response as HttpWebResponse;
|
||||
int statusCode = 0;
|
||||
if (response != null)
|
||||
{
|
||||
statusCode = (int)response.StatusCode;
|
||||
response.Close();
|
||||
}
|
||||
throw new ApiException(statusCode, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] GetMultipartFormData(Dictionary<string, object> postParameters, string boundary)
|
||||
{
|
||||
Stream formDataStream = new System.IO.MemoryStream();
|
||||
bool needsCLRF = false;
|
||||
|
||||
foreach (var param in postParameters)
|
||||
{
|
||||
// Thanks to feedback from commenters, add a CRLF to allow multiple parameters to be added.
|
||||
// Skip it on the first parameter, add it to subsequent parameters.
|
||||
if (needsCLRF)
|
||||
formDataStream.Write(Encoding.UTF8.GetBytes("\r\n"), 0, Encoding.UTF8.GetByteCount("\r\n"));
|
||||
|
||||
needsCLRF = true;
|
||||
|
||||
if (param.Value is byte[])
|
||||
{
|
||||
string postData = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n",
|
||||
boundary,
|
||||
param.Key,
|
||||
"application/octet-stream");
|
||||
formDataStream.Write(Encoding.UTF8.GetBytes(postData), 0, Encoding.UTF8.GetByteCount(postData));
|
||||
|
||||
// Write the file data directly to the Stream, rather than serializing it to a string.
|
||||
formDataStream.Write((param.Value as byte[]), 0, (param.Value as byte[]).Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
string postData = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}",
|
||||
boundary,
|
||||
param.Key,
|
||||
param.Value);
|
||||
formDataStream.Write(Encoding.UTF8.GetBytes(postData), 0, Encoding.UTF8.GetByteCount(postData));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the end of the request. Start with a newline
|
||||
string footer = "\r\n--" + boundary + "--\r\n";
|
||||
formDataStream.Write(Encoding.UTF8.GetBytes(footer), 0, Encoding.UTF8.GetByteCount(footer));
|
||||
|
||||
// Dump the Stream into a byte[]
|
||||
formDataStream.Position = 0;
|
||||
byte[] formData = new byte[formDataStream.Length];
|
||||
formDataStream.Read(formData, 0, formData.Length);
|
||||
formDataStream.Close();
|
||||
|
||||
return formData;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,459 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using io.swagger.client;
|
||||
using io.swagger.client.model;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace io.swagger.client.api {
|
||||
|
||||
public class PetApi {
|
||||
string basePath;
|
||||
private readonly ApiInvoker apiInvoker = ApiInvoker.GetInstance();
|
||||
|
||||
public PetApi(String basePath = "http://petstore.swagger.io/v2")
|
||||
{
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
return apiInvoker;
|
||||
}
|
||||
|
||||
// Sets the endpoint base url for the services being accessed
|
||||
public void setBasePath(string basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
// Gets the endpoint base url for the services being accessed
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void updatePet (Pet body) {
|
||||
// create path and map variables
|
||||
var path = "/pet".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, com.wordnik.swagger.codegen.CodegenParameter@a1193a9, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void addPet (Pet body) {
|
||||
// create path and map variables
|
||||
var path = "/pet".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@7f54169, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by status Multiple status values can be provided with comma seperated strings
|
||||
/// </summary>
|
||||
/// <param name="status">Status values that need to be considered for filter</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public List<Pet> findPetsByStatus (List<String> status) {
|
||||
// create path and map variables
|
||||
var path = "/pet/findByStatus".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
if (status != null){
|
||||
string paramStr = (status is DateTime) ? ((DateTime)(object)status).ToString("u") : Convert.ToString(status);
|
||||
queryParams.Add("status", paramStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(List<Pet>) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as List<Pet>;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (List<Pet>) ApiInvoker.deserialize(response, typeof(List<Pet>));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
/// </summary>
|
||||
/// <param name="tags">Tags to filter by</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public List<Pet> findPetsByTags (List<String> tags) {
|
||||
// create path and map variables
|
||||
var path = "/pet/findByTags".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
if (tags != null){
|
||||
string paramStr = (tags is DateTime) ? ((DateTime)(object)tags).ToString("u") : Convert.ToString(tags);
|
||||
queryParams.Add("tags", paramStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(List<Pet>) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as List<Pet>;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (List<Pet>) ApiInvoker.deserialize(response, typeof(List<Pet>));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
/// </summary>
|
||||
/// <param name="petId">ID of pet that needs to be fetched</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public Pet getPetById (Long petId) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(Pet) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as Pet;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (Pet) ApiInvoker.deserialize(response, typeof(Pet));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates a pet in the store with form data
|
||||
/// </summary>
|
||||
/// <param name="petId">ID of pet that needs to be updated</param>
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void updatePetWithForm (String petId, String name, String status) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (name != null){
|
||||
if(name is byte[]) {
|
||||
formParams.Add("name", name);
|
||||
} else {
|
||||
string paramStr = (name is DateTime) ? ((DateTime)(object)name).ToString("u") : Convert.ToString(name);
|
||||
formParams.Add("name", paramStr);
|
||||
}
|
||||
}
|
||||
if (status != null){
|
||||
if(status is byte[]) {
|
||||
formParams.Add("status", status);
|
||||
} else {
|
||||
string paramStr = (status is DateTime) ? ((DateTime)(object)status).ToString("u") : Convert.ToString(status);
|
||||
formParams.Add("status", paramStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a pet
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void deletePet (String apiKey, Long petId) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
headerParams.Add("apiKey", apiKey);
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// uploads an image
|
||||
/// </summary>
|
||||
/// <param name="petId">ID of pet to update</param>
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void uploadFile (Long petId, String additionalMetadata, File file) {
|
||||
// create path and map variables
|
||||
var path = "/pet/{petId}/uploadImage".Replace("{format}","json").Replace("{" + "petId" + "}", apiInvoker.escapeString(petId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (additionalMetadata != null){
|
||||
if(additionalMetadata is byte[]) {
|
||||
formParams.Add("additionalMetadata", additionalMetadata);
|
||||
} else {
|
||||
string paramStr = (additionalMetadata is DateTime) ? ((DateTime)(object)additionalMetadata).ToString("u") : Convert.ToString(additionalMetadata);
|
||||
formParams.Add("additionalMetadata", paramStr);
|
||||
}
|
||||
}
|
||||
if (file != null){
|
||||
if(file is byte[]) {
|
||||
formParams.Add("file", file);
|
||||
} else {
|
||||
string paramStr = (file is DateTime) ? ((DateTime)(object)file).ToString("u") : Convert.ToString(file);
|
||||
formParams.Add("file", paramStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,224 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using io.swagger.client;
|
||||
using io.swagger.client.model;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace io.swagger.client.api {
|
||||
|
||||
public class StoreApi {
|
||||
string basePath;
|
||||
private readonly ApiInvoker apiInvoker = ApiInvoker.GetInstance();
|
||||
|
||||
public StoreApi(String basePath = "http://petstore.swagger.io/v2")
|
||||
{
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
return apiInvoker;
|
||||
}
|
||||
|
||||
// Sets the endpoint base url for the services being accessed
|
||||
public void setBasePath(string basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
// Gets the endpoint base url for the services being accessed
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
|
||||
/// <returns></returns>
|
||||
public Map<String, Integer> getInventory () {
|
||||
// create path and map variables
|
||||
var path = "/store/inventory".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(Map<String, Integer>) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as Map<String, Integer>;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (Map<String, Integer>) ApiInvoker.deserialize(response, typeof(Map<String, Integer>));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <param name="body">order placed for purchasing the pet</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public Order placeOrder (Order body) {
|
||||
// create path and map variables
|
||||
var path = "/store/order".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(Order) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as Order;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@2ee95a72, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (Order) ApiInvoker.deserialize(response, typeof(Order));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public Order getOrderById (String orderId) {
|
||||
// create path and map variables
|
||||
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(Order) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as Order;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (Order) ApiInvoker.deserialize(response, typeof(Order));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void deleteOrder (String orderId) {
|
||||
// create path and map variables
|
||||
var path = "/store/order/{orderId}".Replace("{format}","json").Replace("{" + "orderId" + "}", apiInvoker.escapeString(orderId.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,422 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using io.swagger.client;
|
||||
using io.swagger.client.model;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace io.swagger.client.api {
|
||||
|
||||
public class UserApi {
|
||||
string basePath;
|
||||
private readonly ApiInvoker apiInvoker = ApiInvoker.GetInstance();
|
||||
|
||||
public UserApi(String basePath = "http://petstore.swagger.io/v2")
|
||||
{
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
return apiInvoker;
|
||||
}
|
||||
|
||||
// Sets the endpoint base url for the services being accessed
|
||||
public void setBasePath(string basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
// Gets the endpoint base url for the services being accessed
|
||||
public String getBasePath() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void createUser (User body) {
|
||||
// create path and map variables
|
||||
var path = "/user".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@3f1dd29a, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void createUsersWithArrayInput (List<User> body) {
|
||||
// create path and map variables
|
||||
var path = "/user/createWithArray".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@3eed9cd5, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void createUsersWithListInput (List<User> body) {
|
||||
// create path and map variables
|
||||
var path = "/user/createWithList".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, com.wordnik.swagger.codegen.CodegenParameter@61d38439, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs user into the system
|
||||
/// </summary>
|
||||
/// <param name="username">The user name for login</param>
|
||||
/// <param name="password">The password for login in clear text</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public String loginUser (String username, String password) {
|
||||
// create path and map variables
|
||||
var path = "/user/login".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
if (username != null){
|
||||
string paramStr = (username is DateTime) ? ((DateTime)(object)username).ToString("u") : Convert.ToString(username);
|
||||
queryParams.Add("username", paramStr);
|
||||
}
|
||||
if (password != null){
|
||||
string paramStr = (password is DateTime) ? ((DateTime)(object)password).ToString("u") : Convert.ToString(password);
|
||||
queryParams.Add("password", paramStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(String) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as String;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (String) ApiInvoker.deserialize(response, typeof(String));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
|
||||
/// <returns></returns>
|
||||
public void logoutUser () {
|
||||
// create path and map variables
|
||||
var path = "/user/logout".Replace("{format}","json");
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get user by user name
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
|
||||
|
||||
/// <returns></returns>
|
||||
public User getUserByName (String username) {
|
||||
// create path and map variables
|
||||
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(User) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ((object)response) as User;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return (User) ApiInvoker.deserialize(response, typeof(User));
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updated user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void updateUser (String username, User body) {
|
||||
// create path and map variables
|
||||
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, com.wordnik.swagger.codegen.CodegenParameter@58dec5c, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be deleted</param>
|
||||
|
||||
/// <returns></returns>
|
||||
public void deleteUser (String username) {
|
||||
// create path and map variables
|
||||
var path = "/user/{username}".Replace("{format}","json").Replace("{" + "username" + "}", apiInvoker.escapeString(username.ToString()));
|
||||
|
||||
// query params
|
||||
var queryParams = new Dictionary<String, String>();
|
||||
var headerParams = new Dictionary<String, String>();
|
||||
var formParams = new Dictionary<String, object>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
if (typeof(void) == typeof(byte[])) {
|
||||
var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams);
|
||||
return ;
|
||||
} else {
|
||||
var response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, formParams);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.ErrorCode == 404) {
|
||||
return ;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.client.model {
|
||||
public class Category {
|
||||
|
||||
|
||||
|
||||
public Long id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String name { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Category {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" name: ").Append(name).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.client.model {
|
||||
public class Order {
|
||||
|
||||
|
||||
|
||||
public Long id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public Long petId { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public Integer quantity { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public Date shipDate { get; set; }
|
||||
|
||||
|
||||
|
||||
/* Order Status */
|
||||
|
||||
public String status { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public Boolean complete { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Order {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" petId: ").Append(petId).Append("\n");
|
||||
|
||||
sb.Append(" quantity: ").Append(quantity).Append("\n");
|
||||
|
||||
sb.Append(" shipDate: ").Append(shipDate).Append("\n");
|
||||
|
||||
sb.Append(" status: ").Append(status).Append("\n");
|
||||
|
||||
sb.Append(" complete: ").Append(complete).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.client.model {
|
||||
public class Pet {
|
||||
|
||||
|
||||
|
||||
public Long id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public Category category { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String name { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public List<String> photoUrls { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Tag> tags { get; set; }
|
||||
|
||||
|
||||
|
||||
/* pet status in the store */
|
||||
|
||||
public String status { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Pet {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" category: ").Append(category).Append("\n");
|
||||
|
||||
sb.Append(" name: ").Append(name).Append("\n");
|
||||
|
||||
sb.Append(" photoUrls: ").Append(photoUrls).Append("\n");
|
||||
|
||||
sb.Append(" tags: ").Append(tags).Append("\n");
|
||||
|
||||
sb.Append(" status: ").Append(status).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.client.model {
|
||||
public class Tag {
|
||||
|
||||
|
||||
|
||||
public Long id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String name { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Tag {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" name: ").Append(name).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace io.swagger.client.model {
|
||||
public class User {
|
||||
|
||||
|
||||
|
||||
public Long id { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String username { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String firstName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String lastName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String email { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String password { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public String phone { get; set; }
|
||||
|
||||
|
||||
|
||||
/* User Status */
|
||||
|
||||
public Integer userStatus { get; set; }
|
||||
|
||||
|
||||
|
||||
public override string ToString() {
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class User {\n");
|
||||
|
||||
sb.Append(" id: ").Append(id).Append("\n");
|
||||
|
||||
sb.Append(" username: ").Append(username).Append("\n");
|
||||
|
||||
sb.Append(" firstName: ").Append(firstName).Append("\n");
|
||||
|
||||
sb.Append(" lastName: ").Append(lastName).Append("\n");
|
||||
|
||||
sb.Append(" email: ").Append(email).Append("\n");
|
||||
|
||||
sb.Append(" password: ").Append(password).Append("\n");
|
||||
|
||||
sb.Append(" phone: ").Append(phone).Append("\n");
|
||||
|
||||
sb.Append(" userStatus: ").Append(userStatus).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2015 Reverb Technologies, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Category implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2015 Reverb Technologies, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Order implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'pet_id' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'ship_date' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $pet_id; /* int */
|
||||
public $quantity; /* int */
|
||||
public $ship_date; /* DateTime */
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public $status; /* string */
|
||||
public $complete; /* boolean */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->pet_id = $data["pet_id"];
|
||||
$this->quantity = $data["quantity"];
|
||||
$this->ship_date = $data["ship_date"];
|
||||
$this->status = $data["status"];
|
||||
$this->complete = $data["complete"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2015 Reverb Technologies, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Pet implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'array[string]',
|
||||
'tags' => 'array[Tag]',
|
||||
'status' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photo_urls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $category; /* Category */
|
||||
public $name; /* string */
|
||||
public $photo_urls; /* array[string] */
|
||||
public $tags; /* array[Tag] */
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public $status; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->category = $data["category"];
|
||||
$this->name = $data["name"];
|
||||
$this->photo_urls = $data["photo_urls"];
|
||||
$this->tags = $data["tags"];
|
||||
$this->status = $data["status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2015 Reverb Technologies, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class Tag implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $name; /* string */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2015 Reverb Technologies, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* $model.description$
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||
*
|
||||
*/
|
||||
|
||||
class User implements ArrayAccess {
|
||||
static $swaggerTypes = array(
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
);
|
||||
|
||||
static $attributeMap = array(
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
);
|
||||
|
||||
|
||||
public $id; /* int */
|
||||
public $username; /* string */
|
||||
public $first_name; /* string */
|
||||
public $last_name; /* string */
|
||||
public $email; /* string */
|
||||
public $password; /* string */
|
||||
public $phone; /* string */
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
public $user_status; /* int */
|
||||
|
||||
public function __construct(array $data) {
|
||||
$this->id = $data["id"];
|
||||
$this->username = $data["username"];
|
||||
$this->first_name = $data["first_name"];
|
||||
$this->last_name = $data["last_name"];
|
||||
$this->email = $data["email"];
|
||||
$this->password = $data["password"];
|
||||
$this->phone = $data["phone"];
|
||||
$this->user_status = $data["user_status"];
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
public function offsetGet($offset) {
|
||||
return $this->$offset;
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
$this->$offset = $value;
|
||||
}
|
||||
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user