diff --git a/bin/all-petstore.sh b/bin/all-petstore.sh index c29203bdd26..fc4be18c3b5 100755 --- a/bin/all-petstore.sh +++ b/bin/all-petstore.sh @@ -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 diff --git a/bin/csharp-petstore.sh b/bin/csharp-petstore.sh new file mode 100755 index 00000000000..47efa2b3038 --- /dev/null +++ b/bin/csharp-petstore.sh @@ -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>/d;//!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*\([^<]*\).*,\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 diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/CSharpClientCodegen.java new file mode 100644 index 00000000000..0fc431139bb --- /dev/null +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/CSharpClientCodegen.java @@ -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 ( + 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( + Arrays.asList( + "String", + "boolean", + "Boolean", + "Double", + "Integer", + "Long", + "Float", + "Object") + ); + instantiationTypes.put("array", "List"); + instantiationTypes.put("map", "Dictionary"); + + typeMapping = new HashMap(); + 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) + ""; + } + 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; + } +} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig index 8303425734d..2d6e751d314 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/com.wordnik.swagger.codegen.CodegenConfig @@ -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 diff --git a/samples/client/petstore/csharp/JsonUtil.cs b/samples/client/petstore/csharp/JsonUtil.cs new file mode 100644 index 00000000000..18a85febb70 --- /dev/null +++ b/samples/client/petstore/csharp/JsonUtil.cs @@ -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 \ No newline at end of file diff --git a/samples/client/petstore/csharp/Newtonsoft.Json.dll b/samples/client/petstore/csharp/Newtonsoft.Json.dll new file mode 100644 index 00000000000..687d26fd9e0 Binary files /dev/null and b/samples/client/petstore/csharp/Newtonsoft.Json.dll differ diff --git a/samples/client/petstore/csharp/bin/Newtonsoft.Json.dll b/samples/client/petstore/csharp/bin/Newtonsoft.Json.dll index 26fdaffec14..687d26fd9e0 100644 Binary files a/samples/client/petstore/csharp/bin/Newtonsoft.Json.dll and b/samples/client/petstore/csharp/bin/Newtonsoft.Json.dll differ diff --git a/samples/client/petstore/csharp/compile.cs b/samples/client/petstore/csharp/compile.cs new file mode 100644 index 00000000000..18a85febb70 --- /dev/null +++ b/samples/client/petstore/csharp/compile.cs @@ -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 \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs new file mode 100644 index 00000000000..6e0996709ca --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/PetApi.cs @@ -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; + } + + + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + + /// + public void updatePet (Pet body) { + // create path and map variables + var path = "/pet".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + + /// + public void addPet (Pet body) { + // create path and map variables + var path = "/pet".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + + /// + public array findPetsByStatus (array status) { + // create path and map variables + var path = "/pet/findByStatus".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + if (status != null){ + string paramStr = (status is DateTime) ? ((DateTime)(object)status).ToString("u") : Convert.ToString(status); + queryParams.Add("status", paramStr); + } + + + + + + + try { + if (typeof(array) == typeof(byte[])) { + var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + return ((object)response) as array; + } else { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + if(response != null){ + return (array) ApiInvoker.deserialize(response, typeof(array)); + } + else { + return null; + } + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + + + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + + /// + public array findPetsByTags (array tags) { + // create path and map variables + var path = "/pet/findByTags".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + if (tags != null){ + string paramStr = (tags is DateTime) ? ((DateTime)(object)tags).ToString("u") : Convert.ToString(tags); + queryParams.Add("tags", paramStr); + } + + + + + + + try { + if (typeof(array) == typeof(byte[])) { + var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + return ((object)response) as array; + } else { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + if(response != null){ + return (array) ApiInvoker.deserialize(response, typeof(array)); + } + else { + return null; + } + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + + + /// + /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + 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; + } + } + } + + + /// + /// Deletes a pet + /// + /// + /// Pet id to delete + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + 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; + } + } + } + + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + 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; + } + } + } + + } + + } \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs new file mode 100644 index 00000000000..e939fea0dac --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/StoreApi.cs @@ -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; + } + + + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + /// + public map getInventory () { + // create path and map variables + var path = "/store/inventory".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + try { + if (typeof(map) == typeof(byte[])) { + var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + return ((object)response) as map; + } else { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + if(response != null){ + return (map) ApiInvoker.deserialize(response, typeof(map)); + } + else { + return null; + } + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + + /// + public Order placeOrder (Order body) { + // create path and map variables + var path = "/store/order".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + } + + } \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs new file mode 100644 index 00000000000..4600b27af1c --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Api/UserApi.cs @@ -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; + } + + + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + + /// + public void createUser (User body) { + // create path and map variables + var path = "/user".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Creates list of users with given input array + /// + /// List of user object + + /// + public void createUsersWithArrayInput (array body) { + // create path and map variables + var path = "/user/createWithArray".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Creates list of users with given input array + /// + /// List of user object + + /// + public void createUsersWithListInput (array body) { + // create path and map variables + var path = "/user/createWithList".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + 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; + } + } + } + + + /// + /// Logs out current logged in user session + /// + + /// + public void logoutUser () { + // create path and map variables + var path = "/user/logout".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + } + + } \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Category.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Category.cs new file mode 100644 index 00000000000..e4e220acd86 --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Category.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs new file mode 100644 index 00000000000..04ac393afe3 --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Order.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Pet.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Pet.cs new file mode 100644 index 00000000000..c99f945fc73 --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Pet.cs @@ -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 photoUrls { get; set; } + + + + + public array 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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Tag.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Tag.cs new file mode 100644 index 00000000000..91eff8d83ad --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/Tag.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/User.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/User.cs new file mode 100644 index 00000000000..17735989b5f --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/Model/User.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs new file mode 100644 index 00000000000..01648d1607c --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiException.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs new file mode 100644 index 00000000000..736b51b81f9 --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/ApiInvoker.cs @@ -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 defaultHeaderMap = new Dictionary(); + + 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 queryParams, object body, Dictionary headerParams, Dictionary formParams) + { + return invokeAPIInternal(host, path, method, false, queryParams, body, headerParams, formParams) as string; + } + + public byte[] invokeBinaryAPI(string host, string path, string method, Dictionary queryParams, object body, Dictionary headerParams, Dictionary 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 queryParams, object body, Dictionary headerParams, Dictionary 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 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; + } + } + } diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/PetApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/PetApi.cs new file mode 100644 index 00000000000..f37c882a6cb --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/PetApi.cs @@ -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; + } + + + + /// + /// Update an existing pet + /// + /// Pet object that needs to be added to the store + + /// + public void updatePet (Pet body) { + // create path and map variables + var path = "/pet".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Add a new pet to the store + /// + /// Pet object that needs to be added to the store + + /// + public void addPet (Pet body) { + // create path and map variables + var path = "/pet".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Finds Pets by status Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + + /// + public List findPetsByStatus (List status) { + // create path and map variables + var path = "/pet/findByStatus".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + if (status != null){ + string paramStr = (status is DateTime) ? ((DateTime)(object)status).ToString("u") : Convert.ToString(status); + queryParams.Add("status", paramStr); + } + + + + + + + try { + if (typeof(List) == typeof(byte[])) { + var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + return ((object)response) as List; + } else { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, typeof(List)); + } + else { + return null; + } + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + + + /// + /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + + /// + public List findPetsByTags (List tags) { + // create path and map variables + var path = "/pet/findByTags".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + if (tags != null){ + string paramStr = (tags is DateTime) ? ((DateTime)(object)tags).ToString("u") : Convert.ToString(tags); + queryParams.Add("tags", paramStr); + } + + + + + + + try { + if (typeof(List) == typeof(byte[])) { + var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + return ((object)response) as List; + } else { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + if(response != null){ + return (List) ApiInvoker.deserialize(response, typeof(List)); + } + else { + return null; + } + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + + + /// + /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Updates a pet in the store with form data + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + 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; + } + } + } + + + /// + /// Deletes a pet + /// + /// + /// Pet id to delete + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + 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; + } + } + } + + + /// + /// uploads an image + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + 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; + } + } + } + + } + + } \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/StoreApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/StoreApi.cs new file mode 100644 index 00000000000..1379255b07a --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/StoreApi.cs @@ -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; + } + + + + /// + /// Returns pet inventories by status Returns a map of status codes to quantities + /// + + /// + public Map getInventory () { + // create path and map variables + var path = "/store/inventory".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + try { + if (typeof(Map) == typeof(byte[])) { + var response = apiInvoker.invokeBinaryAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + return ((object)response) as Map; + } else { + var response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, formParams); + if(response != null){ + return (Map) ApiInvoker.deserialize(response, typeof(Map)); + } + else { + return null; + } + } + } catch (ApiException ex) { + if(ex.ErrorCode == 404) { + return null; + } + else { + throw ex; + } + } + } + + + /// + /// Place an order for a pet + /// + /// order placed for purchasing the pet + + /// + public Order placeOrder (Order body) { + // create path and map variables + var path = "/store/order".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + } + + } \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/UserApi.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/UserApi.cs new file mode 100644 index 00000000000..3b16377ab48 --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/api/UserApi.cs @@ -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; + } + + + + /// + /// Create user This can only be done by the logged in user. + /// + /// Created user object + + /// + public void createUser (User body) { + // create path and map variables + var path = "/user".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Creates list of users with given input array + /// + /// List of user object + + /// + public void createUsersWithArrayInput (List body) { + // create path and map variables + var path = "/user/createWithArray".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Creates list of users with given input array + /// + /// List of user object + + /// + public void createUsersWithListInput (List body) { + // create path and map variables + var path = "/user/createWithList".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Logs user into the system + /// + /// The user name for login + /// The password for login in clear text + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + 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; + } + } + } + + + /// + /// Logs out current logged in user session + /// + + /// + public void logoutUser () { + // create path and map variables + var path = "/user/logout".Replace("{format}","json"); + + // query params + var queryParams = new Dictionary(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Get user by user name + /// + /// The name that needs to be fetched. Use user1 for testing. + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Updated user This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + + /// + /// Delete user This can only be done by the logged in user. + /// + /// The name that needs to be deleted + + /// + 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(); + var headerParams = new Dictionary(); + var formParams = new Dictionary(); + + + + + + + + + + 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; + } + } + } + + } + + } \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Category.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Category.cs new file mode 100644 index 00000000000..f7cf3ae087b --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Category.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Order.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Order.cs new file mode 100644 index 00000000000..60587e5fbc9 --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Order.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Pet.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Pet.cs new file mode 100644 index 00000000000..30c6817a8e0 --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Pet.cs @@ -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 photoUrls { get; set; } + + + + + public List 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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Tag.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Tag.cs new file mode 100644 index 00000000000..c489ec8691f --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/Tag.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/User.cs b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/User.cs new file mode 100644 index 00000000000..7d9280b3f6d --- /dev/null +++ b/samples/client/petstore/csharp/src/main/csharp/io/swagger/client/model/User.cs @@ -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(); + } + } + + +} \ No newline at end of file diff --git a/samples/client/petstore/php/models/Category.php b/samples/client/petstore/php/models/Category.php deleted file mode 100644 index 98e7ba24800..00000000000 --- a/samples/client/petstore/php/models/Category.php +++ /dev/null @@ -1,60 +0,0 @@ - '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); - } -} diff --git a/samples/client/petstore/php/models/Order.php b/samples/client/petstore/php/models/Order.php deleted file mode 100644 index 2770e8bbbdf..00000000000 --- a/samples/client/petstore/php/models/Order.php +++ /dev/null @@ -1,79 +0,0 @@ - '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); - } -} diff --git a/samples/client/petstore/php/models/Pet.php b/samples/client/petstore/php/models/Pet.php deleted file mode 100644 index eee7fa3784c..00000000000 --- a/samples/client/petstore/php/models/Pet.php +++ /dev/null @@ -1,79 +0,0 @@ - '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); - } -} diff --git a/samples/client/petstore/php/models/Tag.php b/samples/client/petstore/php/models/Tag.php deleted file mode 100644 index f8efc998df6..00000000000 --- a/samples/client/petstore/php/models/Tag.php +++ /dev/null @@ -1,60 +0,0 @@ - '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); - } -} diff --git a/samples/client/petstore/php/models/User.php b/samples/client/petstore/php/models/User.php deleted file mode 100644 index d6b520eba51..00000000000 --- a/samples/client/petstore/php/models/User.php +++ /dev/null @@ -1,87 +0,0 @@ - '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); - } -}