forked from loafle/openapi-generator-original
		
	Merge branch 'master' into obj/ApiClient-Sanitizer
This commit is contained in:
		
						commit
						93a39242a6
					
				
							
								
								
									
										112
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										112
									
								
								README.md
									
									
									
									
									
								
							| @ -51,6 +51,7 @@ Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for addit | ||||
|       - [Java JAX-RS (Apache CXF 2 / 3)](#java-jax-rs-apache-cxf-2--3) | ||||
|       - [Java JAX-RS (Resteasy)](#java-jax-rs-resteasy)       | ||||
|       - [Java Spring MVC](#java-spring-mvc) | ||||
|       - [Java SpringBoot](#java-springboot) | ||||
|       - [Haskell Servant](#haskell-servant) | ||||
|       - [ASP.NET 5 Web API](#aspnet-5-web-api) | ||||
|     - [To build the codegen library](#to-build-the-codegen-library) | ||||
| @ -59,6 +60,7 @@ Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for addit | ||||
|   - [Online Generators](#online-generators) | ||||
|   - [Guidelines for Contribution](https://github.com/swagger-api/swagger-codegen/wiki/Guidelines-for-Contribution) | ||||
|   - [Companies/Projects using Swagger Codegen](#companiesprojects-using-swagger-codegen) | ||||
|   - [Swagger Codegen Core Team](#swagger-codegen-core-team) | ||||
|   - [License](#license) | ||||
| 
 | ||||
| 
 | ||||
| @ -688,6 +690,31 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ | ||||
|   -o samples/server/petstore/spring-mvc | ||||
| ``` | ||||
| 
 | ||||
| ### Java SpringBoot | ||||
| 
 | ||||
| ``` | ||||
| java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ | ||||
|   -i http://petstore.swagger.io/v2/swagger.json \ | ||||
|   -l springboot \ | ||||
|   -o samples/server/petstore/springboot | ||||
| ``` | ||||
| 
 | ||||
| You can also set a Json file with basePackage & configPackage properties :   | ||||
| Example :  | ||||
| ``` | ||||
| { | ||||
| "basePackage":"io.swagger", | ||||
| "configPackage":"io.swagger.config" | ||||
| } | ||||
| ``` | ||||
| For use it  add option ```-c myOptions.json```  to the generation command     | ||||
| 
 | ||||
| To Use-it : | ||||
| in the generated folder try ``` mvn package ``` for build jar.   | ||||
| Start your server  ``` java -jar target/swagger-springboot-server-1.0.0.jar ```   | ||||
| SpringBoot listening on default port 8080 | ||||
| 
 | ||||
| 
 | ||||
| ### Haskell Servant | ||||
| 
 | ||||
| ``` | ||||
| @ -794,6 +821,91 @@ Here are some companies/projects using Swagger Codegen in production. To add you | ||||
| - [Zalando](https://tech.zalando.com) | ||||
| - [ZEEF.com](https://zeef.com/) | ||||
| 
 | ||||
| # Swagger Codegen Core Team | ||||
| 
 | ||||
| Swaagger Codegen core team members are contributors who have been making signficiant contributions (review issues, fix bugs, make enhancements, etc) to the project on a regular basis. | ||||
| 
 | ||||
| ## API Clients | ||||
| | Langauges     | Core Team (join date) |  | ||||
| |:-------------|:-------------|  | ||||
| | ActionScript | | | ||||
| | C++      |  |   | ||||
| | C#      | @jimschubert (2016/05/01) |  | | ||||
| | Clojure | @xhh (2016/05/01) | | ||||
| | Dart      |  |   | ||||
| | Groovy     |  |   | ||||
| | Go     |  @guohuang (2016/05/01) @neilotoole (2016/05/01) |   | ||||
| | Java      | @cbornet (2016/05/01) @xhh (2016/05/01) | | ||||
| | NodeJS/Javascript | @xhh (2016/05/01) |  | ||||
| | ObjC      |   | | ||||
| | Perl      | @wing328 (2016/05/01) | | ||||
| | PHP      | @arnested (2016/05/01) | | ||||
| | Python   | @scottrw93 (2016/05/01) | | ||||
| | Ruby      | @wing328 (2016/05/01) | | ||||
| | Scala     |  | | ||||
| | Swift     | @jaz-ah (2016/05/01)  @Edubits (2016/05/01) | | ||||
| | TypeScript (Node) | @Vrolijkx (2016/05/01) |  | ||||
| | TypeScript (Angular1) | @Vrolijkx (2016/05/01) |  | ||||
| | TypeScript (Angular2) | @Vrolijkx (2016/05/01) | | ||||
| | TypeScript (Fetch) |  | | ||||
| ## Server Stubs | ||||
| | Langauges     | Core Team (date joined) |  | ||||
| |:------------- |:-------------|  | ||||
| | C# ASP.NET5 |  @jimschubert (2016/05/01) | | ||||
| | Haskell Servant |  | | ||||
| | Java Spring Boot |  | | ||||
| | Java SpringMVC | @kolyjjj (2016/05/01) | | ||||
| | Java JAX-RS |  | | ||||
| | NodeJS | @kolyjjj (2016/05/01) |   | ||||
| | PHP Lumen | @abcsum (2016/05/01) | | ||||
| | PHP Silex |  | | ||||
| | PHP Slim  |  | | ||||
| | Python Flask  |  | | ||||
| | Ruby Sinatra     | @wing328 (2016/05/01) |  | | ||||
| | Scala Scalatra |  |  | | ||||
| 
 | ||||
| ## Template Creator | ||||
| Here is a list of template creators: | ||||
|  * API Clients: | ||||
|    * C# (.NET 2.0): @who | ||||
|    * Clojure: @xhh | ||||
|    * Dart: @yissachar   | ||||
|    * Groovy: @victorgit   | ||||
|    * Go: @wing328   | ||||
|    * Java (Retrofit): @0legg | ||||
|    * Java (Retrofi2): @emilianobonassi | ||||
|    * Java (Jersey2): @xhh  | ||||
|    * Java (okhttp-gson): @xhh | ||||
|    * Javascript/NodeJS: @jfiala   | ||||
|    * Javascript (Closure-annotated Angular) @achew22 | ||||
|    * Perl: @wing328 | ||||
|    * Swift: @tkqubo | ||||
|    * TypeScript (Node):  @mhardorf  | ||||
|    * TypeScript (Angular1):  @mhardorf  | ||||
|    * TypeScript (Fetch): @leonyu | ||||
|    * TypeScript (Angular2): @roni-frantchi | ||||
|  * Server Stubs | ||||
|    * C# ASP.NET5: @jimschubert | ||||
|    * Haskell Servant: @algas | ||||
|    * Java Spring Boot: @diyfr | ||||
|    * JAX-RS RestEasy: @chameleon82 | ||||
|    * JAX-RS CXF: @hiveship  | ||||
|    * PHP Lumen: @abcsum | ||||
|    * PHP Slim: @jfastnacht | ||||
| 
 | ||||
| ## How to join the core team | ||||
| 
 | ||||
| Here are the requirements to become a core team member: | ||||
| - rank within top 50 in https://github.com/swagger-api/swagger-codegen/graphs/contributors | ||||
|   - to contribute, here are some good [starting points](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22)  | ||||
| - regular contributions to the project | ||||
|   - about 3 hours per week | ||||
|   - for contribution, it can be addressing issues, reviewing PRs submitted by others, submitting PR to fix bugs or make enhancements, etc | ||||
| 
 | ||||
|  To join the core team, please reach out to wing328hk@gmail.com (@wing328) for more information. | ||||
|   | ||||
|  To become a Template Creator, simply submit a PR for new API client (e.g. Rust, Elixir) or server stub (e.g. Ruby Grape) generator. | ||||
| 
 | ||||
| License | ||||
| ------- | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										3
									
								
								bin/typescript-fetch-petstore-target-es6.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								bin/typescript-fetch-petstore-target-es6.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| { | ||||
|   "supportsES6": true | ||||
| } | ||||
							
								
								
									
										31
									
								
								bin/typescript-fetch-petstore-target-es6.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								bin/typescript-fetch-petstore-target-es6.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,31 @@ | ||||
| #!/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 | ||||
| 
 | ||||
| executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.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="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-fetch -c bin/typescript-fetch-petstore-target-es6.json -o samples/client/petstore/typescript-fetch/default-es6" | ||||
| 
 | ||||
| java $JAVA_OPTS -jar $executable $ags | ||||
| @ -0,0 +1,4 @@ | ||||
| { | ||||
|   "npmName": "@swagger/typescript-fetch-petstore", | ||||
|   "npmVersion": "0.0.1" | ||||
| } | ||||
							
								
								
									
										31
									
								
								bin/typescript-fetch-petstore-target-with-package-metadata.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								bin/typescript-fetch-petstore-target-with-package-metadata.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,31 @@ | ||||
| #!/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 | ||||
| 
 | ||||
| executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.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="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-fetch -c bin/typescript-fetch-petstore-target-with-package-metadata.json -o samples/client/petstore/typescript-fetch/with-package-metadata" | ||||
| 
 | ||||
| java $JAVA_OPTS -jar $executable $ags | ||||
| @ -26,6 +26,6 @@ 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="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-fetch -o samples/client/petstore/typescript-fetch/" | ||||
| ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-fetch -o samples/client/petstore/typescript-fetch/default" | ||||
| 
 | ||||
| java $JAVA_OPTS -jar $executable $ags | ||||
|  | ||||
| @ -252,8 +252,8 @@ | ||||
|             <version>${slf4j-version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>commons-lang</groupId> | ||||
|             <artifactId>commons-lang</artifactId> | ||||
|             <groupId>org.apache.commons</groupId> | ||||
|             <artifactId>commons-lang3</artifactId> | ||||
|             <version>${commons-lang-version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|  | ||||
| @ -9,8 +9,8 @@ import io.swagger.models.parameters.*; | ||||
| import io.swagger.models.properties.*; | ||||
| import io.swagger.models.properties.PropertyBuilder.PropertyId; | ||||
| import io.swagger.util.Json; | ||||
| import org.apache.commons.lang.StringEscapeUtils; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringEscapeUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
| @ -325,7 +325,7 @@ public class DefaultCodegen { | ||||
|     @SuppressWarnings("static-method") | ||||
|     public String escapeText(String input) { | ||||
|         if (input != null) { | ||||
|             return StringEscapeUtils.escapeJava(input).replace("\\/", "/"); | ||||
|             return StringEscapeUtils.unescapeJava(StringEscapeUtils.escapeJava(input).replace("\\/", "/")).replaceAll("[\\t\\n\\r]"," "); | ||||
|         } | ||||
|         return input; | ||||
|     } | ||||
|  | ||||
| @ -2,7 +2,7 @@ package io.swagger.codegen.languages; | ||||
| 
 | ||||
| import io.swagger.codegen.*; | ||||
| import io.swagger.models.properties.*; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -6,7 +6,7 @@ import io.swagger.models.properties.*; | ||||
| import java.util.*; | ||||
| import java.io.File; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
| 
 | ||||
|  | ||||
| @ -26,7 +26,7 @@ import io.swagger.models.properties.LongProperty; | ||||
| import io.swagger.models.properties.MapProperty; | ||||
| import io.swagger.models.properties.Property; | ||||
| import io.swagger.models.properties.StringProperty; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -14,7 +14,7 @@ import java.io.File; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashSet; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -2,7 +2,7 @@ package io.swagger.codegen.languages; | ||||
| 
 | ||||
| import io.swagger.codegen.*; | ||||
| import io.swagger.models.properties.*; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -25,8 +25,8 @@ import java.util.Map; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Iterator; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang.WordUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.apache.commons.lang3.text.WordUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -11,7 +11,7 @@ import io.swagger.models.Contact; | ||||
| import io.swagger.models.Info; | ||||
| import io.swagger.models.License; | ||||
| import io.swagger.models.Swagger; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.util.Map; | ||||
|  | ||||
| @ -17,7 +17,7 @@ import io.swagger.models.properties.LongProperty; | ||||
| import io.swagger.models.properties.MapProperty; | ||||
| import io.swagger.models.properties.Property; | ||||
| import io.swagger.models.properties.StringProperty; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.util.Arrays; | ||||
|  | ||||
| @ -9,7 +9,7 @@ import io.swagger.models.parameters.Parameter; | ||||
| import java.io.File; | ||||
| import java.util.*; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| @ -9,9 +9,9 @@ import io.swagger.models.Swagger; | ||||
| import io.swagger.models.parameters.FormParameter; | ||||
| import io.swagger.models.parameters.Parameter; | ||||
| import io.swagger.models.properties.*; | ||||
| import org.apache.commons.lang.BooleanUtils; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang.WordUtils; | ||||
| import org.apache.commons.lang3.BooleanUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| //import org.apache.commons.lang3.WordUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -4,7 +4,7 @@ import io.swagger.codegen.*; | ||||
| import io.swagger.models.Operation; | ||||
| import io.swagger.models.Path; | ||||
| import io.swagger.models.Swagger; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.util.*; | ||||
|  | ||||
| @ -33,7 +33,7 @@ import io.swagger.models.properties.Property; | ||||
| import io.swagger.models.properties.RefProperty; | ||||
| import io.swagger.models.properties.StringProperty; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -8,7 +8,7 @@ import java.util.TreeSet; | ||||
| import java.util.*; | ||||
| import java.io.File; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     public JavascriptClosureAngularClientCodegen() { | ||||
|  | ||||
| @ -19,7 +19,7 @@ import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     public static final String CLASS_PREFIX = "classPrefix"; | ||||
| @ -28,6 +28,9 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     public static final String AUTHOR_EMAIL = "authorEmail"; | ||||
|     public static final String GIT_REPO_URL = "gitRepoURL"; | ||||
|     public static final String LICENSE = "license"; | ||||
|      | ||||
|     public static final String BinaryDataType = "ObjcClientCodegenBinaryData"; | ||||
|      | ||||
|     protected Set<String> foundationClasses = new HashSet<String>(); | ||||
|     protected String podName = "SwaggerClient"; | ||||
|     protected String podVersion = "1.0.0"; | ||||
| @ -66,6 +69,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|         defaultIncludes.add("NSMutableArray"); | ||||
|         defaultIncludes.add("NSMutableDictionary"); | ||||
|          | ||||
|         defaultIncludes.add(BinaryDataType); | ||||
| 
 | ||||
|         languageSpecificPrimitives.clear(); | ||||
|         languageSpecificPrimitives.add("NSNumber"); | ||||
|         languageSpecificPrimitives.add("NSString"); | ||||
| @ -92,10 +97,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|         typeMapping.put("List", "NSArray"); | ||||
|         typeMapping.put("object", "NSObject"); | ||||
|         typeMapping.put("file", "NSURL"); | ||||
|         //TODO binary should be mapped to byte array | ||||
|         // mapped to String as a workaround | ||||
|         typeMapping.put("binary", "NSString"); | ||||
|         typeMapping.put("ByteArray", "NSString"); | ||||
|         typeMapping.put("binary", BinaryDataType); | ||||
|         typeMapping.put("ByteArray", BinaryDataType); | ||||
| 
 | ||||
|         // ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm | ||||
|         setReservedWordsLowerCase( | ||||
| @ -282,11 +285,13 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|             String innerType = getSwaggerType(inner); | ||||
| 
 | ||||
|             String innerTypeDeclaration = getTypeDeclaration(inner); | ||||
| 
 | ||||
|             if (innerTypeDeclaration.endsWith("*")) { | ||||
|                 innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1); | ||||
|             } | ||||
|              | ||||
|             if(innerTypeDeclaration.equalsIgnoreCase(BinaryDataType)) { | ||||
|                 return "NSData*"; | ||||
|             } | ||||
|             // In this codition, type of property p is array of primitive, | ||||
|             // return container type with pointer, e.g. `NSArray* /* NSString */' | ||||
|             if (languageSpecificPrimitives.contains(innerType)) { | ||||
|  | ||||
| @ -27,7 +27,7 @@ import java.util.Arrays; | ||||
| import java.util.HashSet; | ||||
| import java.util.regex.Matcher; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     public static final String MODULE_NAME = "moduleName"; | ||||
|  | ||||
| @ -3,17 +3,23 @@ package io.swagger.codegen.languages; | ||||
| import io.swagger.codegen.CliOption; | ||||
| import io.swagger.codegen.CodegenConfig; | ||||
| import io.swagger.codegen.CodegenConstants; | ||||
| import io.swagger.codegen.CodegenModel; | ||||
| import io.swagger.codegen.CodegenParameter; | ||||
| import io.swagger.codegen.CodegenProperty; | ||||
| import io.swagger.codegen.CodegenType; | ||||
| import io.swagger.codegen.DefaultCodegen; | ||||
| import io.swagger.codegen.SupportingFile; | ||||
| import io.swagger.models.properties.*; | ||||
| 
 | ||||
| import java.io.File; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     protected String packageName; | ||||
| @ -21,6 +27,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig | ||||
|     protected String apiDocPath = "docs/"; | ||||
|     protected String modelDocPath = "docs/"; | ||||
|      | ||||
|     protected Map<Character, String> regexModifiers; | ||||
|      | ||||
| 	private String testFolder; | ||||
| 
 | ||||
|     public PythonClientCodegen() { | ||||
| @ -88,6 +96,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig | ||||
|                     "print", "class", "exec", "in", "raise", "continue", "finally", "is", | ||||
|                     "return", "def", "for", "lambda", "try", "self")); | ||||
|          | ||||
|         regexModifiers = new HashMap<Character, String>(); | ||||
|         regexModifiers.put('i', "IGNORECASE"); | ||||
|         regexModifiers.put('l', "LOCALE"); | ||||
|         regexModifiers.put('m', "MULTILINE"); | ||||
|         regexModifiers.put('s', "DOTALL"); | ||||
|         regexModifiers.put('u', "UNICODE"); | ||||
|         regexModifiers.put('x', "VERBOSE"); | ||||
| 
 | ||||
|         cliOptions.clear(); | ||||
|         cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).") | ||||
|                 .defaultValue("swagger_client")); | ||||
| @ -144,6 +160,46 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig | ||||
|         return str.replaceAll("\\.", "_"); | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public void postProcessParameter(CodegenParameter parameter){ | ||||
|         postProcessPattern(parameter.pattern, parameter.vendorExtensions); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { | ||||
|         postProcessPattern(property.pattern, property.vendorExtensions); | ||||
|     } | ||||
| 
 | ||||
|     /* | ||||
|      * The swagger pattern spec follows the Perl convention and style of modifiers. Python | ||||
|      * does not support this in as natural a way so it needs to convert it. See | ||||
|      * https://docs.python.org/2/howto/regex.html#compilation-flags for details. | ||||
|      */ | ||||
|     public void postProcessPattern(String pattern, Map<String, Object> vendorExtensions){ | ||||
|         if(pattern != null) { | ||||
|             int i = pattern.lastIndexOf('/'); | ||||
| 
 | ||||
|             //Must follow Perl /pattern/modifiers convention | ||||
|             if(pattern.charAt(0) != '/' || i < 2) { | ||||
|                 throw new IllegalArgumentException("Pattern must follow the Perl " | ||||
|                         + "/pattern/modifiers convention. "+pattern+" is not valid."); | ||||
|             } | ||||
| 
 | ||||
|             String regex = pattern.substring(1, i).replace("'", "\'"); | ||||
|             List<String> modifiers = new ArrayList<String>(); | ||||
| 
 | ||||
|             for(char c : pattern.substring(i).toCharArray()) { | ||||
|                 if(regexModifiers.containsKey(c)) { | ||||
|                     String modifier = regexModifiers.get(c); | ||||
|                     modifiers.add(modifier); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             vendorExtensions.put("x-regex", regex); | ||||
|             vendorExtensions.put("x-modifiers", modifiers); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public CodegenType getTag() { | ||||
|         return CodegenType.CLIENT; | ||||
|  | ||||
| @ -19,7 +19,7 @@ import java.util.HashSet; | ||||
| import java.util.Iterator; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -26,7 +26,7 @@ import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     protected String invokerPackage = "io.swagger.client"; | ||||
|  | ||||
| @ -17,7 +17,7 @@ import java.util.Arrays; | ||||
| import java.util.HashSet; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| 
 | ||||
|  | ||||
| @ -13,9 +13,9 @@ import io.swagger.models.parameters.Parameter; | ||||
| import io.swagger.models.properties.ArrayProperty; | ||||
| import io.swagger.models.properties.MapProperty; | ||||
| import io.swagger.models.properties.Property; | ||||
| import org.apache.commons.lang.ArrayUtils; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang.WordUtils; | ||||
| import org.apache.commons.lang3.ArrayUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.apache.commons.lang3.text.WordUtils; | ||||
| 
 | ||||
| import javax.annotation.Nullable; | ||||
| import java.util.*; | ||||
|  | ||||
| @ -25,7 +25,7 @@ import java.util.HashSet; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| 
 | ||||
| public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     protected static String PREFIX = "Sami"; | ||||
|  | ||||
| @ -1,11 +1,47 @@ | ||||
| package io.swagger.codegen.languages; | ||||
| 
 | ||||
| import io.swagger.codegen.CliOption; | ||||
| import io.swagger.codegen.SupportingFile; | ||||
| 
 | ||||
| import java.io.File; | ||||
| 
 | ||||
| public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodegen { | ||||
| 
 | ||||
|     public static final String NPM_NAME = "npmName"; | ||||
|     public static final String NPM_VERSION = "npmVersion"; | ||||
| 
 | ||||
|     protected String npmName = null; | ||||
|     protected String npmVersion = "1.0.0"; | ||||
| 
 | ||||
|     public TypeScriptFetchClientCodegen() { | ||||
|         super(); | ||||
|         outputFolder = "generated-code/typescript-fetch"; | ||||
|         embeddedTemplateDir = templateDir = "TypeScript-Fetch"; | ||||
|         this.cliOptions.add(new CliOption(NPM_NAME, "The name under which you want to publish generated npm package")); | ||||
|         this.cliOptions.add(new CliOption(NPM_VERSION, "The version of your npm package")); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void processOpts() { | ||||
|         super.processOpts(); | ||||
|         final String defaultFolder = apiPackage().replace('.', File.separatorChar); | ||||
| 
 | ||||
|         supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts")); | ||||
|         supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); | ||||
|         supportingFiles.add(new SupportingFile("assign.ts", defaultFolder, "assign.ts")); | ||||
|         supportingFiles.add(new SupportingFile("package.json.mustache", "", "package.json")); | ||||
|         supportingFiles.add(new SupportingFile("typings.json.mustache", "", "typings.json")); | ||||
|         supportingFiles.add(new SupportingFile("tsconfig.json.mustache", "", "tsconfig.json")); | ||||
| 
 | ||||
|         if(additionalProperties.containsKey(NPM_NAME)) { | ||||
|             this.setNpmName(additionalProperties.get(NPM_NAME).toString()); | ||||
|         } | ||||
| 
 | ||||
|         if (additionalProperties.containsKey(NPM_VERSION)) { | ||||
|             this.setNpmVersion(additionalProperties.get(NPM_VERSION).toString()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String getName() { | ||||
|         return "typescript-fetch"; | ||||
| @ -16,23 +52,20 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege | ||||
|         return "Generates a TypeScript client library using Fetch API (beta)."; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void processOpts() { | ||||
|         super.processOpts(); | ||||
|         final String defaultFolder = apiPackage().replace('.', File.separatorChar); | ||||
| 
 | ||||
|         supportingFiles.add(new SupportingFile("api.mustache", null, "api.ts")); | ||||
|         supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); | ||||
|         supportingFiles.add(new SupportingFile("assign.ts", defaultFolder, "assign.ts")); | ||||
|         supportingFiles.add(new SupportingFile("package.json", "", "package.json")); | ||||
|         supportingFiles.add(new SupportingFile("typings.json", "", "typings.json")); | ||||
|         supportingFiles.add(new SupportingFile("tsconfig.json", "", "tsconfig.json")); | ||||
|     public String getNpmName() { | ||||
|         return npmName; | ||||
|     } | ||||
| 
 | ||||
|     public TypeScriptFetchClientCodegen() { | ||||
|         super(); | ||||
|         outputFolder = "generated-code/typescript-fetch"; | ||||
|         embeddedTemplateDir = templateDir = "TypeScript-Fetch"; | ||||
|     public void setNpmName(String npmName) { | ||||
|         this.npmName = npmName; | ||||
|     } | ||||
| 
 | ||||
|     public String getNpmVersion() { | ||||
|         return npmVersion; | ||||
|     } | ||||
| 
 | ||||
|     public void setNpmVersion(String npmVersion) { | ||||
|         this.npmVersion = npmVersion; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -23,14 +23,14 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ | ||||
| } | ||||
| 
 | ||||
| {{#hasEnums}} | ||||
| export namespace {{classname}} { | ||||
| {{#vars}} | ||||
| {{#isEnum}} | ||||
| 
 | ||||
| export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} | ||||
|     {{.}} = <any> '{{.}}'{{^-last}},{{/-last}}{{/values}}{{/allowableValues}} | ||||
| } | ||||
| export type {{datatypeWithEnum}} = {{#allowableValues}}{{#values}}'{{.}}'{{^-last}} | {{/-last}}{{/values}}{{/allowableValues}}; | ||||
| {{/isEnum}} | ||||
| {{/vars}} | ||||
| } | ||||
| {{/hasEnums}} | ||||
| {{/model}} | ||||
| {{/models}} | ||||
| @ -119,8 +119,8 @@ export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}} | ||||
|                 if (response.status >= 200 && response.status < 300) { | ||||
|                     return response.json(); | ||||
|                 } else { | ||||
|                     var error = new Error(response.statusText); | ||||
|                     error['response'] = response; | ||||
|                     let error = new Error(response.statusText); | ||||
|                     (error as any).response = response; | ||||
|                     throw error; | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| export function assign (target, ...args) { | ||||
| export function assign (target: any, ...args: any[]) { | ||||
|   'use strict'; | ||||
|   if (target === undefined || target === null) { | ||||
|     throw new TypeError('Cannot convert undefined or null to object'); | ||||
|  | ||||
| @ -1,10 +0,0 @@ | ||||
| { | ||||
|   "private": true, | ||||
|   "dependencies": { | ||||
|     "isomorphic-fetch": "^2.2.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "typescript": "^1.8.10", | ||||
|     "typings": "^0.8.1" | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,17 @@ | ||||
| { | ||||
|   "name": "{{#npmName}}{{{npmName}}}{{/npmName}}{{^npmName}}typescript-fetch-api{{/npmName}}", | ||||
|   "version": "{{#npmVersion}}{{{npmVersion}}}{{/npmVersion}}{{^npmVersion}}0.0.0{{/npmVersion}}", | ||||
|   "private": true, | ||||
|   "main": "dist/api.js", | ||||
|   "browser": "dist/api.js", | ||||
|   "dependencies": { | ||||
|     "isomorphic-fetch": "^2.2.1" | ||||
|   }, | ||||
|   "scripts" : { | ||||
|     "install" : "typings install && tsc" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "typescript": "^1.8.10", | ||||
|     "typings": "^0.8.1" | ||||
|   } | ||||
| } | ||||
| @ -1,11 +0,0 @@ | ||||
| { | ||||
|   "compilerOptions": { | ||||
|     "target": "es5" | ||||
|   }, | ||||
|   "exclude": [ | ||||
|     "node_modules", | ||||
|     "typings/browser", | ||||
|     "typings/main", | ||||
|     "typings/main.d.ts" | ||||
|   ] | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| { | ||||
|   "compilerOptions": { | ||||
|     "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}", | ||||
|     "module": "commonjs", | ||||
|     "noImplicitAny": true, | ||||
|     "outDir": "dist" | ||||
|   }, | ||||
|   "exclude": [ | ||||
|     "node_modules", | ||||
|     "typings/browser", | ||||
|     "typings/main", | ||||
|     "typings/main.d.ts" | ||||
|   ] | ||||
| } | ||||
| @ -2,8 +2,8 @@ | ||||
|   "version": false, | ||||
|   "dependencies": {}, | ||||
|   "ambientDependencies": { | ||||
|     "es6-promise": "registry:dt/es6-promise#0.0.0+20160423074304", | ||||
|     "node": "registry:dt/node#4.0.0+20160423143914", | ||||
| {{^supportsES6}}    "es6-promise": "registry:dt/es6-promise#0.0.0+20160423074304", | ||||
| {{/supportsES6}}    "node": "registry:dt/node#4.0.0+20160423143914", | ||||
|     "isomorphic-fetch": "github:leonyu/DefinitelyTyped/isomorphic-fetch/isomorphic-fetch.d.ts#isomorphic-fetch-fix-module" | ||||
|   } | ||||
| } | ||||
| @ -10,6 +10,30 @@ static AFNetworkReachabilityStatus reachabilityStatus = AFNetworkReachabilitySta | ||||
| static void (^reachabilityChangeBlock)(int); | ||||
| 
 | ||||
| 
 | ||||
| static NSDictionary * {{classPrefix}}__headerFieldsForResponse(NSURLResponse *response) { | ||||
|     if(![response isKindOfClass:[NSHTTPURLResponse class]]) { | ||||
|         return nil; | ||||
|     } | ||||
|     return ((NSHTTPURLResponse*)response).allHeaderFields; | ||||
| } | ||||
| 
 | ||||
| static NSString * {{classPrefix}}__fileNameForResponse(NSURLResponse *response) { | ||||
|     NSDictionary * headers = {{classPrefix}}__headerFieldsForResponse(response); | ||||
|     if(!headers[@"Content-Disposition"]) { | ||||
|         return [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]; | ||||
|     } | ||||
|     NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?"; | ||||
|     NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern | ||||
|                                                                             options:NSRegularExpressionCaseInsensitive | ||||
|                                                                               error:nil]; | ||||
|     NSString *contentDispositionHeader = headers[@"Content-Disposition"]; | ||||
|     NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader | ||||
|                                                      options:0 | ||||
|                                                        range:NSMakeRange(0, [contentDispositionHeader length])]; | ||||
|     return [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]]; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @interface {{classPrefix}}ApiClient () | ||||
| 
 | ||||
| @property (readwrite, nonatomic) NSDictionary *HTTPResponseHeaders; | ||||
| @ -97,14 +121,12 @@ static void (^reachabilityChangeBlock)(int); | ||||
|     va_end(args); | ||||
| } | ||||
| 
 | ||||
| - (void)logResponse:(AFHTTPRequestOperation *)operation | ||||
|          forRequest:(NSURLRequest *)request | ||||
|               error:(NSError*)error { | ||||
| - (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error { | ||||
| 
 | ||||
|     NSString *message = [NSString stringWithFormat:@"\n[DEBUG] HTTP request body \n~BEGIN~\n %@\n~END~\n"\ | ||||
|                          "[DEBUG] HTTP response body \n~BEGIN~\n %@\n~END~\n", | ||||
|                         [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding], | ||||
|                         operation.responseString]; | ||||
|                          responseObject]; | ||||
| 
 | ||||
|     {{classPrefix}}DebugLog(message); | ||||
| } | ||||
| @ -220,20 +242,14 @@ static void (^reachabilityChangeBlock)(int); | ||||
| 
 | ||||
| -(Boolean) executeRequestWithId:(NSNumber*) requestId { | ||||
|     NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) { | ||||
|         if ([obj intValue]  == [requestId intValue]) { | ||||
|             return YES; | ||||
|         } | ||||
|         else { | ||||
|             return NO; | ||||
|         } | ||||
|         return [obj intValue]  == [requestId intValue]; | ||||
|     }]; | ||||
| 
 | ||||
|     if (matchingItems.count == 1) { | ||||
|         {{classPrefix}}DebugLog(@"removed request id %@", requestId); | ||||
|         [queuedRequests removeObject:requestId]; | ||||
|         return YES; | ||||
|     } | ||||
|     else { | ||||
|     } else { | ||||
|         return NO; | ||||
|     } | ||||
| } | ||||
| @ -244,7 +260,7 @@ static void (^reachabilityChangeBlock)(int); | ||||
|     return reachabilityStatus; | ||||
| } | ||||
| 
 | ||||
| +(bool) getOfflineState { | ||||
| +(BOOL) getOfflineState { | ||||
|     return offlineState; | ||||
| } | ||||
| 
 | ||||
| @ -255,29 +271,8 @@ static void (^reachabilityChangeBlock)(int); | ||||
| - (void) configureCacheReachibility { | ||||
|     [self.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { | ||||
|         reachabilityStatus = status; | ||||
|         switch (status) { | ||||
|             case AFNetworkReachabilityStatusUnknown: | ||||
|                 {{classPrefix}}DebugLog(@"reachability changed to AFNetworkReachabilityStatusUnknown"); | ||||
|                 [{{classPrefix}}ApiClient setOfflineState:true]; | ||||
|                 break; | ||||
| 
 | ||||
|             case AFNetworkReachabilityStatusNotReachable: | ||||
|                 {{classPrefix}}DebugLog(@"reachability changed to AFNetworkReachabilityStatusNotReachable"); | ||||
|                 [{{classPrefix}}ApiClient setOfflineState:true]; | ||||
|                 break; | ||||
| 
 | ||||
|             case AFNetworkReachabilityStatusReachableViaWWAN: | ||||
|                 {{classPrefix}}DebugLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWWAN"); | ||||
|                 [{{classPrefix}}ApiClient setOfflineState:false]; | ||||
|                 break; | ||||
| 
 | ||||
|             case AFNetworkReachabilityStatusReachableViaWiFi: | ||||
|                 {{classPrefix}}DebugLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWiFi"); | ||||
|                 [{{classPrefix}}ApiClient setOfflineState:false]; | ||||
|                 break; | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|         {{classPrefix}}DebugLog(@"reachability changed to %@",AFStringFromNetworkReachabilityStatus(status)); | ||||
|         [{{classPrefix}}ApiClient setOfflineState:status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable]; | ||||
| 
 | ||||
|         // call the reachability block, if configured | ||||
|         if (reachabilityChangeBlock != nil) { | ||||
| @ -293,92 +288,60 @@ static void (^reachabilityChangeBlock)(int); | ||||
| - (void) operationWithCompletionBlock: (NSURLRequest *)request | ||||
|                             requestId: (NSNumber *) requestId | ||||
|                       completionBlock: (void (^)(id, NSError *))completionBlock { | ||||
|     AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request | ||||
|                                                                success:^(AFHTTPRequestOperation *operation, id response) { | ||||
|                                                                    if ([self executeRequestWithId:requestId]) { | ||||
|                                                                        [self logResponse:operation forRequest:request error:nil]; | ||||
|                                                                        NSDictionary *responseHeaders = [[operation response] allHeaderFields]; | ||||
|                                                                        self.HTTPResponseHeaders = responseHeaders; | ||||
|                                                                        completionBlock(response, nil); | ||||
|     __weak __typeof(self)weakSelf = self; | ||||
|     NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { | ||||
|         __strong __typeof(weakSelf)strongSelf = weakSelf; | ||||
|         if (![strongSelf executeRequestWithId:requestId]) { | ||||
|             return; | ||||
|         } | ||||
|         [strongSelf logResponse:response responseObject:responseObject request:request error:error]; | ||||
|         strongSelf.HTTPResponseHeaders = {{classPrefix}}__headerFieldsForResponse(response); | ||||
|         if(!error) { | ||||
|             completionBlock(responseObject, nil); | ||||
|             return; | ||||
|         } | ||||
|                                                                } failure:^(AFHTTPRequestOperation *operation, NSError *error) { | ||||
|                                                                    if ([self executeRequestWithId:requestId]) { | ||||
|         NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; | ||||
|                                                                        if (operation.responseObject) { | ||||
|         if (responseObject) { | ||||
|             // Add in the (parsed) response body. | ||||
|                                                                            userInfo[{{classPrefix}}ResponseObjectErrorKey] = operation.responseObject; | ||||
|             userInfo[{{classPrefix}}ResponseObjectErrorKey] = responseObject; | ||||
|         } | ||||
|         NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; | ||||
|                                                                         [self logResponse:nil forRequest:request error:augmentedError]; | ||||
| 
 | ||||
|                                                                        NSDictionary *responseHeaders = [[operation response] allHeaderFields]; | ||||
|                                                                        self.HTTPResponseHeaders = responseHeaders; | ||||
| 
 | ||||
|         completionBlock(nil, augmentedError); | ||||
|                                                                    } | ||||
|     }]; | ||||
| 
 | ||||
|     [self.operationQueue addOperation:op]; | ||||
|     [op resume]; | ||||
| } | ||||
| 
 | ||||
| - (void) downloadOperationWithCompletionBlock: (NSURLRequest *)request | ||||
|                                     requestId: (NSNumber *) requestId | ||||
|                               completionBlock: (void (^)(id, NSError *))completionBlock { | ||||
|     AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request | ||||
|                                                                success:^(AFHTTPRequestOperation *operation, id responseObject) { | ||||
|     __weak __typeof(self)weakSelf = self; | ||||
|     NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { | ||||
|         __strong __typeof(weakSelf)strongSelf = weakSelf; | ||||
|         if (![strongSelf executeRequestWithId:requestId]) { | ||||
|             return; | ||||
|         } | ||||
|         strongSelf.HTTPResponseHeaders = {{classPrefix}}__headerFieldsForResponse(response); | ||||
|         [strongSelf logResponse:response responseObject:responseObject request:request error:error]; | ||||
|         if(error) { | ||||
|             NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; | ||||
|             if (responseObject) { | ||||
|                 userInfo[{{classPrefix}}ResponseObjectErrorKey] = responseObject; | ||||
|             } | ||||
|             NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; | ||||
|             completionBlock(nil, augmentedError); | ||||
|         } | ||||
|         {{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig]; | ||||
|                                                                    NSString *directory = nil; | ||||
|                                                                    if (config.tempFolderPath) { | ||||
|                                                                        directory = config.tempFolderPath; | ||||
|                                                                    } | ||||
|                                                                    else { | ||||
|                                                                        directory = NSTemporaryDirectory(); | ||||
|                                                                    } | ||||
| 
 | ||||
|                                                                    NSDictionary *headers = operation.response.allHeaderFields; | ||||
|                                                                    NSString *filename = nil; | ||||
|                                                                    if ([headers objectForKey:@"Content-Disposition"]) { | ||||
| 
 | ||||
|                                                                        NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?"; | ||||
|                                                                        NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern | ||||
|                                                                                                                                                options:NSRegularExpressionCaseInsensitive | ||||
|                                                                                                                                                  error:nil]; | ||||
|                                                                        NSString *contentDispositionHeader = [headers objectForKey:@"Content-Disposition"]; | ||||
|                                                                        NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader | ||||
|                                                                                                                         options:0 | ||||
|                                                                                                                           range:NSMakeRange(0, [contentDispositionHeader length])]; | ||||
|                                                                        filename = [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]]; | ||||
|                                                                    } | ||||
|                                                                    else { | ||||
|                                                                        filename = [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]; | ||||
|                                                                    } | ||||
|         NSString *directory = config.tempFolderPath ?: NSTemporaryDirectory(); | ||||
|         NSString * filename = {{classPrefix}}__fileNameForResponse(response); | ||||
| 
 | ||||
|         NSString *filepath = [directory stringByAppendingPathComponent:filename]; | ||||
|         NSURL *file = [NSURL fileURLWithPath:filepath]; | ||||
| 
 | ||||
|                                                                    [operation.responseData writeToURL:file atomically:YES]; | ||||
|                                                                    self.HTTPResponseHeaders = headers; | ||||
|         [responseObject writeToURL:file atomically:YES]; | ||||
| 
 | ||||
|         completionBlock(file, nil); | ||||
|                                                                } failure:^(AFHTTPRequestOperation *operation, NSError *error) { | ||||
| 
 | ||||
|                                                                    if ([self executeRequestWithId:requestId]) { | ||||
|                                                                        NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; | ||||
|                                                                        if (operation.responseObject) { | ||||
|                                                                            userInfo[{{classPrefix}}ResponseObjectErrorKey] = operation.responseObject; | ||||
|                                                                        } | ||||
| 
 | ||||
|                                                                        NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; | ||||
| 
 | ||||
| 
 | ||||
|                                                                         [self logResponse:nil forRequest:request error:augmentedError]; | ||||
| 
 | ||||
|                                                                        NSDictionary *responseHeaders = [[operation response] allHeaderFields]; | ||||
|                                                                        self.HTTPResponseHeaders = responseHeaders; | ||||
|                                                                        completionBlock(nil, augmentedError); | ||||
|                                                                    } | ||||
|     }]; | ||||
| 
 | ||||
|     [self.operationQueue addOperation:op]; | ||||
|     [op resume]; | ||||
| } | ||||
| 
 | ||||
| #pragma mark - Perform Request Methods | ||||
| @ -504,7 +467,7 @@ static void (^reachabilityChangeBlock)(int); | ||||
|     [request setHTTPShouldHandleCookies:NO]; | ||||
| 
 | ||||
|     NSNumber* requestId = [{{classPrefix}}ApiClient queueRequest]; | ||||
|     if ([responseType isEqualToString:@"NSURL*"]) { | ||||
|     if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) { | ||||
|         [self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { | ||||
|             completionBlock(data, error); | ||||
|         }]; | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #import <Foundation/Foundation.h> | ||||
| #import <ISO8601/ISO8601.h> | ||||
| #import <AFNetworking/AFHTTPRequestOperationManager.h> | ||||
| #import <AFNetworking.h> | ||||
| #import "{{classPrefix}}JSONResponseSerializer.h" | ||||
| #import "{{classPrefix}}JSONRequestSerializer.h" | ||||
| #import "{{classPrefix}}QueryParamCollection.h" | ||||
| @ -31,7 +31,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; | ||||
|  */ | ||||
| #define {{classPrefix}}DebugLog(format, ...) [{{classPrefix}}ApiClient debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__]; | ||||
| 
 | ||||
| @interface {{classPrefix}}ApiClient : AFHTTPRequestOperationManager | ||||
| @interface {{classPrefix}}ApiClient : AFHTTPSessionManager | ||||
| 
 | ||||
| @property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy; | ||||
| @property(nonatomic, assign) NSTimeInterval timeoutInterval; | ||||
| @ -74,7 +74,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; | ||||
|  * | ||||
|  * @return The client offline state | ||||
|  */ | ||||
| +(bool) getOfflineState; | ||||
| +(BOOL) getOfflineState; | ||||
| 
 | ||||
| /** | ||||
|  * Sets the client reachability, this may be overridden by the reachability manager if reachability changes | ||||
| @ -173,12 +173,14 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; | ||||
| /** | ||||
|  * Logs request and response | ||||
|  * | ||||
|  * @param operation AFHTTPRequestOperation for the HTTP request. | ||||
|  * @param response NSURLResponse for the HTTP request. | ||||
|  * @param responseObject response object of the HTTP request. | ||||
|  * @param request   The HTTP request. | ||||
|  * @param error     The error of the HTTP request. | ||||
|  */ | ||||
| - (void)logResponse:(AFHTTPRequestOperation *)operation | ||||
|          forRequest:(NSURLRequest *)request | ||||
| - (void)logResponse:(NSURLResponse *)response | ||||
|      responseObject:(id)responseObject | ||||
|             request:(NSURLRequest *)request | ||||
|               error:(NSError *)error; | ||||
| 
 | ||||
| /** | ||||
|  | ||||
| @ -33,7 +33,7 @@ NSInteger const {{classPrefix}}UnknownResponseObjectErrorCode = 143528; | ||||
|         formatter.numberStyle = NSNumberFormatterDecimalStyle; | ||||
|         _numberFormatter = formatter; | ||||
|         _primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; | ||||
|         _basicReturnTypes = @[@"NSObject", @"id"]; | ||||
|         _basicReturnTypes = @[@"NSObject", @"id", @"NSData"]; | ||||
|         _arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>" | ||||
|                                                                                 options:NSRegularExpressionCaseInsensitive | ||||
|                                                                                   error:nil]; | ||||
|  | ||||
| @ -21,6 +21,7 @@ from __future__ import absolute_import | ||||
| 
 | ||||
| import sys | ||||
| import os | ||||
| import re | ||||
| 
 | ||||
| # python 2 and python 3 compatibility library | ||||
| from six import iteritems | ||||
| @ -94,6 +95,31 @@ class {{classname}}(object): | ||||
|         if ('{{paramName}}' not in params) or (params['{{paramName}}'] is None): | ||||
|             raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") | ||||
| {{/required}} | ||||
| {{/allParams}} | ||||
| 
 | ||||
| {{#allParams}} | ||||
| {{#hasValidation}} | ||||
|     {{#maxLength}} | ||||
|         if '{{paramName}}' in params and len(params['{{paramName}}']) > {{maxLength}}:  | ||||
|             raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") | ||||
|     {{/maxLength}} | ||||
|     {{#minLength}} | ||||
|         if '{{paramName}}' in params and len(params['{{paramName}}']) < {{minLength}}:  | ||||
|             raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") | ||||
|     {{/minLength}} | ||||
|     {{#maximum}} | ||||
|         if '{{paramName}}' in params and params['{{paramName}}'] > {{maximum}}:  | ||||
|             raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than or equal to  `{{maximum}}`") | ||||
|     {{/maximum}} | ||||
|     {{#minimum}} | ||||
|         if '{{paramName}}' in params and params['{{paramName}}'] < {{minimum}}:  | ||||
|             raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than or equal to `{{minimum}}`") | ||||
|     {{/minimum}} | ||||
|     {{#pattern}} | ||||
|         if '{{paramName}}' in params and not re.search('{{vendorExtensions.x-regex}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):  | ||||
|             raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{pattern}}`") | ||||
|     {{/pattern}} | ||||
| {{/hasValidation}} | ||||
| {{/allParams}} | ||||
| 
 | ||||
|         resource_path = '{{path}}'.replace('{format}', 'json') | ||||
|  | ||||
| @ -22,6 +22,7 @@ Copyright 2016 SmartBear Software | ||||
| {{#model}} | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class {{classname}}(object): | ||||
| @ -79,7 +80,36 @@ class {{classname}}(object): | ||||
|                 "Invalid value for `{{name}}`, must be one of {0}" | ||||
|                 .format(allowed_values) | ||||
|             ) | ||||
|         {{/isEnum}}self._{{name}} = {{name}} | ||||
| {{/isEnum}} | ||||
| {{^isEnum}} | ||||
| {{#hasValidation}} | ||||
| 
 | ||||
|         if not {{name}}: | ||||
|             raise ValueError("Invalid value for `{{name}}`, must not be `None`") | ||||
| {{#maxLength}} | ||||
|         if len({{name}}) > {{maxLength}}:  | ||||
|             raise ValueError("Invalid value for `{{name}}`, length must be less than `{{maxLength}}`") | ||||
| {{/maxLength}} | ||||
| {{#minLength}} | ||||
|         if len({{name}}) < {{minLength}}:  | ||||
|             raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") | ||||
| {{/minLength}} | ||||
| {{#maximum}} | ||||
|         if {{name}} > {{maximum}}:  | ||||
|             raise ValueError("Invalid value for `{{name}}`, must be a value less than or equal to `{{maximum}}`") | ||||
| {{/maximum}} | ||||
| {{#minimum}} | ||||
|         if {{name}} < {{minimum}}:  | ||||
|             raise ValueError("Invalid value for `{{name}}`, must be a value greater than or equal to `{{minimum}}`") | ||||
| {{/minimum}} | ||||
| {{#pattern}} | ||||
|         if not re.search('{{vendorExtensions.x-regex}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):  | ||||
|             raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{pattern}}`") | ||||
| {{/pattern}} | ||||
| {{/hasValidation}} | ||||
| {{/isEnum}} | ||||
| 
 | ||||
|         self._{{name}} = {{name}} | ||||
| 
 | ||||
| {{/vars}} | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -2,6 +2,7 @@ package io.swagger.codegen.options; | ||||
| 
 | ||||
| import com.google.common.collect.ImmutableMap; | ||||
| import io.swagger.codegen.CodegenConstants; | ||||
| import io.swagger.codegen.languages.TypeScriptFetchClientCodegen; | ||||
| 
 | ||||
| import java.util.Map; | ||||
| 
 | ||||
| @ -10,6 +11,8 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider { | ||||
|     public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true"; | ||||
|     public static final Boolean SUPPORTS_ES6_VALUE = false; | ||||
|     public static final String MODEL_PROPERTY_NAMING_VALUE = "camelCase"; | ||||
|     private static final String NMP_NAME = "npmName"; | ||||
|     private static final String NMP_VERSION = "1.0.0"; | ||||
| 
 | ||||
|     @Override | ||||
|     public String getLanguage() { | ||||
| @ -23,6 +26,8 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider { | ||||
|                 .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) | ||||
|                 .put(CodegenConstants.MODEL_PROPERTY_NAMING, MODEL_PROPERTY_NAMING_VALUE) | ||||
|                 .put(CodegenConstants.SUPPORTS_ES6, String.valueOf(SUPPORTS_ES6_VALUE)) | ||||
|                 .put(TypeScriptFetchClientCodegen.NPM_NAME, NMP_NAME) | ||||
|                 .put(TypeScriptFetchClientCodegen.NPM_VERSION, NMP_VERSION) | ||||
|                 .build(); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -12,7 +12,7 @@ import java.util.Set; | ||||
| 
 | ||||
| import javax.annotation.Nullable; | ||||
| 
 | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
| import org.junit.rules.TemporaryFolder; | ||||
| import org.testng.annotations.AfterMethod; | ||||
| import org.testng.annotations.BeforeMethod; | ||||
|  | ||||
| @ -564,8 +564,16 @@ paths: | ||||
|     post: | ||||
|       tags: | ||||
|         - fake  | ||||
|       summary: Fake endpoint for testing various parameters | ||||
|       description: Fake endpoint for testing various parameters | ||||
|       summary: | | ||||
|         Fake endpoint for testing various parameters | ||||
|         假端點 | ||||
|         偽のエンドポイント | ||||
|         가짜 엔드 포인트 | ||||
|       description: | | ||||
|         Fake endpoint for testing various parameters | ||||
|         假端點 | ||||
|         偽のエンドポイント | ||||
|         가짜 엔드 포인트 | ||||
|       operationId: testEndpointParameters | ||||
|       produces: | ||||
|         - application/xml | ||||
|  | ||||
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							| @ -567,7 +567,7 @@ | ||||
|         <commons-cli-version>1.2</commons-cli-version> | ||||
|         <junit-version>4.8.1</junit-version> | ||||
|         <maven-plugin-version>1.0.0</maven-plugin-version> | ||||
|         <commons-lang-version>2.4</commons-lang-version> | ||||
|         <commons-lang-version>3.4</commons-lang-version> | ||||
|         <slf4j-version>1.7.12</slf4j-version> | ||||
|         <scala-maven-plugin-version>3.2.1</scala-maven-plugin-version> | ||||
|         <jmustache-version>1.12</jmustache-version> | ||||
|  | ||||
| @ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi | ||||
| 
 | ||||
| - API version: 1.0.0 | ||||
| - Package version:  | ||||
| - Build date: 2016-05-07T15:16:28.620+02:00 | ||||
| - Build date: 2016-05-08T12:06:01.121+02:00 | ||||
| - Build package: class io.swagger.codegen.languages.ObjcClientCodegen | ||||
| 
 | ||||
| ## Requirements | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| #import <Foundation/Foundation.h> | ||||
| #import <ISO8601/ISO8601.h> | ||||
| #import <AFNetworking/AFHTTPRequestOperationManager.h> | ||||
| #import <AFNetworking.h> | ||||
| #import "SWGJSONResponseSerializer.h" | ||||
| #import "SWGJSONRequestSerializer.h" | ||||
| #import "SWGQueryParamCollection.h" | ||||
| @ -35,7 +35,7 @@ extern NSString *const SWGResponseObjectErrorKey; | ||||
|  */ | ||||
| #define SWGDebugLog(format, ...) [SWGApiClient debugLog:[NSString stringWithFormat:@"%s", __PRETTY_FUNCTION__] message: format, ##__VA_ARGS__]; | ||||
| 
 | ||||
| @interface SWGApiClient : AFHTTPRequestOperationManager | ||||
| @interface SWGApiClient : AFHTTPSessionManager | ||||
| 
 | ||||
| @property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy; | ||||
| @property(nonatomic, assign) NSTimeInterval timeoutInterval; | ||||
| @ -78,7 +78,7 @@ extern NSString *const SWGResponseObjectErrorKey; | ||||
|  * | ||||
|  * @return The client offline state | ||||
|  */ | ||||
| +(bool) getOfflineState; | ||||
| +(BOOL) getOfflineState; | ||||
| 
 | ||||
| /**
 | ||||
|  * Sets the client reachability, this may be overridden by the reachability manager if reachability changes | ||||
| @ -177,12 +177,14 @@ extern NSString *const SWGResponseObjectErrorKey; | ||||
| /**
 | ||||
|  * Logs request and response | ||||
|  * | ||||
|  * @param operation AFHTTPRequestOperation for the HTTP request. | ||||
|  * @param response NSURLResponse for the HTTP request. | ||||
|  * @param responseObject response object of the HTTP request. | ||||
|  * @param request   The HTTP request. | ||||
|  * @param error     The error of the HTTP request. | ||||
|  */ | ||||
| - (void)logResponse:(AFHTTPRequestOperation *)operation | ||||
|          forRequest:(NSURLRequest *)request | ||||
| - (void)logResponse:(NSURLResponse *)response | ||||
|      responseObject:(id)responseObject | ||||
|             request:(NSURLRequest *)request | ||||
|               error:(NSError *)error; | ||||
| 
 | ||||
| /**
 | ||||
|  | ||||
| @ -10,6 +10,30 @@ static AFNetworkReachabilityStatus reachabilityStatus = AFNetworkReachabilitySta | ||||
| static void (^reachabilityChangeBlock)(int); | ||||
| 
 | ||||
| 
 | ||||
| static NSDictionary * SWG__headerFieldsForResponse(NSURLResponse *response) { | ||||
|     if(![response isKindOfClass:[NSHTTPURLResponse class]]) { | ||||
|         return nil; | ||||
|     } | ||||
|     return ((NSHTTPURLResponse*)response).allHeaderFields; | ||||
| } | ||||
| 
 | ||||
| static NSString * SWG__fileNameForResponse(NSURLResponse *response) { | ||||
|     NSDictionary * headers = SWG__headerFieldsForResponse(response); | ||||
|     if(!headers[@"Content-Disposition"]) { | ||||
|         return [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]; | ||||
|     } | ||||
|     NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?"; | ||||
|     NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern | ||||
|                                                                             options:NSRegularExpressionCaseInsensitive | ||||
|                                                                               error:nil]; | ||||
|     NSString *contentDispositionHeader = headers[@"Content-Disposition"]; | ||||
|     NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader | ||||
|                                                      options:0 | ||||
|                                                        range:NSMakeRange(0, [contentDispositionHeader length])]; | ||||
|     return [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]]; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @interface SWGApiClient () | ||||
| 
 | ||||
| @property (readwrite, nonatomic) NSDictionary *HTTPResponseHeaders; | ||||
| @ -97,14 +121,12 @@ static void (^reachabilityChangeBlock)(int); | ||||
|     va_end(args); | ||||
| } | ||||
| 
 | ||||
| - (void)logResponse:(AFHTTPRequestOperation *)operation | ||||
|          forRequest:(NSURLRequest *)request | ||||
|               error:(NSError*)error { | ||||
| - (void)logResponse:(NSURLResponse *)response responseObject:(id)responseObject request:(NSURLRequest *)request error:(NSError *)error { | ||||
| 
 | ||||
|     NSString *message = [NSString stringWithFormat:@"\n[DEBUG] HTTP request body \n~BEGIN~\n %@\n~END~\n"\ | ||||
|                          "[DEBUG] HTTP response body \n~BEGIN~\n %@\n~END~\n", | ||||
|                         [[NSString alloc] initWithData:request.HTTPBody encoding:NSUTF8StringEncoding], | ||||
|                         operation.responseString]; | ||||
|                          responseObject]; | ||||
| 
 | ||||
|     SWGDebugLog(message); | ||||
| } | ||||
| @ -220,20 +242,14 @@ static void (^reachabilityChangeBlock)(int); | ||||
| 
 | ||||
| -(Boolean) executeRequestWithId:(NSNumber*) requestId { | ||||
|     NSSet* matchingItems = [queuedRequests objectsPassingTest:^BOOL(id obj, BOOL *stop) { | ||||
|         if ([obj intValue]  == [requestId intValue]) { | ||||
|             return YES; | ||||
|         } | ||||
|         else { | ||||
|             return NO; | ||||
|         } | ||||
|         return [obj intValue]  == [requestId intValue]; | ||||
|     }]; | ||||
| 
 | ||||
|     if (matchingItems.count == 1) { | ||||
|         SWGDebugLog(@"removed request id %@", requestId); | ||||
|         [queuedRequests removeObject:requestId]; | ||||
|         return YES; | ||||
|     } | ||||
|     else { | ||||
|     } else { | ||||
|         return NO; | ||||
|     } | ||||
| } | ||||
| @ -244,7 +260,7 @@ static void (^reachabilityChangeBlock)(int); | ||||
|     return reachabilityStatus; | ||||
| } | ||||
| 
 | ||||
| +(bool) getOfflineState { | ||||
| +(BOOL) getOfflineState { | ||||
|     return offlineState; | ||||
| } | ||||
| 
 | ||||
| @ -255,29 +271,8 @@ static void (^reachabilityChangeBlock)(int); | ||||
| - (void) configureCacheReachibility { | ||||
|     [self.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { | ||||
|         reachabilityStatus = status; | ||||
|         switch (status) { | ||||
|             case AFNetworkReachabilityStatusUnknown: | ||||
|                 SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusUnknown"); | ||||
|                 [SWGApiClient setOfflineState:true]; | ||||
|                 break; | ||||
| 
 | ||||
|             case AFNetworkReachabilityStatusNotReachable: | ||||
|                 SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusNotReachable"); | ||||
|                 [SWGApiClient setOfflineState:true]; | ||||
|                 break; | ||||
| 
 | ||||
|             case AFNetworkReachabilityStatusReachableViaWWAN: | ||||
|                 SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWWAN"); | ||||
|                 [SWGApiClient setOfflineState:false]; | ||||
|                 break; | ||||
| 
 | ||||
|             case AFNetworkReachabilityStatusReachableViaWiFi: | ||||
|                 SWGDebugLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWiFi"); | ||||
|                 [SWGApiClient setOfflineState:false]; | ||||
|                 break; | ||||
|             default: | ||||
|                 break; | ||||
|         } | ||||
|         SWGDebugLog(@"reachability changed to %@",AFStringFromNetworkReachabilityStatus(status)); | ||||
|         [SWGApiClient setOfflineState:status == AFNetworkReachabilityStatusUnknown || status == AFNetworkReachabilityStatusNotReachable]; | ||||
| 
 | ||||
|         // call the reachability block, if configured | ||||
|         if (reachabilityChangeBlock != nil) { | ||||
| @ -293,92 +288,60 @@ static void (^reachabilityChangeBlock)(int); | ||||
| - (void) operationWithCompletionBlock: (NSURLRequest *)request | ||||
|                             requestId: (NSNumber *) requestId | ||||
|                       completionBlock: (void (^)(id, NSError *))completionBlock { | ||||
|     AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request | ||||
|                                                                success:^(AFHTTPRequestOperation *operation, id response) { | ||||
|                                                                    if ([self executeRequestWithId:requestId]) { | ||||
|                                                                        [self logResponse:operation forRequest:request error:nil]; | ||||
|                                                                        NSDictionary *responseHeaders = [[operation response] allHeaderFields]; | ||||
|                                                                        self.HTTPResponseHeaders = responseHeaders; | ||||
|                                                                        completionBlock(response, nil); | ||||
|     __weak __typeof(self)weakSelf = self; | ||||
|     NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { | ||||
|         __strong __typeof(weakSelf)strongSelf = weakSelf; | ||||
|         if (![strongSelf executeRequestWithId:requestId]) { | ||||
|             return; | ||||
|         } | ||||
|         [strongSelf logResponse:response responseObject:responseObject request:request error:error]; | ||||
|         strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response); | ||||
|         if(!error) { | ||||
|             completionBlock(responseObject, nil); | ||||
|             return; | ||||
|         } | ||||
|                                                                } failure:^(AFHTTPRequestOperation *operation, NSError *error) { | ||||
|                                                                    if ([self executeRequestWithId:requestId]) { | ||||
|         NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; | ||||
|                                                                        if (operation.responseObject) { | ||||
|         if (responseObject) { | ||||
|             // Add in the (parsed) response body. | ||||
|                                                                            userInfo[SWGResponseObjectErrorKey] = operation.responseObject; | ||||
|             userInfo[SWGResponseObjectErrorKey] = responseObject; | ||||
|         } | ||||
|         NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; | ||||
|                                                                         [self logResponse:nil forRequest:request error:augmentedError]; | ||||
| 
 | ||||
|                                                                        NSDictionary *responseHeaders = [[operation response] allHeaderFields]; | ||||
|                                                                        self.HTTPResponseHeaders = responseHeaders; | ||||
| 
 | ||||
|         completionBlock(nil, augmentedError); | ||||
|                                                                    } | ||||
|     }]; | ||||
| 
 | ||||
|     [self.operationQueue addOperation:op]; | ||||
|     [op resume]; | ||||
| } | ||||
| 
 | ||||
| - (void) downloadOperationWithCompletionBlock: (NSURLRequest *)request | ||||
|                                     requestId: (NSNumber *) requestId | ||||
|                               completionBlock: (void (^)(id, NSError *))completionBlock { | ||||
|     AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request | ||||
|                                                                success:^(AFHTTPRequestOperation *operation, id responseObject) { | ||||
|     __weak __typeof(self)weakSelf = self; | ||||
|     NSURLSessionDataTask* op = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { | ||||
|         __strong __typeof(weakSelf)strongSelf = weakSelf; | ||||
|         if (![strongSelf executeRequestWithId:requestId]) { | ||||
|             return; | ||||
|         } | ||||
|         strongSelf.HTTPResponseHeaders = SWG__headerFieldsForResponse(response); | ||||
|         [strongSelf logResponse:response responseObject:responseObject request:request error:error]; | ||||
|         if(error) { | ||||
|             NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; | ||||
|             if (responseObject) { | ||||
|                 userInfo[SWGResponseObjectErrorKey] = responseObject; | ||||
|             } | ||||
|             NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; | ||||
|             completionBlock(nil, augmentedError); | ||||
|         } | ||||
|         SWGConfiguration *config = [SWGConfiguration sharedConfig]; | ||||
|                                                                    NSString *directory = nil; | ||||
|                                                                    if (config.tempFolderPath) { | ||||
|                                                                        directory = config.tempFolderPath; | ||||
|                                                                    } | ||||
|                                                                    else { | ||||
|                                                                        directory = NSTemporaryDirectory(); | ||||
|                                                                    } | ||||
| 
 | ||||
|                                                                    NSDictionary *headers = operation.response.allHeaderFields; | ||||
|                                                                    NSString *filename = nil; | ||||
|                                                                    if ([headers objectForKey:@"Content-Disposition"]) { | ||||
| 
 | ||||
|                                                                        NSString *pattern = @"filename=['\"]?([^'\"\\s]+)['\"]?"; | ||||
|                                                                        NSRegularExpression *regexp = [NSRegularExpression regularExpressionWithPattern:pattern | ||||
|                                                                                                                                                options:NSRegularExpressionCaseInsensitive | ||||
|                                                                                                                                                  error:nil]; | ||||
|                                                                        NSString *contentDispositionHeader = [headers objectForKey:@"Content-Disposition"]; | ||||
|                                                                        NSTextCheckingResult *match = [regexp firstMatchInString:contentDispositionHeader | ||||
|                                                                                                                         options:0 | ||||
|                                                                                                                           range:NSMakeRange(0, [contentDispositionHeader length])]; | ||||
|                                                                        filename = [contentDispositionHeader substringWithRange:[match rangeAtIndex:1]]; | ||||
|                                                                    } | ||||
|                                                                    else { | ||||
|                                                                        filename = [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]; | ||||
|                                                                    } | ||||
|         NSString *directory = config.tempFolderPath ?: NSTemporaryDirectory(); | ||||
|         NSString * filename = SWG__fileNameForResponse(response); | ||||
| 
 | ||||
|         NSString *filepath = [directory stringByAppendingPathComponent:filename]; | ||||
|         NSURL *file = [NSURL fileURLWithPath:filepath]; | ||||
| 
 | ||||
|                                                                    [operation.responseData writeToURL:file atomically:YES]; | ||||
|                                                                    self.HTTPResponseHeaders = headers; | ||||
|         [responseObject writeToURL:file atomically:YES]; | ||||
| 
 | ||||
|         completionBlock(file, nil); | ||||
|                                                                } failure:^(AFHTTPRequestOperation *operation, NSError *error) { | ||||
| 
 | ||||
|                                                                    if ([self executeRequestWithId:requestId]) { | ||||
|                                                                        NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; | ||||
|                                                                        if (operation.responseObject) { | ||||
|                                                                            userInfo[SWGResponseObjectErrorKey] = operation.responseObject; | ||||
|                                                                        } | ||||
| 
 | ||||
|                                                                        NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; | ||||
| 
 | ||||
| 
 | ||||
|                                                                         [self logResponse:nil forRequest:request error:augmentedError]; | ||||
| 
 | ||||
|                                                                        NSDictionary *responseHeaders = [[operation response] allHeaderFields]; | ||||
|                                                                        self.HTTPResponseHeaders = responseHeaders; | ||||
|                                                                        completionBlock(nil, augmentedError); | ||||
|                                                                    } | ||||
|     }]; | ||||
| 
 | ||||
|     [self.operationQueue addOperation:op]; | ||||
|     [op resume]; | ||||
| } | ||||
| 
 | ||||
| #pragma mark - Perform Request Methods | ||||
| @ -504,7 +467,7 @@ static void (^reachabilityChangeBlock)(int); | ||||
|     [request setHTTPShouldHandleCookies:NO]; | ||||
| 
 | ||||
|     NSNumber* requestId = [SWGApiClient queueRequest]; | ||||
|     if ([responseType isEqualToString:@"NSURL*"]) { | ||||
|     if ([responseType isEqualToString:@"NSURL*"] || [responseType isEqualToString:@"NSURL"]) { | ||||
|         [self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) { | ||||
|             completionBlock(data, error); | ||||
|         }]; | ||||
|  | ||||
| @ -33,7 +33,7 @@ NSInteger const SWGUnknownResponseObjectErrorCode = 143528; | ||||
|         formatter.numberStyle = NSNumberFormatterDecimalStyle; | ||||
|         _numberFormatter = formatter; | ||||
|         _primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"]; | ||||
|         _basicReturnTypes = @[@"NSObject", @"id"]; | ||||
|         _basicReturnTypes = @[@"NSObject", @"id", @"NSData"]; | ||||
|         _arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>" | ||||
|                                                                                 options:NSRegularExpressionCaseInsensitive | ||||
|                                                                                   error:nil]; | ||||
|  | ||||
| @ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git | ||||
| 
 | ||||
| - API version: 1.0.0 | ||||
| - Package version: 1.0.0 | ||||
| - Build date: 2016-05-06T10:33:16.765+08:00 | ||||
| - Build date: 2016-05-06T16:24:00.420+08:00 | ||||
| - Build package: class io.swagger.codegen.languages.PhpClientCodegen | ||||
| 
 | ||||
| ## Requirements | ||||
| @ -88,6 +88,10 @@ All URIs are relative to *http://petstore.swagger.io/v2* | ||||
| Class | Method | HTTP request | Description | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| *FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters | ||||
| 假端點 | ||||
| 偽のエンドポイント | ||||
| 가짜 엔드 포인트 | ||||
| 
 | ||||
| *PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store | ||||
| *PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet | ||||
| *PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status | ||||
|  | ||||
| @ -0,0 +1,9 @@ | ||||
| # EnumClass | ||||
| 
 | ||||
| ## Properties | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| 
 | ||||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||||
| 
 | ||||
| 
 | ||||
| @ -0,0 +1,12 @@ | ||||
| # EnumTest | ||||
| 
 | ||||
| ## Properties | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| **enum_string** | **string** |  | [optional]  | ||||
| **enum_integer** | **int** |  | [optional]  | ||||
| **enum_number** | **double** |  | [optional]  | ||||
| 
 | ||||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||||
| 
 | ||||
| 
 | ||||
| @ -5,14 +5,26 @@ All URIs are relative to *http://petstore.swagger.io/v2* | ||||
| Method | HTTP request | Description | ||||
| ------------- | ------------- | ------------- | ||||
| [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters | ||||
| 假端點 | ||||
| 偽のエンドポイント | ||||
| 가짜 엔드 포인트 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| # **testEndpointParameters** | ||||
| > testEndpointParameters($number, $double, $string, $byte, $integer, $int32, $int64, $float, $binary, $date, $date_time, $password) | ||||
| 
 | ||||
| Fake endpoint for testing various parameters | ||||
| 假端點 | ||||
| 偽のエンドポイント | ||||
| 가짜 엔드 포인트 | ||||
| 
 | ||||
| 
 | ||||
| Fake endpoint for testing various parameters | ||||
| 假端點 | ||||
| 偽のエンドポイント | ||||
| 가짜 엔드 포인트 | ||||
| 
 | ||||
| 
 | ||||
| ### Example  | ||||
| ```php | ||||
|  | ||||
| @ -94,6 +94,10 @@ class FakeApi | ||||
|      * testEndpointParameters | ||||
|      * | ||||
|      * Fake endpoint for testing various parameters | ||||
| 假端點 | ||||
| 偽のエンドポイント | ||||
| 가짜 엔드 포인트 | ||||
| 
 | ||||
|      * | ||||
|      * @param float $number None (required) | ||||
|      * @param double $double None (required) | ||||
| @ -121,6 +125,10 @@ class FakeApi | ||||
|      * testEndpointParametersWithHttpInfo | ||||
|      * | ||||
|      * Fake endpoint for testing various parameters | ||||
| 假端點 | ||||
| 偽のエンドポイント | ||||
| 가짜 엔드 포인트 | ||||
| 
 | ||||
|      * | ||||
|      * @param float $number None (required) | ||||
|      * @param double $double None (required) | ||||
|  | ||||
| @ -0,0 +1,182 @@ | ||||
| <?php | ||||
| /** | ||||
|  * EnumClass | ||||
|  * | ||||
|  * PHP version 5 | ||||
|  * | ||||
|  * @category Class | ||||
|  * @package  Swagger\Client | ||||
|  * @author   http://github.com/swagger-api/swagger-codegen | ||||
|  * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link     https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| /** | ||||
|  *  Copyright 2016 SmartBear Software | ||||
|  * | ||||
|  *  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. | ||||
|  */ | ||||
| /** | ||||
|  * NOTE: This class is auto generated by the swagger code generator program. | ||||
|  * https://github.com/swagger-api/swagger-codegen | ||||
|  * Do not edit the class manually. | ||||
|  */ | ||||
| 
 | ||||
| namespace Swagger\Client\Model; | ||||
| 
 | ||||
| use \ArrayAccess; | ||||
| /** | ||||
|  * EnumClass Class Doc Comment | ||||
|  * | ||||
|  * @category    Class | ||||
|  * @description  | ||||
|  * @package     Swagger\Client | ||||
|  * @author      http://github.com/swagger-api/swagger-codegen | ||||
|  * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link        https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| class EnumClass implements ArrayAccess | ||||
| { | ||||
|     /** | ||||
|       * The original name of the model. | ||||
|       * @var string | ||||
|       */ | ||||
|     static $swaggerModelName = 'EnumClass'; | ||||
| 
 | ||||
|     /** | ||||
|       * Array of property to type mappings. Used for (de)serialization  | ||||
|       * @var string[] | ||||
|       */ | ||||
|     static $swaggerTypes = array( | ||||
|          | ||||
|     ); | ||||
|   | ||||
|     static function swaggerTypes() { | ||||
|         return self::$swaggerTypes; | ||||
|     } | ||||
| 
 | ||||
|     /**  | ||||
|      * Array of attributes where the key is the local name, and the value is the original name | ||||
|      * @var string[] | ||||
|      */ | ||||
|     static $attributeMap = array( | ||||
|          | ||||
|     ); | ||||
|   | ||||
|     static function attributeMap() { | ||||
|         return self::$attributeMap; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Array of attributes to setter functions (for deserialization of responses) | ||||
|      * @var string[] | ||||
|      */ | ||||
|     static $setters = array( | ||||
|          | ||||
|     ); | ||||
|   | ||||
|     static function setters() { | ||||
|         return self::$setters; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Array of attributes to getter functions (for serialization of requests) | ||||
|      * @var string[] | ||||
|      */ | ||||
|     static $getters = array( | ||||
|          | ||||
|     ); | ||||
|   | ||||
|     static function getters() { | ||||
|         return self::$getters; | ||||
|     } | ||||
| 
 | ||||
|      | ||||
| 
 | ||||
|      | ||||
| 
 | ||||
|     /** | ||||
|      * Associative array for storing property values | ||||
|      * @var mixed[] | ||||
|      */ | ||||
|     protected $container = array(); | ||||
| 
 | ||||
|     /** | ||||
|      * Constructor | ||||
|      * @param mixed[] $data Associated array of property value initalizing the model | ||||
|      */ | ||||
|     public function __construct(array $data = null) | ||||
|     { | ||||
|          | ||||
|          | ||||
|         if ($data != null) { | ||||
|              | ||||
|         } | ||||
|     } | ||||
|     /** | ||||
|      * Returns true if offset exists. False otherwise. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @return boolean | ||||
|      */ | ||||
|     public function offsetExists($offset) | ||||
|     { | ||||
|         return isset($this->container[$offset]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Gets offset. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @return mixed  | ||||
|      */ | ||||
|     public function offsetGet($offset) | ||||
|     { | ||||
|         return isset($this->container[$offset]) ? $this->container[$offset] : null; | ||||
|     } | ||||
|   | ||||
|     /** | ||||
|      * Sets value based on offset. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @param  mixed   $value  Value to be set | ||||
|      * @return void | ||||
|      */ | ||||
|     public function offsetSet($offset, $value) | ||||
|     { | ||||
|         if (is_null($offset)) { | ||||
|             $this->container[] = $value; | ||||
|         } else { | ||||
|             $this->container[$offset] = $value; | ||||
|         } | ||||
|     } | ||||
|   | ||||
|     /** | ||||
|      * Unsets offset. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @return void | ||||
|      */ | ||||
|     public function offsetUnset($offset) | ||||
|     { | ||||
|         unset($this->container[$offset]); | ||||
|     } | ||||
|   | ||||
|     /** | ||||
|      * Gets the string presentation of the object | ||||
|      * @return string | ||||
|      */ | ||||
|     public function __toString() | ||||
|     { | ||||
|         if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
 | ||||
|             return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); | ||||
|         } | ||||
| 
 | ||||
|         return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,318 @@ | ||||
| <?php | ||||
| /** | ||||
|  * EnumTest | ||||
|  * | ||||
|  * PHP version 5 | ||||
|  * | ||||
|  * @category Class | ||||
|  * @package  Swagger\Client | ||||
|  * @author   http://github.com/swagger-api/swagger-codegen | ||||
|  * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link     https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| /** | ||||
|  *  Copyright 2016 SmartBear Software | ||||
|  * | ||||
|  *  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. | ||||
|  */ | ||||
| /** | ||||
|  * NOTE: This class is auto generated by the swagger code generator program. | ||||
|  * https://github.com/swagger-api/swagger-codegen | ||||
|  * Do not edit the class manually. | ||||
|  */ | ||||
| 
 | ||||
| namespace Swagger\Client\Model; | ||||
| 
 | ||||
| use \ArrayAccess; | ||||
| /** | ||||
|  * EnumTest Class Doc Comment | ||||
|  * | ||||
|  * @category    Class | ||||
|  * @description  | ||||
|  * @package     Swagger\Client | ||||
|  * @author      http://github.com/swagger-api/swagger-codegen | ||||
|  * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link        https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| class EnumTest implements ArrayAccess | ||||
| { | ||||
|     /** | ||||
|       * The original name of the model. | ||||
|       * @var string | ||||
|       */ | ||||
|     static $swaggerModelName = 'Enum_Test'; | ||||
| 
 | ||||
|     /** | ||||
|       * Array of property to type mappings. Used for (de)serialization  | ||||
|       * @var string[] | ||||
|       */ | ||||
|     static $swaggerTypes = array( | ||||
|         'enum_string' => 'string', | ||||
|         'enum_integer' => 'int', | ||||
|         'enum_number' => 'double' | ||||
|     ); | ||||
|   | ||||
|     static function swaggerTypes() { | ||||
|         return self::$swaggerTypes; | ||||
|     } | ||||
| 
 | ||||
|     /**  | ||||
|      * Array of attributes where the key is the local name, and the value is the original name | ||||
|      * @var string[] | ||||
|      */ | ||||
|     static $attributeMap = array( | ||||
|         'enum_string' => 'enum_string', | ||||
|         'enum_integer' => 'enum_integer', | ||||
|         'enum_number' => 'enum_number' | ||||
|     ); | ||||
|   | ||||
|     static function attributeMap() { | ||||
|         return self::$attributeMap; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Array of attributes to setter functions (for deserialization of responses) | ||||
|      * @var string[] | ||||
|      */ | ||||
|     static $setters = array( | ||||
|         'enum_string' => 'setEnumString', | ||||
|         'enum_integer' => 'setEnumInteger', | ||||
|         'enum_number' => 'setEnumNumber' | ||||
|     ); | ||||
|   | ||||
|     static function setters() { | ||||
|         return self::$setters; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Array of attributes to getter functions (for serialization of requests) | ||||
|      * @var string[] | ||||
|      */ | ||||
|     static $getters = array( | ||||
|         'enum_string' => 'getEnumString', | ||||
|         'enum_integer' => 'getEnumInteger', | ||||
|         'enum_number' => 'getEnumNumber' | ||||
|     ); | ||||
|   | ||||
|     static function getters() { | ||||
|         return self::$getters; | ||||
|     } | ||||
| 
 | ||||
|     const ENUM_STRING_UPPER = 'UPPER'; | ||||
|     const ENUM_STRING_LOWER = 'lower'; | ||||
|     const ENUM_INTEGER_1 = 1; | ||||
|     const ENUM_INTEGER_MINUS_1 = -1; | ||||
|     const ENUM_NUMBER_1_DOT_1 = 1.1; | ||||
|     const ENUM_NUMBER_MINUS_1_DOT_2 = -1.2; | ||||
|      | ||||
| 
 | ||||
|      | ||||
|     /** | ||||
|      * Gets allowable values of the enum | ||||
|      * @return string[] | ||||
|      */ | ||||
|     public function getEnumStringAllowableValues() { | ||||
|         return [ | ||||
|             self::ENUM_STRING_UPPER, | ||||
|             self::ENUM_STRING_LOWER, | ||||
|         ]; | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * Gets allowable values of the enum | ||||
|      * @return string[] | ||||
|      */ | ||||
|     public function getEnumIntegerAllowableValues() { | ||||
|         return [ | ||||
|             self::ENUM_INTEGER_1, | ||||
|             self::ENUM_INTEGER_MINUS_1, | ||||
|         ]; | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * Gets allowable values of the enum | ||||
|      * @return string[] | ||||
|      */ | ||||
|     public function getEnumNumberAllowableValues() { | ||||
|         return [ | ||||
|             self::ENUM_NUMBER_1_DOT_1, | ||||
|             self::ENUM_NUMBER_MINUS_1_DOT_2, | ||||
|         ]; | ||||
|     } | ||||
|      | ||||
| 
 | ||||
|     /** | ||||
|      * Associative array for storing property values | ||||
|      * @var mixed[] | ||||
|      */ | ||||
|     protected $container = array( | ||||
|         /** | ||||
|          * $container['enum_string'] | ||||
|          * @var string | ||||
|          */ | ||||
|         'enum_string' => null, | ||||
|      | ||||
|         /** | ||||
|          * $container['enum_integer'] | ||||
|          * @var int | ||||
|          */ | ||||
|         'enum_integer' => null, | ||||
|      | ||||
|         /** | ||||
|          * $container['enum_number'] | ||||
|          * @var double | ||||
|          */ | ||||
|         'enum_number' => null, | ||||
|     ); | ||||
| 
 | ||||
|     /** | ||||
|      * Constructor | ||||
|      * @param mixed[] $data Associated array of property value initalizing the model | ||||
|      */ | ||||
|     public function __construct(array $data = null) | ||||
|     { | ||||
|          | ||||
|          | ||||
|         if ($data != null) { | ||||
|             $this->container['enum_string'] = $data['enum_string']; | ||||
|             $this->container['enum_integer'] = $data['enum_integer']; | ||||
|             $this->container['enum_number'] = $data['enum_number']; | ||||
|         } | ||||
|     } | ||||
|     /** | ||||
|      * Gets enum_string | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getEnumString() | ||||
|     { | ||||
|         return $this->container['enum_string']; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sets enum_string | ||||
|      * @param string $enum_string  | ||||
|      * @return $this | ||||
|      */ | ||||
|     public function setEnumString($enum_string) | ||||
|     { | ||||
|         $allowed_values = array('UPPER', 'lower'); | ||||
|         if (!in_array($enum_string, $allowed_values)) { | ||||
|             throw new \InvalidArgumentException("Invalid value for 'enum_string', must be one of 'UPPER', 'lower'"); | ||||
|         } | ||||
|         $this->container['enum_string'] = $enum_string; | ||||
|         return $this; | ||||
|     } | ||||
|     /** | ||||
|      * Gets enum_integer | ||||
|      * @return int | ||||
|      */ | ||||
|     public function getEnumInteger() | ||||
|     { | ||||
|         return $this->container['enum_integer']; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sets enum_integer | ||||
|      * @param int $enum_integer  | ||||
|      * @return $this | ||||
|      */ | ||||
|     public function setEnumInteger($enum_integer) | ||||
|     { | ||||
|         $allowed_values = array('1', '-1'); | ||||
|         if (!in_array($enum_integer, $allowed_values)) { | ||||
|             throw new \InvalidArgumentException("Invalid value for 'enum_integer', must be one of '1', '-1'"); | ||||
|         } | ||||
|         $this->container['enum_integer'] = $enum_integer; | ||||
|         return $this; | ||||
|     } | ||||
|     /** | ||||
|      * Gets enum_number | ||||
|      * @return double | ||||
|      */ | ||||
|     public function getEnumNumber() | ||||
|     { | ||||
|         return $this->container['enum_number']; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Sets enum_number | ||||
|      * @param double $enum_number  | ||||
|      * @return $this | ||||
|      */ | ||||
|     public function setEnumNumber($enum_number) | ||||
|     { | ||||
|         $allowed_values = array('1.1', '-1.2'); | ||||
|         if (!in_array($enum_number, $allowed_values)) { | ||||
|             throw new \InvalidArgumentException("Invalid value for 'enum_number', must be one of '1.1', '-1.2'"); | ||||
|         } | ||||
|         $this->container['enum_number'] = $enum_number; | ||||
|         return $this; | ||||
|     } | ||||
|     /** | ||||
|      * Returns true if offset exists. False otherwise. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @return boolean | ||||
|      */ | ||||
|     public function offsetExists($offset) | ||||
|     { | ||||
|         return isset($this->container[$offset]); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Gets offset. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @return mixed  | ||||
|      */ | ||||
|     public function offsetGet($offset) | ||||
|     { | ||||
|         return isset($this->container[$offset]) ? $this->container[$offset] : null; | ||||
|     } | ||||
|   | ||||
|     /** | ||||
|      * Sets value based on offset. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @param  mixed   $value  Value to be set | ||||
|      * @return void | ||||
|      */ | ||||
|     public function offsetSet($offset, $value) | ||||
|     { | ||||
|         if (is_null($offset)) { | ||||
|             $this->container[] = $value; | ||||
|         } else { | ||||
|             $this->container[$offset] = $value; | ||||
|         } | ||||
|     } | ||||
|   | ||||
|     /** | ||||
|      * Unsets offset. | ||||
|      * @param  integer $offset Offset  | ||||
|      * @return void | ||||
|      */ | ||||
|     public function offsetUnset($offset) | ||||
|     { | ||||
|         unset($this->container[$offset]); | ||||
|     } | ||||
|   | ||||
|     /** | ||||
|      * Gets the string presentation of the object | ||||
|      * @return string | ||||
|      */ | ||||
|     public function __toString() | ||||
|     { | ||||
|         if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
 | ||||
|             return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); | ||||
|         } | ||||
| 
 | ||||
|         return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,70 @@ | ||||
| <?php | ||||
| /** | ||||
|  * EnumClassTest | ||||
|  * | ||||
|  * PHP version 5 | ||||
|  * | ||||
|  * @category Class | ||||
|  * @package  Swagger\Client | ||||
|  * @author   http://github.com/swagger-api/swagger-codegen | ||||
|  * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link     https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| /** | ||||
|  *  Copyright 2016 SmartBear Software | ||||
|  * | ||||
|  *  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. | ||||
|  */ | ||||
| /** | ||||
|  * NOTE: This class is auto generated by the swagger code generator program. | ||||
|  * https://github.com/swagger-api/swagger-codegen | ||||
|  * Please update the test case below to test the model. | ||||
|  */ | ||||
| 
 | ||||
| namespace Swagger\Client\Model; | ||||
| 
 | ||||
| /** | ||||
|  * EnumClassTest Class Doc Comment | ||||
|  * | ||||
|  * @category    Class | ||||
|  * @description  | ||||
|  * @package     Swagger\Client | ||||
|  * @author      http://github.com/swagger-api/swagger-codegen | ||||
|  * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link        https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| class EnumClassTest extends \PHPUnit_Framework_TestCase | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Setup before running each test case | ||||
|      */ | ||||
|     public static function setUpBeforeClass() { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clean up after running each test case | ||||
|      */ | ||||
|     public static function tearDownAfterClass() { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Test EnumClass | ||||
|      */ | ||||
|     public function testEnumClass() { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,70 @@ | ||||
| <?php | ||||
| /** | ||||
|  * EnumTestTest | ||||
|  * | ||||
|  * PHP version 5 | ||||
|  * | ||||
|  * @category Class | ||||
|  * @package  Swagger\Client | ||||
|  * @author   http://github.com/swagger-api/swagger-codegen | ||||
|  * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link     https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| /** | ||||
|  *  Copyright 2016 SmartBear Software | ||||
|  * | ||||
|  *  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. | ||||
|  */ | ||||
| /** | ||||
|  * NOTE: This class is auto generated by the swagger code generator program. | ||||
|  * https://github.com/swagger-api/swagger-codegen | ||||
|  * Please update the test case below to test the model. | ||||
|  */ | ||||
| 
 | ||||
| namespace Swagger\Client\Model; | ||||
| 
 | ||||
| /** | ||||
|  * EnumTestTest Class Doc Comment | ||||
|  * | ||||
|  * @category    Class | ||||
|  * @description  | ||||
|  * @package     Swagger\Client | ||||
|  * @author      http://github.com/swagger-api/swagger-codegen | ||||
|  * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 | ||||
|  * @link        https://github.com/swagger-api/swagger-codegen | ||||
|  */ | ||||
| class EnumTestTest extends \PHPUnit_Framework_TestCase | ||||
| { | ||||
| 
 | ||||
|     /** | ||||
|      * Setup before running each test case | ||||
|      */ | ||||
|     public static function setUpBeforeClass() { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Clean up after running each test case | ||||
|      */ | ||||
|     public static function tearDownAfterClass() { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Test EnumTest | ||||
|      */ | ||||
|     public function testEnumTest() { | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -68,6 +68,10 @@ class FakeApiTest extends \PHPUnit_Framework_TestCase | ||||
|      * Test case for testEndpointParameters | ||||
|      * | ||||
|      * Fake endpoint for testing various parameters | ||||
| 假端點 | ||||
| 偽のエンドポイント | ||||
| 가짜 엔드 포인트 | ||||
| 
 | ||||
|      * | ||||
|      */ | ||||
|     public function test_testEndpointParameters() { | ||||
|  | ||||
| @ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https:// | ||||
| 
 | ||||
| - API version: 1.0.0 | ||||
| - Package version: 1.0.0 | ||||
| - Build date: 2016-04-27T22:50:21.115+01:00 | ||||
| - Build date: 2016-05-09T01:08:25.311+01:00 | ||||
| - Build package: class io.swagger.codegen.languages.PythonClientCodegen | ||||
| 
 | ||||
| ## Requirements. | ||||
| @ -18,9 +18,9 @@ Python 2.7 and 3.4+ | ||||
| If the python package is hosted on Github, you can install directly from Github | ||||
| 
 | ||||
| ```sh | ||||
| pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git | ||||
| pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git | ||||
| ``` | ||||
| (you may need to run `pip` with root permission: `sudo pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git`) | ||||
| (you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) | ||||
| 
 | ||||
| Then import the package: | ||||
| ```python | ||||
|  | ||||
| @ -8,12 +8,12 @@ git_repo_id=$2 | ||||
| release_note=$3 | ||||
| 
 | ||||
| if [ "$git_user_id" = "" ]; then | ||||
|     git_user_id="YOUR_GIT_USR_ID" | ||||
|     git_user_id="GIT_USER_ID" | ||||
|     echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" | ||||
| fi | ||||
| 
 | ||||
| if [ "$git_repo_id" = "" ]; then | ||||
|     git_repo_id="YOUR_GIT_REPO_ID" | ||||
|     git_repo_id="GIT_REPO_ID" | ||||
|     echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" | ||||
| fi | ||||
| 
 | ||||
|  | ||||
| @ -21,6 +21,7 @@ from __future__ import absolute_import | ||||
| 
 | ||||
| import sys | ||||
| import os | ||||
| import re | ||||
| 
 | ||||
| # python 2 and python 3 compatibility library | ||||
| from six import iteritems | ||||
| @ -103,6 +104,31 @@ class FakeApi(object): | ||||
|         if ('byte' not in params) or (params['byte'] is None): | ||||
|             raise ValueError("Missing the required parameter `byte` when calling `test_endpoint_parameters`") | ||||
| 
 | ||||
|         if 'number' in params and params['number'] > 543.2:  | ||||
|             raise ValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value less than or equal to  `543.2`") | ||||
|         if 'number' in params and params['number'] < 32.1:  | ||||
|             raise ValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value greater than or equal to `32.1`") | ||||
|         if 'double' in params and params['double'] > 123.4:  | ||||
|             raise ValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value less than or equal to  `123.4`") | ||||
|         if 'double' in params and params['double'] < 67.8:  | ||||
|             raise ValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value greater than or equal to `67.8`") | ||||
|         if 'string' in params and not re.search('[a-z]', params['string'], flags=re.IGNORECASE):  | ||||
|             raise ValueError("Invalid value for parameter `string` when calling `test_endpoint_parameters`, must conform to the pattern `/[a-z]/i`") | ||||
|         if 'integer' in params and params['integer'] > 100.0:  | ||||
|             raise ValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value less than or equal to  `100.0`") | ||||
|         if 'integer' in params and params['integer'] < 10.0:  | ||||
|             raise ValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value greater than or equal to `10.0`") | ||||
|         if 'int32' in params and params['int32'] > 200.0:  | ||||
|             raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value less than or equal to  `200.0`") | ||||
|         if 'int32' in params and params['int32'] < 20.0:  | ||||
|             raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value greater than or equal to `20.0`") | ||||
|         if 'float' in params and params['float'] > 987.6:  | ||||
|             raise ValueError("Invalid value for parameter `float` when calling `test_endpoint_parameters`, must be a value less than or equal to  `987.6`") | ||||
|         if 'password' in params and len(params['password']) > 64:  | ||||
|             raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be less than or equal to `64`") | ||||
|         if 'password' in params and len(params['password']) < 10:  | ||||
|             raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be greater than or equal to `10`") | ||||
| 
 | ||||
|         resource_path = '/fake'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
|  | ||||
| @ -21,6 +21,7 @@ from __future__ import absolute_import | ||||
| 
 | ||||
| import sys | ||||
| import os | ||||
| import re | ||||
| 
 | ||||
| # python 2 and python 3 compatibility library | ||||
| from six import iteritems | ||||
| @ -83,6 +84,7 @@ class PetApi(object): | ||||
|         if ('body' not in params) or (params['body'] is None): | ||||
|             raise ValueError("Missing the required parameter `body` when calling `add_pet`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -161,6 +163,7 @@ class PetApi(object): | ||||
|         if ('pet_id' not in params) or (params['pet_id'] is None): | ||||
|             raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet/{petId}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'pet_id' in params: | ||||
| @ -240,6 +243,7 @@ class PetApi(object): | ||||
|         if ('status' not in params) or (params['status'] is None): | ||||
|             raise ValueError("Missing the required parameter `status` when calling `find_pets_by_status`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet/findByStatus'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -317,6 +321,7 @@ class PetApi(object): | ||||
|         if ('tags' not in params) or (params['tags'] is None): | ||||
|             raise ValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet/findByTags'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -394,6 +399,7 @@ class PetApi(object): | ||||
|         if ('pet_id' not in params) or (params['pet_id'] is None): | ||||
|             raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet/{petId}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'pet_id' in params: | ||||
| @ -471,6 +477,7 @@ class PetApi(object): | ||||
|         if ('body' not in params) or (params['body'] is None): | ||||
|             raise ValueError("Missing the required parameter `body` when calling `update_pet`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -550,6 +557,7 @@ class PetApi(object): | ||||
|         if ('pet_id' not in params) or (params['pet_id'] is None): | ||||
|             raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet/{petId}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'pet_id' in params: | ||||
| @ -633,6 +641,7 @@ class PetApi(object): | ||||
|         if ('pet_id' not in params) or (params['pet_id'] is None): | ||||
|             raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'pet_id' in params: | ||||
|  | ||||
| @ -21,6 +21,7 @@ from __future__ import absolute_import | ||||
| 
 | ||||
| import sys | ||||
| import os | ||||
| import re | ||||
| 
 | ||||
| # python 2 and python 3 compatibility library | ||||
| from six import iteritems | ||||
| @ -83,6 +84,9 @@ class StoreApi(object): | ||||
|         if ('order_id' not in params) or (params['order_id'] is None): | ||||
|             raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") | ||||
| 
 | ||||
|         if 'order_id' in params and params['order_id'] < 1.0:  | ||||
|             raise ValueError("Invalid value for parameter `order_id` when calling `delete_order`, must be a value greater than or equal to `1.0`") | ||||
| 
 | ||||
|         resource_path = '/store/order/{orderId}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'order_id' in params: | ||||
| @ -156,6 +160,7 @@ class StoreApi(object): | ||||
|         del params['kwargs'] | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/store/inventory'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -231,6 +236,11 @@ class StoreApi(object): | ||||
|         if ('order_id' not in params) or (params['order_id'] is None): | ||||
|             raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") | ||||
| 
 | ||||
|         if 'order_id' in params and params['order_id'] > 5.0:  | ||||
|             raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to  `5.0`") | ||||
|         if 'order_id' in params and params['order_id'] < 1.0:  | ||||
|             raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1.0`") | ||||
| 
 | ||||
|         resource_path = '/store/order/{orderId}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'order_id' in params: | ||||
| @ -308,6 +318,7 @@ class StoreApi(object): | ||||
|         if ('body' not in params) or (params['body'] is None): | ||||
|             raise ValueError("Missing the required parameter `body` when calling `place_order`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/store/order'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
|  | ||||
| @ -21,6 +21,7 @@ from __future__ import absolute_import | ||||
| 
 | ||||
| import sys | ||||
| import os | ||||
| import re | ||||
| 
 | ||||
| # python 2 and python 3 compatibility library | ||||
| from six import iteritems | ||||
| @ -83,6 +84,7 @@ class UserApi(object): | ||||
|         if ('body' not in params) or (params['body'] is None): | ||||
|             raise ValueError("Missing the required parameter `body` when calling `create_user`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -160,6 +162,7 @@ class UserApi(object): | ||||
|         if ('body' not in params) or (params['body'] is None): | ||||
|             raise ValueError("Missing the required parameter `body` when calling `create_users_with_array_input`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user/createWithArray'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -237,6 +240,7 @@ class UserApi(object): | ||||
|         if ('body' not in params) or (params['body'] is None): | ||||
|             raise ValueError("Missing the required parameter `body` when calling `create_users_with_list_input`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user/createWithList'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -314,6 +318,7 @@ class UserApi(object): | ||||
|         if ('username' not in params) or (params['username'] is None): | ||||
|             raise ValueError("Missing the required parameter `username` when calling `delete_user`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user/{username}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'username' in params: | ||||
| @ -391,6 +396,7 @@ class UserApi(object): | ||||
|         if ('username' not in params) or (params['username'] is None): | ||||
|             raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user/{username}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'username' in params: | ||||
| @ -472,6 +478,7 @@ class UserApi(object): | ||||
|         if ('password' not in params) or (params['password'] is None): | ||||
|             raise ValueError("Missing the required parameter `password` when calling `login_user`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user/login'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -547,6 +554,7 @@ class UserApi(object): | ||||
|         del params['kwargs'] | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user/logout'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
| 
 | ||||
| @ -626,6 +634,7 @@ class UserApi(object): | ||||
|         if ('body' not in params) or (params['body'] is None): | ||||
|             raise ValueError("Missing the required parameter `body` when calling `update_user`") | ||||
| 
 | ||||
| 
 | ||||
|         resource_path = '/user/{username}'.replace('{format}', 'json') | ||||
|         path_params = {} | ||||
|         if 'username' in params: | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Animal(object): | ||||
| @ -66,6 +67,7 @@ class Animal(object): | ||||
|         :param class_name: The class_name of this Animal. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._class_name = class_name | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class ApiResponse(object): | ||||
| @ -72,6 +73,7 @@ class ApiResponse(object): | ||||
|         :param code: The code of this ApiResponse. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._code = code | ||||
| 
 | ||||
|     @property | ||||
| @ -94,6 +96,7 @@ class ApiResponse(object): | ||||
|         :param type: The type of this ApiResponse. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._type = type | ||||
| 
 | ||||
|     @property | ||||
| @ -116,6 +119,7 @@ class ApiResponse(object): | ||||
|         :param message: The message of this ApiResponse. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._message = message | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Cat(object): | ||||
| @ -69,6 +70,7 @@ class Cat(object): | ||||
|         :param class_name: The class_name of this Cat. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._class_name = class_name | ||||
| 
 | ||||
|     @property | ||||
| @ -91,6 +93,7 @@ class Cat(object): | ||||
|         :param declawed: The declawed of this Cat. | ||||
|         :type: bool | ||||
|         """ | ||||
|          | ||||
|         self._declawed = declawed | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Category(object): | ||||
| @ -69,6 +70,7 @@ class Category(object): | ||||
|         :param id: The id of this Category. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._id = id | ||||
| 
 | ||||
|     @property | ||||
| @ -91,6 +93,7 @@ class Category(object): | ||||
|         :param name: The name of this Category. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._name = name | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Dog(object): | ||||
| @ -69,6 +70,7 @@ class Dog(object): | ||||
|         :param class_name: The class_name of this Dog. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._class_name = class_name | ||||
| 
 | ||||
|     @property | ||||
| @ -91,6 +93,7 @@ class Dog(object): | ||||
|         :param breed: The breed of this Dog. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._breed = breed | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class FormatTest(object): | ||||
| @ -102,6 +103,14 @@ class FormatTest(object): | ||||
|         :param integer: The integer of this FormatTest. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         if not integer: | ||||
|             raise ValueError("Invalid value for `integer`, must not be `None`") | ||||
|         if integer > 100.0:  | ||||
|             raise ValueError("Invalid value for `integer`, must be a value less than or equal to `100.0`") | ||||
|         if integer < 10.0:  | ||||
|             raise ValueError("Invalid value for `integer`, must be a value greater than or equal to `10.0`") | ||||
| 
 | ||||
|         self._integer = integer | ||||
| 
 | ||||
|     @property | ||||
| @ -124,6 +133,14 @@ class FormatTest(object): | ||||
|         :param int32: The int32 of this FormatTest. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         if not int32: | ||||
|             raise ValueError("Invalid value for `int32`, must not be `None`") | ||||
|         if int32 > 200.0:  | ||||
|             raise ValueError("Invalid value for `int32`, must be a value less than or equal to `200.0`") | ||||
|         if int32 < 20.0:  | ||||
|             raise ValueError("Invalid value for `int32`, must be a value greater than or equal to `20.0`") | ||||
| 
 | ||||
|         self._int32 = int32 | ||||
| 
 | ||||
|     @property | ||||
| @ -146,6 +163,7 @@ class FormatTest(object): | ||||
|         :param int64: The int64 of this FormatTest. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._int64 = int64 | ||||
| 
 | ||||
|     @property | ||||
| @ -168,6 +186,14 @@ class FormatTest(object): | ||||
|         :param number: The number of this FormatTest. | ||||
|         :type: float | ||||
|         """ | ||||
|          | ||||
|         if not number: | ||||
|             raise ValueError("Invalid value for `number`, must not be `None`") | ||||
|         if number > 543.2:  | ||||
|             raise ValueError("Invalid value for `number`, must be a value less than or equal to `543.2`") | ||||
|         if number < 32.1:  | ||||
|             raise ValueError("Invalid value for `number`, must be a value greater than or equal to `32.1`") | ||||
| 
 | ||||
|         self._number = number | ||||
| 
 | ||||
|     @property | ||||
| @ -190,6 +216,14 @@ class FormatTest(object): | ||||
|         :param float: The float of this FormatTest. | ||||
|         :type: float | ||||
|         """ | ||||
|          | ||||
|         if not float: | ||||
|             raise ValueError("Invalid value for `float`, must not be `None`") | ||||
|         if float > 987.6:  | ||||
|             raise ValueError("Invalid value for `float`, must be a value less than or equal to `987.6`") | ||||
|         if float < 54.3:  | ||||
|             raise ValueError("Invalid value for `float`, must be a value greater than or equal to `54.3`") | ||||
| 
 | ||||
|         self._float = float | ||||
| 
 | ||||
|     @property | ||||
| @ -212,6 +246,14 @@ class FormatTest(object): | ||||
|         :param double: The double of this FormatTest. | ||||
|         :type: float | ||||
|         """ | ||||
|          | ||||
|         if not double: | ||||
|             raise ValueError("Invalid value for `double`, must not be `None`") | ||||
|         if double > 123.4:  | ||||
|             raise ValueError("Invalid value for `double`, must be a value less than or equal to `123.4`") | ||||
|         if double < 67.8:  | ||||
|             raise ValueError("Invalid value for `double`, must be a value greater than or equal to `67.8`") | ||||
| 
 | ||||
|         self._double = double | ||||
| 
 | ||||
|     @property | ||||
| @ -234,6 +276,12 @@ class FormatTest(object): | ||||
|         :param string: The string of this FormatTest. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         if not string: | ||||
|             raise ValueError("Invalid value for `string`, must not be `None`") | ||||
|         if not re.search('[a-z]', string, flags=re.IGNORECASE):  | ||||
|             raise ValueError("Invalid value for `string`, must be a follow pattern or equal to `/[a-z]/i`") | ||||
| 
 | ||||
|         self._string = string | ||||
| 
 | ||||
|     @property | ||||
| @ -256,6 +304,7 @@ class FormatTest(object): | ||||
|         :param byte: The byte of this FormatTest. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._byte = byte | ||||
| 
 | ||||
|     @property | ||||
| @ -278,6 +327,7 @@ class FormatTest(object): | ||||
|         :param binary: The binary of this FormatTest. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._binary = binary | ||||
| 
 | ||||
|     @property | ||||
| @ -300,6 +350,7 @@ class FormatTest(object): | ||||
|         :param date: The date of this FormatTest. | ||||
|         :type: date | ||||
|         """ | ||||
|          | ||||
|         self._date = date | ||||
| 
 | ||||
|     @property | ||||
| @ -322,6 +373,7 @@ class FormatTest(object): | ||||
|         :param date_time: The date_time of this FormatTest. | ||||
|         :type: datetime | ||||
|         """ | ||||
|          | ||||
|         self._date_time = date_time | ||||
| 
 | ||||
|     @property | ||||
| @ -344,6 +396,7 @@ class FormatTest(object): | ||||
|         :param uuid: The uuid of this FormatTest. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._uuid = uuid | ||||
| 
 | ||||
|     @property | ||||
| @ -366,6 +419,14 @@ class FormatTest(object): | ||||
|         :param password: The password of this FormatTest. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         if not password: | ||||
|             raise ValueError("Invalid value for `password`, must not be `None`") | ||||
|         if len(password) > 64:  | ||||
|             raise ValueError("Invalid value for `password`, length must be less than `64`") | ||||
|         if len(password) < 10:  | ||||
|             raise ValueError("Invalid value for `password`, length must be greater than or equal to `10`") | ||||
| 
 | ||||
|         self._password = password | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Model200Response(object): | ||||
| @ -66,6 +67,7 @@ class Model200Response(object): | ||||
|         :param name: The name of this Model200Response. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._name = name | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class ModelReturn(object): | ||||
| @ -66,6 +67,7 @@ class ModelReturn(object): | ||||
|         :param _return: The _return of this ModelReturn. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self.__return = _return | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Name(object): | ||||
| @ -72,6 +73,7 @@ class Name(object): | ||||
|         :param name: The name of this Name. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._name = name | ||||
| 
 | ||||
|     @property | ||||
| @ -94,6 +96,7 @@ class Name(object): | ||||
|         :param snake_case: The snake_case of this Name. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._snake_case = snake_case | ||||
| 
 | ||||
|     @property | ||||
| @ -116,6 +119,7 @@ class Name(object): | ||||
|         :param _property: The _property of this Name. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self.__property = _property | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Order(object): | ||||
| @ -81,6 +82,7 @@ class Order(object): | ||||
|         :param id: The id of this Order. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._id = id | ||||
| 
 | ||||
|     @property | ||||
| @ -103,6 +105,7 @@ class Order(object): | ||||
|         :param pet_id: The pet_id of this Order. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._pet_id = pet_id | ||||
| 
 | ||||
|     @property | ||||
| @ -125,6 +128,7 @@ class Order(object): | ||||
|         :param quantity: The quantity of this Order. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._quantity = quantity | ||||
| 
 | ||||
|     @property | ||||
| @ -147,6 +151,7 @@ class Order(object): | ||||
|         :param ship_date: The ship_date of this Order. | ||||
|         :type: datetime | ||||
|         """ | ||||
|          | ||||
|         self._ship_date = ship_date | ||||
| 
 | ||||
|     @property | ||||
| @ -175,6 +180,7 @@ class Order(object): | ||||
|                 "Invalid value for `status`, must be one of {0}" | ||||
|                 .format(allowed_values) | ||||
|             ) | ||||
| 
 | ||||
|         self._status = status | ||||
| 
 | ||||
|     @property | ||||
| @ -197,6 +203,7 @@ class Order(object): | ||||
|         :param complete: The complete of this Order. | ||||
|         :type: bool | ||||
|         """ | ||||
|          | ||||
|         self._complete = complete | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Pet(object): | ||||
| @ -81,6 +82,7 @@ class Pet(object): | ||||
|         :param id: The id of this Pet. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._id = id | ||||
| 
 | ||||
|     @property | ||||
| @ -103,6 +105,7 @@ class Pet(object): | ||||
|         :param category: The category of this Pet. | ||||
|         :type: Category | ||||
|         """ | ||||
|          | ||||
|         self._category = category | ||||
| 
 | ||||
|     @property | ||||
| @ -125,6 +128,7 @@ class Pet(object): | ||||
|         :param name: The name of this Pet. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._name = name | ||||
| 
 | ||||
|     @property | ||||
| @ -147,6 +151,7 @@ class Pet(object): | ||||
|         :param photo_urls: The photo_urls of this Pet. | ||||
|         :type: list[str] | ||||
|         """ | ||||
|          | ||||
|         self._photo_urls = photo_urls | ||||
| 
 | ||||
|     @property | ||||
| @ -169,6 +174,7 @@ class Pet(object): | ||||
|         :param tags: The tags of this Pet. | ||||
|         :type: list[Tag] | ||||
|         """ | ||||
|          | ||||
|         self._tags = tags | ||||
| 
 | ||||
|     @property | ||||
| @ -197,6 +203,7 @@ class Pet(object): | ||||
|                 "Invalid value for `status`, must be one of {0}" | ||||
|                 .format(allowed_values) | ||||
|             ) | ||||
| 
 | ||||
|         self._status = status | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class SpecialModelName(object): | ||||
| @ -66,6 +67,7 @@ class SpecialModelName(object): | ||||
|         :param special_property_name: The special_property_name of this SpecialModelName. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._special_property_name = special_property_name | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class Tag(object): | ||||
| @ -69,6 +70,7 @@ class Tag(object): | ||||
|         :param id: The id of this Tag. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._id = id | ||||
| 
 | ||||
|     @property | ||||
| @ -91,6 +93,7 @@ class Tag(object): | ||||
|         :param name: The name of this Tag. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._name = name | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -20,6 +20,7 @@ Copyright 2016 SmartBear Software | ||||
| 
 | ||||
| from pprint import pformat | ||||
| from six import iteritems | ||||
| import re | ||||
| 
 | ||||
| 
 | ||||
| class User(object): | ||||
| @ -87,6 +88,7 @@ class User(object): | ||||
|         :param id: The id of this User. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._id = id | ||||
| 
 | ||||
|     @property | ||||
| @ -109,6 +111,7 @@ class User(object): | ||||
|         :param username: The username of this User. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._username = username | ||||
| 
 | ||||
|     @property | ||||
| @ -131,6 +134,7 @@ class User(object): | ||||
|         :param first_name: The first_name of this User. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._first_name = first_name | ||||
| 
 | ||||
|     @property | ||||
| @ -153,6 +157,7 @@ class User(object): | ||||
|         :param last_name: The last_name of this User. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._last_name = last_name | ||||
| 
 | ||||
|     @property | ||||
| @ -175,6 +180,7 @@ class User(object): | ||||
|         :param email: The email of this User. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._email = email | ||||
| 
 | ||||
|     @property | ||||
| @ -197,6 +203,7 @@ class User(object): | ||||
|         :param password: The password of this User. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._password = password | ||||
| 
 | ||||
|     @property | ||||
| @ -219,6 +226,7 @@ class User(object): | ||||
|         :param phone: The phone of this User. | ||||
|         :type: str | ||||
|         """ | ||||
|          | ||||
|         self._phone = phone | ||||
| 
 | ||||
|     @property | ||||
| @ -241,6 +249,7 @@ class User(object): | ||||
|         :param user_status: The user_status of this User. | ||||
|         :type: int | ||||
|         """ | ||||
|          | ||||
|         self._user_status = user_status | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|  | ||||
| @ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ | ||||
| 
 | ||||
| - API version: 1.0.0 | ||||
| - Package version: 1.0.0 | ||||
| - Build date: 2016-05-02T21:47:16.723+08:00 | ||||
| - Build date: 2016-05-06T16:33:11.754+08:00 | ||||
| - Build package: class io.swagger.codegen.languages.RubyClientCodegen | ||||
| 
 | ||||
| ## Installation | ||||
| @ -77,7 +77,7 @@ opts = { | ||||
| } | ||||
| 
 | ||||
| begin | ||||
|   #Fake endpoint for testing various parameters | ||||
|   #Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
|   api_instance.test_endpoint_parameters(number, double, string, byte, opts) | ||||
| rescue Petstore::ApiError => e | ||||
|   puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}" | ||||
| @ -91,7 +91,7 @@ All URIs are relative to *http://petstore.swagger.io/v2* | ||||
| 
 | ||||
| Class | Method | HTTP request | Description | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| *Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters | ||||
| *Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
| *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store | ||||
| *Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet | ||||
| *Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status | ||||
| @ -117,10 +117,13 @@ Class | Method | HTTP request | Description | ||||
| ## Documentation for Models | ||||
| 
 | ||||
|  - [Petstore::Animal](docs/Animal.md) | ||||
|  - [Petstore::AnimalFarm](docs/AnimalFarm.md) | ||||
|  - [Petstore::ApiResponse](docs/ApiResponse.md) | ||||
|  - [Petstore::Cat](docs/Cat.md) | ||||
|  - [Petstore::Category](docs/Category.md) | ||||
|  - [Petstore::Dog](docs/Dog.md) | ||||
|  - [Petstore::EnumClass](docs/EnumClass.md) | ||||
|  - [Petstore::EnumTest](docs/EnumTest.md) | ||||
|  - [Petstore::FormatTest](docs/FormatTest.md) | ||||
|  - [Petstore::Model200Response](docs/Model200Response.md) | ||||
|  - [Petstore::ModelReturn](docs/ModelReturn.md) | ||||
|  | ||||
							
								
								
									
										7
									
								
								samples/client/petstore/ruby/docs/AnimalFarm.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								samples/client/petstore/ruby/docs/AnimalFarm.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| # Petstore::AnimalFarm | ||||
| 
 | ||||
| ## Properties | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| 
 | ||||
| 
 | ||||
							
								
								
									
										7
									
								
								samples/client/petstore/ruby/docs/EnumClass.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								samples/client/petstore/ruby/docs/EnumClass.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| # Petstore::EnumClass | ||||
| 
 | ||||
| ## Properties | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| 
 | ||||
| 
 | ||||
							
								
								
									
										10
									
								
								samples/client/petstore/ruby/docs/EnumTest.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								samples/client/petstore/ruby/docs/EnumTest.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| # Petstore::EnumTest | ||||
| 
 | ||||
| ## Properties | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| **enum_string** | **String** |  | [optional]  | ||||
| **enum_integer** | **Integer** |  | [optional]  | ||||
| **enum_number** | **Float** |  | [optional]  | ||||
| 
 | ||||
| 
 | ||||
| @ -4,15 +4,15 @@ All URIs are relative to *http://petstore.swagger.io/v2* | ||||
| 
 | ||||
| Method | HTTP request | Description | ||||
| ------------- | ------------- | ------------- | ||||
| [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters | ||||
| [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
| 
 | ||||
| 
 | ||||
| # **test_endpoint_parameters** | ||||
| > test_endpoint_parameters(number, double, string, byte, opts) | ||||
| 
 | ||||
| Fake endpoint for testing various parameters | ||||
| Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
| 
 | ||||
| Fake endpoint for testing various parameters | ||||
| Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
| 
 | ||||
| ### Example | ||||
| ```ruby | ||||
| @ -41,7 +41,7 @@ opts = { | ||||
| } | ||||
| 
 | ||||
| begin | ||||
|   #Fake endpoint for testing various parameters | ||||
|   #Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
|   api_instance.test_endpoint_parameters(number, double, string, byte, opts) | ||||
| rescue Petstore::ApiError => e | ||||
|   puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}" | ||||
|  | ||||
| @ -22,10 +22,13 @@ require 'petstore/configuration' | ||||
| 
 | ||||
| # Models | ||||
| require 'petstore/models/animal' | ||||
| require 'petstore/models/animal_farm' | ||||
| require 'petstore/models/api_response' | ||||
| require 'petstore/models/cat' | ||||
| require 'petstore/models/category' | ||||
| require 'petstore/models/dog' | ||||
| require 'petstore/models/enum_class' | ||||
| require 'petstore/models/enum_test' | ||||
| require 'petstore/models/format_test' | ||||
| require 'petstore/models/model_200_response' | ||||
| require 'petstore/models/model_return' | ||||
|  | ||||
| @ -24,8 +24,8 @@ module Petstore | ||||
|       @api_client = api_client | ||||
|     end | ||||
| 
 | ||||
|     # Fake endpoint for testing various parameters | ||||
|     # Fake endpoint for testing various parameters | ||||
|     # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
|     # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
|     # @param number None | ||||
|     # @param double None | ||||
|     # @param string None | ||||
| @ -45,8 +45,8 @@ module Petstore | ||||
|       return nil | ||||
|     end | ||||
| 
 | ||||
|     # Fake endpoint for testing various parameters | ||||
|     # Fake endpoint for testing various parameters | ||||
|     # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
|     # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트  | ||||
|     # @param number None | ||||
|     # @param double None | ||||
|     # @param string None | ||||
|  | ||||
							
								
								
									
										179
									
								
								samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								samples/client/petstore/ruby/lib/petstore/models/animal_farm.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,179 @@ | ||||
| =begin | ||||
| Swagger Petstore | ||||
| 
 | ||||
| This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. | ||||
| 
 | ||||
| OpenAPI spec version: 1.0.0 | ||||
| Contact: apiteam@swagger.io | ||||
| Generated by: https://github.com/swagger-api/swagger-codegen.git | ||||
| 
 | ||||
| License: Apache 2.0 | ||||
| http://www.apache.org/licenses/LICENSE-2.0.html | ||||
| 
 | ||||
| Terms of Service: http://swagger.io/terms/ | ||||
| 
 | ||||
| =end | ||||
| 
 | ||||
| require 'date' | ||||
| 
 | ||||
| module Petstore | ||||
|   class AnimalFarm | ||||
|     # Attribute mapping from ruby-style variable name to JSON key. | ||||
|     def self.attribute_map | ||||
|       { | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     # Attribute type mapping. | ||||
|     def self.swagger_types | ||||
|       { | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     # Initializes the object | ||||
|     # @param [Hash] attributes Model attributes in the form of hash | ||||
|     def initialize(attributes = {}) | ||||
|       return unless attributes.is_a?(Hash) | ||||
| 
 | ||||
|       # convert string to symbol for hash key | ||||
|       attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} | ||||
| 
 | ||||
|     end | ||||
| 
 | ||||
|     # Show invalid properties with the reasons. Usually used together with valid? | ||||
|     # @return Array for valid properies with the reasons | ||||
|     def list_invalid_properties | ||||
|       invalid_properties = Array.new | ||||
|       return invalid_properties | ||||
|     end | ||||
| 
 | ||||
|     # Check to see if the all the properties in the model are valid | ||||
|     # @return true if the model is valid | ||||
|     def valid? | ||||
|     end | ||||
| 
 | ||||
|     # Checks equality by comparing each attribute. | ||||
|     # @param [Object] Object to be compared  | ||||
|     def ==(o) | ||||
|       return true if self.equal?(o) | ||||
|       self.class == o.class | ||||
|     end | ||||
| 
 | ||||
|     # @see the `==` method | ||||
|     # @param [Object] Object to be compared  | ||||
|     def eql?(o) | ||||
|       self == o | ||||
|     end | ||||
| 
 | ||||
|     # Calculates hash code according to all attributes. | ||||
|     # @return [Fixnum] Hash code | ||||
|     def hash | ||||
|       [].hash | ||||
|     end | ||||
| 
 | ||||
|     # Builds the object from hash | ||||
|     # @param [Hash] attributes Model attributes in the form of hash | ||||
|     # @return [Object] Returns the model itself | ||||
|     def build_from_hash(attributes) | ||||
|       return nil unless attributes.is_a?(Hash) | ||||
|       self.class.swagger_types.each_pair do |key, type| | ||||
|         if type =~ /^Array<(.*)>/i | ||||
|           # check to ensure the input is an array given that the the attribute | ||||
|           # is documented as an array but the input is not | ||||
|           if attributes[self.class.attribute_map[key]].is_a?(Array) | ||||
|             self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) | ||||
|           end | ||||
|         elsif !attributes[self.class.attribute_map[key]].nil? | ||||
|           self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) | ||||
|         end # or else data not found in attributes(hash), not an issue as the data can be optional | ||||
|       end | ||||
| 
 | ||||
|       self | ||||
|     end | ||||
| 
 | ||||
|     # Deserializes the data based on type | ||||
|     # @param string type Data type | ||||
|     # @param string value Value to be deserialized | ||||
|     # @return [Object] Deserialized data | ||||
|     def _deserialize(type, value) | ||||
|       case type.to_sym | ||||
|       when :DateTime | ||||
|         DateTime.parse(value) | ||||
|       when :Date | ||||
|         Date.parse(value) | ||||
|       when :String | ||||
|         value.to_s | ||||
|       when :Integer | ||||
|         value.to_i | ||||
|       when :Float | ||||
|         value.to_f | ||||
|       when :BOOLEAN | ||||
|         if value.to_s =~ /^(true|t|yes|y|1)$/i | ||||
|           true | ||||
|         else | ||||
|           false | ||||
|         end | ||||
|       when :Object | ||||
|         # generic object (usually a Hash), return directly | ||||
|         value | ||||
|       when /\AArray<(?<inner_type>.+)>\z/ | ||||
|         inner_type = Regexp.last_match[:inner_type] | ||||
|         value.map { |v| _deserialize(inner_type, v) } | ||||
|       when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/ | ||||
|         k_type = Regexp.last_match[:k_type] | ||||
|         v_type = Regexp.last_match[:v_type] | ||||
|         {}.tap do |hash| | ||||
|           value.each do |k, v| | ||||
|             hash[_deserialize(k_type, k)] = _deserialize(v_type, v) | ||||
|           end | ||||
|         end | ||||
|       else # model | ||||
|         temp_model = Petstore.const_get(type).new | ||||
|         temp_model.build_from_hash(value) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     # Returns the string representation of the object | ||||
|     # @return [String] String presentation of the object | ||||
|     def to_s | ||||
|       to_hash.to_s | ||||
|     end | ||||
| 
 | ||||
|     # to_body is an alias to to_hash (backward compatibility) | ||||
|     # @return [Hash] Returns the object in the form of hash | ||||
|     def to_body | ||||
|       to_hash | ||||
|     end | ||||
| 
 | ||||
|     # Returns the object in the form of hash | ||||
|     # @return [Hash] Returns the object in the form of hash | ||||
|     def to_hash | ||||
|       hash = {} | ||||
|       self.class.attribute_map.each_pair do |attr, param| | ||||
|         value = self.send(attr) | ||||
|         next if value.nil? | ||||
|         hash[param] = _to_hash(value) | ||||
|       end | ||||
|       hash | ||||
|     end | ||||
| 
 | ||||
|     # Outputs non-array value in the form of hash | ||||
|     # For object, use to_hash. Otherwise, just return the value | ||||
|     # @param [Object] value Any valid value  | ||||
|     # @return [Hash] Returns the value in the form of hash | ||||
|     def _to_hash(value) | ||||
|       if value.is_a?(Array) | ||||
|         value.compact.map{ |v| _to_hash(v) } | ||||
|       elsif value.is_a?(Hash) | ||||
|         {}.tap do |hash| | ||||
|           value.each { |k, v| hash[k] = _to_hash(v) } | ||||
|         end | ||||
|       elsif value.respond_to? :to_hash | ||||
|         value.to_hash | ||||
|       else | ||||
|         value | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|   end | ||||
| end | ||||
							
								
								
									
										184
									
								
								samples/client/petstore/ruby/lib/petstore/models/enum_class.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										184
									
								
								samples/client/petstore/ruby/lib/petstore/models/enum_class.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,184 @@ | ||||
| =begin | ||||
| Swagger Petstore | ||||
| 
 | ||||
| This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. | ||||
| 
 | ||||
| OpenAPI spec version: 1.0.0 | ||||
| Contact: apiteam@swagger.io | ||||
| Generated by: https://github.com/swagger-api/swagger-codegen.git | ||||
| 
 | ||||
| License: Apache 2.0 | ||||
| http://www.apache.org/licenses/LICENSE-2.0.html | ||||
| 
 | ||||
| Terms of Service: http://swagger.io/terms/ | ||||
| 
 | ||||
| =end | ||||
| 
 | ||||
| require 'date' | ||||
| 
 | ||||
| module Petstore | ||||
|   class EnumClass | ||||
|     # Attribute mapping from ruby-style variable name to JSON key. | ||||
|     def self.attribute_map | ||||
|       { | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     # Attribute type mapping. | ||||
|     def self.swagger_types | ||||
|       { | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     # Initializes the object | ||||
|     # @param [Hash] attributes Model attributes in the form of hash | ||||
|     def initialize(attributes = {}) | ||||
|       return unless attributes.is_a?(Hash) | ||||
| 
 | ||||
|       # convert string to symbol for hash key | ||||
|       attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} | ||||
| 
 | ||||
|     end | ||||
| 
 | ||||
|     # Show invalid properties with the reasons. Usually used together with valid? | ||||
|     # @return Array for valid properies with the reasons | ||||
|     def list_invalid_properties | ||||
|       invalid_properties = Array.new | ||||
|       allowed_values = ["_abc", "-efg", "(xyz)"] | ||||
|       if @EnumClass && !allowed_values.include?(EnumClass) | ||||
|         invalid_properties.push("invalid value for 'EnumClass', must be one of #{allowed_values}.") | ||||
|       end | ||||
| 
 | ||||
|       return invalid_properties | ||||
|     end | ||||
| 
 | ||||
|     # Check to see if the all the properties in the model are valid | ||||
|     # @return true if the model is valid | ||||
|     def valid? | ||||
|     end | ||||
| 
 | ||||
|     # Checks equality by comparing each attribute. | ||||
|     # @param [Object] Object to be compared  | ||||
|     def ==(o) | ||||
|       return true if self.equal?(o) | ||||
|       self.class == o.class | ||||
|     end | ||||
| 
 | ||||
|     # @see the `==` method | ||||
|     # @param [Object] Object to be compared  | ||||
|     def eql?(o) | ||||
|       self == o | ||||
|     end | ||||
| 
 | ||||
|     # Calculates hash code according to all attributes. | ||||
|     # @return [Fixnum] Hash code | ||||
|     def hash | ||||
|       [].hash | ||||
|     end | ||||
| 
 | ||||
|     # Builds the object from hash | ||||
|     # @param [Hash] attributes Model attributes in the form of hash | ||||
|     # @return [Object] Returns the model itself | ||||
|     def build_from_hash(attributes) | ||||
|       return nil unless attributes.is_a?(Hash) | ||||
|       self.class.swagger_types.each_pair do |key, type| | ||||
|         if type =~ /^Array<(.*)>/i | ||||
|           # check to ensure the input is an array given that the the attribute | ||||
|           # is documented as an array but the input is not | ||||
|           if attributes[self.class.attribute_map[key]].is_a?(Array) | ||||
|             self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) | ||||
|           end | ||||
|         elsif !attributes[self.class.attribute_map[key]].nil? | ||||
|           self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) | ||||
|         end # or else data not found in attributes(hash), not an issue as the data can be optional | ||||
|       end | ||||
| 
 | ||||
|       self | ||||
|     end | ||||
| 
 | ||||
|     # Deserializes the data based on type | ||||
|     # @param string type Data type | ||||
|     # @param string value Value to be deserialized | ||||
|     # @return [Object] Deserialized data | ||||
|     def _deserialize(type, value) | ||||
|       case type.to_sym | ||||
|       when :DateTime | ||||
|         DateTime.parse(value) | ||||
|       when :Date | ||||
|         Date.parse(value) | ||||
|       when :String | ||||
|         value.to_s | ||||
|       when :Integer | ||||
|         value.to_i | ||||
|       when :Float | ||||
|         value.to_f | ||||
|       when :BOOLEAN | ||||
|         if value.to_s =~ /^(true|t|yes|y|1)$/i | ||||
|           true | ||||
|         else | ||||
|           false | ||||
|         end | ||||
|       when :Object | ||||
|         # generic object (usually a Hash), return directly | ||||
|         value | ||||
|       when /\AArray<(?<inner_type>.+)>\z/ | ||||
|         inner_type = Regexp.last_match[:inner_type] | ||||
|         value.map { |v| _deserialize(inner_type, v) } | ||||
|       when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/ | ||||
|         k_type = Regexp.last_match[:k_type] | ||||
|         v_type = Regexp.last_match[:v_type] | ||||
|         {}.tap do |hash| | ||||
|           value.each do |k, v| | ||||
|             hash[_deserialize(k_type, k)] = _deserialize(v_type, v) | ||||
|           end | ||||
|         end | ||||
|       else # model | ||||
|         temp_model = Petstore.const_get(type).new | ||||
|         temp_model.build_from_hash(value) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     # Returns the string representation of the object | ||||
|     # @return [String] String presentation of the object | ||||
|     def to_s | ||||
|       to_hash.to_s | ||||
|     end | ||||
| 
 | ||||
|     # to_body is an alias to to_hash (backward compatibility) | ||||
|     # @return [Hash] Returns the object in the form of hash | ||||
|     def to_body | ||||
|       to_hash | ||||
|     end | ||||
| 
 | ||||
|     # Returns the object in the form of hash | ||||
|     # @return [Hash] Returns the object in the form of hash | ||||
|     def to_hash | ||||
|       hash = {} | ||||
|       self.class.attribute_map.each_pair do |attr, param| | ||||
|         value = self.send(attr) | ||||
|         next if value.nil? | ||||
|         hash[param] = _to_hash(value) | ||||
|       end | ||||
|       hash | ||||
|     end | ||||
| 
 | ||||
|     # Outputs non-array value in the form of hash | ||||
|     # For object, use to_hash. Otherwise, just return the value | ||||
|     # @param [Object] value Any valid value  | ||||
|     # @return [Hash] Returns the value in the form of hash | ||||
|     def _to_hash(value) | ||||
|       if value.is_a?(Array) | ||||
|         value.compact.map{ |v| _to_hash(v) } | ||||
|       elsif value.is_a?(Hash) | ||||
|         {}.tap do |hash| | ||||
|           value.each { |k, v| hash[k] = _to_hash(v) } | ||||
|         end | ||||
|       elsif value.respond_to? :to_hash | ||||
|         value.to_hash | ||||
|       else | ||||
|         value | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|   end | ||||
| end | ||||
							
								
								
									
										248
									
								
								samples/client/petstore/ruby/lib/petstore/models/enum_test.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										248
									
								
								samples/client/petstore/ruby/lib/petstore/models/enum_test.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,248 @@ | ||||
| =begin | ||||
| Swagger Petstore | ||||
| 
 | ||||
| This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. | ||||
| 
 | ||||
| OpenAPI spec version: 1.0.0 | ||||
| Contact: apiteam@swagger.io | ||||
| Generated by: https://github.com/swagger-api/swagger-codegen.git | ||||
| 
 | ||||
| License: Apache 2.0 | ||||
| http://www.apache.org/licenses/LICENSE-2.0.html | ||||
| 
 | ||||
| Terms of Service: http://swagger.io/terms/ | ||||
| 
 | ||||
| =end | ||||
| 
 | ||||
| require 'date' | ||||
| 
 | ||||
| module Petstore | ||||
|   class EnumTest | ||||
|     attr_accessor :enum_string | ||||
| 
 | ||||
|     attr_accessor :enum_integer | ||||
| 
 | ||||
|     attr_accessor :enum_number | ||||
| 
 | ||||
|     # Attribute mapping from ruby-style variable name to JSON key. | ||||
|     def self.attribute_map | ||||
|       { | ||||
|         :'enum_string' => :'enum_string', | ||||
|         :'enum_integer' => :'enum_integer', | ||||
|         :'enum_number' => :'enum_number' | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     # Attribute type mapping. | ||||
|     def self.swagger_types | ||||
|       { | ||||
|         :'enum_string' => :'String', | ||||
|         :'enum_integer' => :'Integer', | ||||
|         :'enum_number' => :'Float' | ||||
|       } | ||||
|     end | ||||
| 
 | ||||
|     # Initializes the object | ||||
|     # @param [Hash] attributes Model attributes in the form of hash | ||||
|     def initialize(attributes = {}) | ||||
|       return unless attributes.is_a?(Hash) | ||||
| 
 | ||||
|       # convert string to symbol for hash key | ||||
|       attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} | ||||
| 
 | ||||
|       if attributes.has_key?(:'enum_string') | ||||
|         self.enum_string = attributes[:'enum_string'] | ||||
|       end | ||||
| 
 | ||||
|       if attributes.has_key?(:'enum_integer') | ||||
|         self.enum_integer = attributes[:'enum_integer'] | ||||
|       end | ||||
| 
 | ||||
|       if attributes.has_key?(:'enum_number') | ||||
|         self.enum_number = attributes[:'enum_number'] | ||||
|       end | ||||
| 
 | ||||
|     end | ||||
| 
 | ||||
|     # Show invalid properties with the reasons. Usually used together with valid? | ||||
|     # @return Array for valid properies with the reasons | ||||
|     def list_invalid_properties | ||||
|       invalid_properties = Array.new | ||||
|       return invalid_properties | ||||
|     end | ||||
| 
 | ||||
|     # Check to see if the all the properties in the model are valid | ||||
|     # @return true if the model is valid | ||||
|     def valid? | ||||
|       allowed_values = ["UPPER", "lower"] | ||||
|       if @enum_string && !allowed_values.include?(@enum_string) | ||||
|         return false | ||||
|       end | ||||
|       allowed_values = ["1", "-1"] | ||||
|       if @enum_integer && !allowed_values.include?(@enum_integer) | ||||
|         return false | ||||
|       end | ||||
|       allowed_values = ["1.1", "-1.2"] | ||||
|       if @enum_number && !allowed_values.include?(@enum_number) | ||||
|         return false | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     # Custom attribute writer method checking allowed values (enum). | ||||
|     # @param [Object] enum_string Object to be assigned | ||||
|     def enum_string=(enum_string) | ||||
|       allowed_values = ["UPPER", "lower"] | ||||
|       if enum_string && !allowed_values.include?(enum_string) | ||||
|         fail ArgumentError, "invalid value for 'enum_string', must be one of #{allowed_values}." | ||||
|       end | ||||
|       @enum_string = enum_string | ||||
|     end | ||||
| 
 | ||||
|     # Custom attribute writer method checking allowed values (enum). | ||||
|     # @param [Object] enum_integer Object to be assigned | ||||
|     def enum_integer=(enum_integer) | ||||
|       allowed_values = ["1", "-1"] | ||||
|       if enum_integer && !allowed_values.include?(enum_integer) | ||||
|         fail ArgumentError, "invalid value for 'enum_integer', must be one of #{allowed_values}." | ||||
|       end | ||||
|       @enum_integer = enum_integer | ||||
|     end | ||||
| 
 | ||||
|     # Custom attribute writer method checking allowed values (enum). | ||||
|     # @param [Object] enum_number Object to be assigned | ||||
|     def enum_number=(enum_number) | ||||
|       allowed_values = ["1.1", "-1.2"] | ||||
|       if enum_number && !allowed_values.include?(enum_number) | ||||
|         fail ArgumentError, "invalid value for 'enum_number', must be one of #{allowed_values}." | ||||
|       end | ||||
|       @enum_number = enum_number | ||||
|     end | ||||
| 
 | ||||
|     # Checks equality by comparing each attribute. | ||||
|     # @param [Object] Object to be compared  | ||||
|     def ==(o) | ||||
|       return true if self.equal?(o) | ||||
|       self.class == o.class && | ||||
|           enum_string == o.enum_string && | ||||
|           enum_integer == o.enum_integer && | ||||
|           enum_number == o.enum_number | ||||
|     end | ||||
| 
 | ||||
|     # @see the `==` method | ||||
|     # @param [Object] Object to be compared  | ||||
|     def eql?(o) | ||||
|       self == o | ||||
|     end | ||||
| 
 | ||||
|     # Calculates hash code according to all attributes. | ||||
|     # @return [Fixnum] Hash code | ||||
|     def hash | ||||
|       [enum_string, enum_integer, enum_number].hash | ||||
|     end | ||||
| 
 | ||||
|     # Builds the object from hash | ||||
|     # @param [Hash] attributes Model attributes in the form of hash | ||||
|     # @return [Object] Returns the model itself | ||||
|     def build_from_hash(attributes) | ||||
|       return nil unless attributes.is_a?(Hash) | ||||
|       self.class.swagger_types.each_pair do |key, type| | ||||
|         if type =~ /^Array<(.*)>/i | ||||
|           # check to ensure the input is an array given that the the attribute | ||||
|           # is documented as an array but the input is not | ||||
|           if attributes[self.class.attribute_map[key]].is_a?(Array) | ||||
|             self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) | ||||
|           end | ||||
|         elsif !attributes[self.class.attribute_map[key]].nil? | ||||
|           self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) | ||||
|         end # or else data not found in attributes(hash), not an issue as the data can be optional | ||||
|       end | ||||
| 
 | ||||
|       self | ||||
|     end | ||||
| 
 | ||||
|     # Deserializes the data based on type | ||||
|     # @param string type Data type | ||||
|     # @param string value Value to be deserialized | ||||
|     # @return [Object] Deserialized data | ||||
|     def _deserialize(type, value) | ||||
|       case type.to_sym | ||||
|       when :DateTime | ||||
|         DateTime.parse(value) | ||||
|       when :Date | ||||
|         Date.parse(value) | ||||
|       when :String | ||||
|         value.to_s | ||||
|       when :Integer | ||||
|         value.to_i | ||||
|       when :Float | ||||
|         value.to_f | ||||
|       when :BOOLEAN | ||||
|         if value.to_s =~ /^(true|t|yes|y|1)$/i | ||||
|           true | ||||
|         else | ||||
|           false | ||||
|         end | ||||
|       when :Object | ||||
|         # generic object (usually a Hash), return directly | ||||
|         value | ||||
|       when /\AArray<(?<inner_type>.+)>\z/ | ||||
|         inner_type = Regexp.last_match[:inner_type] | ||||
|         value.map { |v| _deserialize(inner_type, v) } | ||||
|       when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/ | ||||
|         k_type = Regexp.last_match[:k_type] | ||||
|         v_type = Regexp.last_match[:v_type] | ||||
|         {}.tap do |hash| | ||||
|           value.each do |k, v| | ||||
|             hash[_deserialize(k_type, k)] = _deserialize(v_type, v) | ||||
|           end | ||||
|         end | ||||
|       else # model | ||||
|         temp_model = Petstore.const_get(type).new | ||||
|         temp_model.build_from_hash(value) | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     # Returns the string representation of the object | ||||
|     # @return [String] String presentation of the object | ||||
|     def to_s | ||||
|       to_hash.to_s | ||||
|     end | ||||
| 
 | ||||
|     # to_body is an alias to to_hash (backward compatibility) | ||||
|     # @return [Hash] Returns the object in the form of hash | ||||
|     def to_body | ||||
|       to_hash | ||||
|     end | ||||
| 
 | ||||
|     # Returns the object in the form of hash | ||||
|     # @return [Hash] Returns the object in the form of hash | ||||
|     def to_hash | ||||
|       hash = {} | ||||
|       self.class.attribute_map.each_pair do |attr, param| | ||||
|         value = self.send(attr) | ||||
|         next if value.nil? | ||||
|         hash[param] = _to_hash(value) | ||||
|       end | ||||
|       hash | ||||
|     end | ||||
| 
 | ||||
|     # Outputs non-array value in the form of hash | ||||
|     # For object, use to_hash. Otherwise, just return the value | ||||
|     # @param [Object] value Any valid value  | ||||
|     # @return [Hash] Returns the value in the form of hash | ||||
|     def _to_hash(value) | ||||
|       if value.is_a?(Array) | ||||
|         value.compact.map{ |v| _to_hash(v) } | ||||
|       elsif value.is_a?(Hash) | ||||
|         {}.tap do |hash| | ||||
|           value.each { |k, v| hash[k] = _to_hash(v) } | ||||
|         end | ||||
|       elsif value.respond_to? :to_hash | ||||
|         value.to_hash | ||||
|       else | ||||
|         value | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|   end | ||||
| end | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user