forked from loafle/openapi-generator-original
		
	Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0
This commit is contained in:
		
						commit
						03b764d404
					
				
							
								
								
									
										36
									
								
								bin/ruby-petstore.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								bin/ruby-petstore.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,36 @@
 | 
				
			|||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SCRIPT="$0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					while [ -h "$SCRIPT" ] ; do
 | 
				
			||||||
 | 
					  ls=`ls -ld "$SCRIPT"`
 | 
				
			||||||
 | 
					  link=`expr "$ls" : '.*-> \(.*\)$'`
 | 
				
			||||||
 | 
					  if expr "$link" : '/.*' > /dev/null; then
 | 
				
			||||||
 | 
					    SCRIPT="$link"
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    SCRIPT=`dirname "$SCRIPT"`/"$link"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ ! -d "${APP_DIR}" ]; then
 | 
				
			||||||
 | 
					  APP_DIR=`dirname "$SCRIPT"`/..
 | 
				
			||||||
 | 
					  APP_DIR=`cd "${APP_DIR}"; pwd`
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					root=./modules/swagger-codegen-distribution/pom.xml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# gets version of swagger-codegen
 | 
				
			||||||
 | 
					version=$(sed '/<project>/,/<\/project>/d;/<version>/!d;s/ *<\/\?version> *//g' $root | sed -n '2p' | sed -e 's,.*<version>\([^<]*\)</version>.*,\1,g')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					executable="./modules/swagger-codegen-distribution/target/swagger-codegen-distribution-$version.jar"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ ! -f "$executable" ]
 | 
				
			||||||
 | 
					then
 | 
				
			||||||
 | 
					  mvn clean package
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# if you've executed sbt assembly previously it will use that instead.
 | 
				
			||||||
 | 
					export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
 | 
				
			||||||
 | 
					ags="$@ -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l ruby -o samples/client/petstore/ruby"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					java $JAVA_OPTS -jar $executable $ags
 | 
				
			||||||
@ -0,0 +1,120 @@
 | 
				
			|||||||
 | 
					package com.wordnik.swagger.codegen.languages;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.wordnik.swagger.codegen.*;
 | 
				
			||||||
 | 
					import com.wordnik.swagger.util.Json;
 | 
				
			||||||
 | 
					import com.wordnik.swagger.models.properties.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
 | 
				
			||||||
 | 
					  protected String invokerPackage = "com.wordnik.client";
 | 
				
			||||||
 | 
					  protected String groupId = "com.wordnik";
 | 
				
			||||||
 | 
					  protected String artifactId = "swagger-client";
 | 
				
			||||||
 | 
					  protected String artifactVersion = "1.0.0";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public CodegenType getTag() {
 | 
				
			||||||
 | 
					    return CodegenType.CLIENT;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public String getName() {
 | 
				
			||||||
 | 
					    return "ruby";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public String getHelp() {
 | 
				
			||||||
 | 
					    return "Generates a Ruby client library.";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public RubyClientCodegen() {
 | 
				
			||||||
 | 
					    super();
 | 
				
			||||||
 | 
					    modelPackage = "models";
 | 
				
			||||||
 | 
					    apiPackage = "lib";
 | 
				
			||||||
 | 
					    outputFolder = "generated-code/ruby";
 | 
				
			||||||
 | 
					    modelTemplateFiles.put("model.mustache", ".rb");
 | 
				
			||||||
 | 
					    apiTemplateFiles.put("api.mustache", ".rb");
 | 
				
			||||||
 | 
					    templateDir = "ruby";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typeMapping.clear();
 | 
				
			||||||
 | 
					    languageSpecificPrimitives.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    reservedWords = new HashSet<String> (
 | 
				
			||||||
 | 
					      Arrays.asList(
 | 
				
			||||||
 | 
					        "int")
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    additionalProperties.put("invokerPackage", invokerPackage);
 | 
				
			||||||
 | 
					    additionalProperties.put("groupId", groupId);
 | 
				
			||||||
 | 
					    additionalProperties.put("artifactId", artifactId);
 | 
				
			||||||
 | 
					    additionalProperties.put("artifactVersion", artifactVersion);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    languageSpecificPrimitives.add("int");
 | 
				
			||||||
 | 
					    languageSpecificPrimitives.add("array");
 | 
				
			||||||
 | 
					    languageSpecificPrimitives.add("map");
 | 
				
			||||||
 | 
					    languageSpecificPrimitives.add("string");
 | 
				
			||||||
 | 
					    languageSpecificPrimitives.add("DateTime");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    typeMapping.put("long", "int");
 | 
				
			||||||
 | 
					    typeMapping.put("integer", "int");
 | 
				
			||||||
 | 
					    typeMapping.put("Array", "array");
 | 
				
			||||||
 | 
					    typeMapping.put("String", "string");
 | 
				
			||||||
 | 
					    typeMapping.put("List", "array");
 | 
				
			||||||
 | 
					    typeMapping.put("map", "map");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    supportingFiles.add(new SupportingFile("swagger.mustache", "", "lib/swagger.rb"));
 | 
				
			||||||
 | 
					    supportingFiles.add(new SupportingFile("monkey.mustache", "", "lib/monkey.rb"));
 | 
				
			||||||
 | 
					    supportingFiles.add(new SupportingFile("swagger/request.mustache", "", "lib/swagger/request.rb"));
 | 
				
			||||||
 | 
					    supportingFiles.add(new SupportingFile("swagger/response.mustache", "", "lib/swagger/response.rb"));
 | 
				
			||||||
 | 
					    supportingFiles.add(new SupportingFile("swagger/version.mustache", "", "lib/swagger/version.rb"));
 | 
				
			||||||
 | 
					    supportingFiles.add(new SupportingFile("swagger/configuration.mustache", "", "lib/swagger/configuration.rb"));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Override
 | 
				
			||||||
 | 
					  public String escapeReservedWord(String name) {
 | 
				
			||||||
 | 
					    return "_" + name;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Override
 | 
				
			||||||
 | 
					  public String apiFileFolder() {
 | 
				
			||||||
 | 
					    return outputFolder + "/" + apiPackage().replace('.', File.separatorChar);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public String modelFileFolder() {
 | 
				
			||||||
 | 
					    return outputFolder + "/" + modelPackage().replace('.', File.separatorChar);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Override
 | 
				
			||||||
 | 
					  public String getTypeDeclaration(Property p) {
 | 
				
			||||||
 | 
					    if(p instanceof ArrayProperty) {
 | 
				
			||||||
 | 
					      ArrayProperty ap = (ArrayProperty) p;
 | 
				
			||||||
 | 
					      Property inner = ap.getItems();
 | 
				
			||||||
 | 
					      return getSwaggerType(p) + "[" + getTypeDeclaration(inner) + "]";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else if (p instanceof MapProperty) {
 | 
				
			||||||
 | 
					      MapProperty mp = (MapProperty) p;
 | 
				
			||||||
 | 
					      Property inner = mp.getAdditionalProperties();
 | 
				
			||||||
 | 
					      return getSwaggerType(p) + "[string," + getTypeDeclaration(inner) + "]";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return super.getTypeDeclaration(p);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Override
 | 
				
			||||||
 | 
					  public String getSwaggerType(Property p) {
 | 
				
			||||||
 | 
					    String swaggerType = super.getSwaggerType(p);
 | 
				
			||||||
 | 
					    String type = null;
 | 
				
			||||||
 | 
					    if(typeMapping.containsKey(swaggerType)) {
 | 
				
			||||||
 | 
					      type = typeMapping.get(swaggerType);
 | 
				
			||||||
 | 
					      if(languageSpecificPrimitives.contains(type)) {
 | 
				
			||||||
 | 
					        return type;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      type = swaggerType;
 | 
				
			||||||
 | 
					    if(type == null)
 | 
				
			||||||
 | 
					      return null;
 | 
				
			||||||
 | 
					    return type;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public String toDefaultValue(Property p) {
 | 
				
			||||||
 | 
					    return "null";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -11,4 +11,5 @@ com.wordnik.swagger.codegen.languages.StaticHtmlGenerator
 | 
				
			|||||||
com.wordnik.swagger.codegen.languages.SwaggerGenerator
 | 
					com.wordnik.swagger.codegen.languages.SwaggerGenerator
 | 
				
			||||||
com.wordnik.swagger.codegen.languages.TizenClientCodegen
 | 
					com.wordnik.swagger.codegen.languages.TizenClientCodegen
 | 
				
			||||||
com.wordnik.swagger.codegen.languages.PhpClientCodegen
 | 
					com.wordnik.swagger.codegen.languages.PhpClientCodegen
 | 
				
			||||||
 | 
					com.wordnik.swagger.codegen.languages.RubyClientCodegen
 | 
				
			||||||
com.wordnik.swagger.codegen.languages.PythonClientCodegen
 | 
					com.wordnik.swagger.codegen.languages.PythonClientCodegen
 | 
				
			||||||
 | 
				
			|||||||
@ -48,6 +48,18 @@ class APIClient {
 | 
				
			|||||||
    $this->headerValue = $headerValue;
 | 
					    $this->headerValue = $headerValue;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Set the user agent of the API client
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   *  @param string $user_agent The user agent of the API client
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function setUserAgent($user_agent) {
 | 
				
			||||||
 | 
					    if (!is_string($user_agent)) {
 | 
				
			||||||
 | 
					      throw new Exception('User-agent must be a string.');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    $this->user_agent= $user_agent;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   *  @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
 | 
					   *  @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
 | 
				
			||||||
  */
 | 
					  */
 | 
				
			||||||
@ -58,7 +70,6 @@ class APIClient {
 | 
				
			|||||||
    $this->curl_timout = $seconds;
 | 
					    $this->curl_timout = $seconds;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * @param string $resourcePath path to method endpoint
 | 
					   * @param string $resourcePath path to method endpoint
 | 
				
			||||||
   * @param string $method method to call
 | 
					   * @param string $method method to call
 | 
				
			||||||
@ -121,6 +132,13 @@ class APIClient {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    curl_setopt($curl, CURLOPT_URL, $url);
 | 
					    curl_setopt($curl, CURLOPT_URL, $url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Set user agent
 | 
				
			||||||
 | 
					    if ($this->user_agent) {
 | 
				
			||||||
 | 
					      curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
 | 
				
			||||||
 | 
					    } else { // use PHP-Swagger as the default user agent
 | 
				
			||||||
 | 
					      curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Make the request
 | 
					    // Make the request
 | 
				
			||||||
    $response = curl_exec($curl);
 | 
					    $response = curl_exec($curl);
 | 
				
			||||||
    $response_info = curl_getinfo($curl);
 | 
					    $response_info = curl_getinfo($curl);
 | 
				
			||||||
@ -129,11 +147,14 @@ class APIClient {
 | 
				
			|||||||
    if ($response_info['http_code'] == 0) {
 | 
					    if ($response_info['http_code'] == 0) {
 | 
				
			||||||
      throw new APIClientException("TIMEOUT: api call to " . $url .
 | 
					      throw new APIClientException("TIMEOUT: api call to " . $url .
 | 
				
			||||||
        " took more than 5s to return", 0, $response_info, $response);
 | 
					        " took more than 5s to return", 0, $response_info, $response);
 | 
				
			||||||
    } else if ($response_info['http_code'] == 200) {
 | 
					    } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
 | 
				
			||||||
      $data = json_decode($response);
 | 
					      $data = json_decode($response);
 | 
				
			||||||
 | 
					      if (json_last_error() > 0) { // if response is a string
 | 
				
			||||||
 | 
					        $data = $response;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    } else if ($response_info['http_code'] == 401) {
 | 
					    } else if ($response_info['http_code'] == 401) {
 | 
				
			||||||
      throw new APIClientException("Unauthorized API request to " . $url .
 | 
					      throw new APIClientException("Unauthorized API request to " . $url .
 | 
				
			||||||
          ": " . json_decode($response)->message, 0, $response_info, $response);
 | 
					          ": " . serialize($response), 0, $response_info, $response);
 | 
				
			||||||
    } else if ($response_info['http_code'] == 404) {
 | 
					    } else if ($response_info['http_code'] == 404) {
 | 
				
			||||||
      $data = null;
 | 
					      $data = null;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
@ -178,7 +199,7 @@ class APIClient {
 | 
				
			|||||||
   * @return string the serialized object
 | 
					   * @return string the serialized object
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public static function toPathValue($value) {
 | 
					  public static function toPathValue($value) {
 | 
				
			||||||
      return rawurlencode($value);
 | 
					      return rawurlencode(toString($value));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
@ -193,20 +214,48 @@ class APIClient {
 | 
				
			|||||||
        if (is_array($object)) {
 | 
					        if (is_array($object)) {
 | 
				
			||||||
            return implode(',', $object);
 | 
					            return implode(',', $object);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return $object;
 | 
					            return toString($object);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Just pass through the header value for now. Placeholder in case we
 | 
					   * Take value and turn it into a string suitable for inclusion in
 | 
				
			||||||
   * find out we need to do something with header values.
 | 
					   * the header. If it's a string, pass through unchanged
 | 
				
			||||||
 | 
					   * If it's a datetime object, format it in ISO8601
 | 
				
			||||||
   * @param string $value a string which will be part of the header
 | 
					   * @param string $value a string which will be part of the header
 | 
				
			||||||
   * @return string the header string
 | 
					   * @return string the header string
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public static function toHeaderValue($value) {
 | 
					  public static function toHeaderValue($value) {
 | 
				
			||||||
      return $value;
 | 
					      return toString($value);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Take value and turn it into a string suitable for inclusion in
 | 
				
			||||||
 | 
					   * the http body (form parameter). If it's a string, pass through unchanged
 | 
				
			||||||
 | 
					   * If it's a datetime object, format it in ISO8601
 | 
				
			||||||
 | 
					   * @param string $value the value of the form parameter
 | 
				
			||||||
 | 
					   * @return string the form string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public static function toFormValue($value) {
 | 
				
			||||||
 | 
					      return toString($value);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Take value and turn it into a string suitable for inclusion in
 | 
				
			||||||
 | 
					   * the parameter. If it's a string, pass through unchanged
 | 
				
			||||||
 | 
					   * If it's a datetime object, format it in ISO8601
 | 
				
			||||||
 | 
					   * @param string $value the value of the parameter
 | 
				
			||||||
 | 
					   * @return string the header string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public static function toString($value) {
 | 
				
			||||||
 | 
					    if ($value instanceof \DateTime) { // datetime in ISO8601 format
 | 
				
			||||||
 | 
					      return $value->format(\DateTime::ISO8601);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					      return $value;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Deserialize a JSON string into an object
 | 
					   * Deserialize a JSON string into an object
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
 | 
				
			|||||||
@ -63,7 +63,7 @@ class {{classname}} {
 | 
				
			|||||||
  		}{{/pathParams}}
 | 
					  		}{{/pathParams}}
 | 
				
			||||||
      {{#formParams}}// form params
 | 
					      {{#formParams}}// form params
 | 
				
			||||||
      if (${{paramName}} !== null) {
 | 
					      if (${{paramName}} !== null) {
 | 
				
			||||||
        $formParams['{{baseName}}'] = {{#isFile}}'@' . {{/isFile}}${{paramName}};
 | 
					        $formParams['{{baseName}}'] = {{#isFile}}'@' . {{/isFile}}$this->apiClient->toFormValue(${{paramName}});
 | 
				
			||||||
      }{{/formParams}}
 | 
					      }{{/formParams}}
 | 
				
			||||||
      {{#bodyParams}}// body params
 | 
					      {{#bodyParams}}// body params
 | 
				
			||||||
      $body = null;
 | 
					      $body = null;
 | 
				
			||||||
 | 
				
			|||||||
@ -7,9 +7,8 @@ class {{classname}}
 | 
				
			|||||||
  def self.attribute_map
 | 
					  def self.attribute_map
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      {{#vars}}
 | 
					      {{#vars}}
 | 
				
			||||||
      :{{{name}}} => :{{{baseName}}}{{#hasMore}},
 | 
					      :{{{name}}} => :{{{baseName}}}{{#hasMore}},{{/hasMore}}
 | 
				
			||||||
      {{/hasMore}}
 | 
					      {{/vars}}
 | 
				
			||||||
    {{/vars}}{{newline}}
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -19,14 +18,14 @@ class {{classname}}
 | 
				
			|||||||
    {{#vars}}
 | 
					    {{#vars}}
 | 
				
			||||||
    if self.class.attribute_map[:"{{{name}}}"]
 | 
					    if self.class.attribute_map[:"{{{name}}}"]
 | 
				
			||||||
      {{#isContainer}}
 | 
					      {{#isContainer}}
 | 
				
			||||||
        if (value = attributes["{{{baseName}}}"]).is_a?(Array)
 | 
					      if (value = attributes["{{{baseName}}}"]).is_a?(Array)
 | 
				
			||||||
          @{{{name}}} = value{{#complexType}}.map{ |v| {{complexType}}.new(v) }{{/complexType}}{{newline}}
 | 
					        @{{{name}}} = value{{#complexType}}.map{ |v| {{complexType}}.new(v) }{{/complexType}}{{newline}}
 | 
				
			||||||
        end
 | 
					      end
 | 
				
			||||||
      {{/isContainer}}{{^isContainer}}
 | 
					      {{/isContainer}}{{^isContainer}}
 | 
				
			||||||
        @{{{name}}} = attributes["{{{baseName}}}"]
 | 
					      @{{{name}}} = attributes["{{{baseName}}}"]
 | 
				
			||||||
    {{/isContainer}}
 | 
					      {{/isContainer}}
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    {{/vars}}{{newline}}
 | 
					    {{/vars}}
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def to_body
 | 
					  def to_body
 | 
				
			||||||
 | 
				
			|||||||
@ -304,10 +304,10 @@ class PetApi {
 | 
				
			|||||||
  		}
 | 
					  		}
 | 
				
			||||||
      // form params
 | 
					      // form params
 | 
				
			||||||
      if ($name !== null) {
 | 
					      if ($name !== null) {
 | 
				
			||||||
        $formParams['name'] = $name;
 | 
					        $formParams['name'] = $this->apiClient->toFormValue($name);
 | 
				
			||||||
      }// form params
 | 
					      }// form params
 | 
				
			||||||
      if ($status !== null) {
 | 
					      if ($status !== null) {
 | 
				
			||||||
        $formParams['status'] = $status;
 | 
					        $formParams['status'] = $this->apiClient->toFormValue($status);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -408,10 +408,10 @@ class PetApi {
 | 
				
			|||||||
  		}
 | 
					  		}
 | 
				
			||||||
      // form params
 | 
					      // form params
 | 
				
			||||||
      if ($additionalMetadata !== null) {
 | 
					      if ($additionalMetadata !== null) {
 | 
				
			||||||
        $formParams['additionalMetadata'] = $additionalMetadata;
 | 
					        $formParams['additionalMetadata'] = $this->apiClient->toFormValue($additionalMetadata);
 | 
				
			||||||
      }// form params
 | 
					      }// form params
 | 
				
			||||||
      if ($file !== null) {
 | 
					      if ($file !== null) {
 | 
				
			||||||
        $formParams['file'] = '@' . $file;
 | 
					        $formParams['file'] = '@' . $this->apiClient->toFormValue($file);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -48,6 +48,18 @@ class APIClient {
 | 
				
			|||||||
    $this->headerValue = $headerValue;
 | 
					    $this->headerValue = $headerValue;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Set the user agent of the API client
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   *  @param string $user_agent The user agent of the API client
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function setUserAgent($user_agent) {
 | 
				
			||||||
 | 
					    if (!is_string($user_agent)) {
 | 
				
			||||||
 | 
					      throw new Exception('User-agent must be a string.');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    $this->user_agent= $user_agent;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   *  @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
 | 
					   *  @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
 | 
				
			||||||
  */
 | 
					  */
 | 
				
			||||||
@ -58,7 +70,6 @@ class APIClient {
 | 
				
			|||||||
    $this->curl_timout = $seconds;
 | 
					    $this->curl_timout = $seconds;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * @param string $resourcePath path to method endpoint
 | 
					   * @param string $resourcePath path to method endpoint
 | 
				
			||||||
   * @param string $method method to call
 | 
					   * @param string $method method to call
 | 
				
			||||||
@ -121,25 +132,35 @@ class APIClient {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    curl_setopt($curl, CURLOPT_URL, $url);
 | 
					    curl_setopt($curl, CURLOPT_URL, $url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Set user agent
 | 
				
			||||||
 | 
					    if ($this->user_agent) {
 | 
				
			||||||
 | 
					      curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
 | 
				
			||||||
 | 
					    } else { // use PHP-Swagger as the default user agent
 | 
				
			||||||
 | 
					      curl_setopt($curl, CURLOPT_USERAGENT, 'PHP-Swagger');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Make the request
 | 
					    // Make the request
 | 
				
			||||||
    $response = curl_exec($curl);
 | 
					    $response = curl_exec($curl);
 | 
				
			||||||
    $response_info = curl_getinfo($curl);
 | 
					    $response_info = curl_getinfo($curl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Handle the response
 | 
					    // Handle the response
 | 
				
			||||||
    if ($response_info['http_code'] == 0) {
 | 
					    if ($response_info['http_code'] == 0) {
 | 
				
			||||||
      throw new Exception("TIMEOUT: api call to " . $url .
 | 
					      throw new APIClientException("TIMEOUT: api call to " . $url .
 | 
				
			||||||
        " took more than 5s to return" );
 | 
					        " took more than 5s to return", 0, $response_info, $response);
 | 
				
			||||||
    } else if ($response_info['http_code'] == 200) {
 | 
					    } else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
 | 
				
			||||||
      $data = json_decode($response);
 | 
					      $data = json_decode($response);
 | 
				
			||||||
 | 
					      if (json_last_error() > 0) { // if response is a string
 | 
				
			||||||
 | 
					        $data = $response;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    } else if ($response_info['http_code'] == 401) {
 | 
					    } else if ($response_info['http_code'] == 401) {
 | 
				
			||||||
      throw new Exception("Unauthorized API request to " . $url .
 | 
					      throw new APIClientException("Unauthorized API request to " . $url .
 | 
				
			||||||
          ": ".json_decode($response)->message );
 | 
					          ": " . serialize($response), 0, $response_info, $response);
 | 
				
			||||||
    } else if ($response_info['http_code'] == 404) {
 | 
					    } else if ($response_info['http_code'] == 404) {
 | 
				
			||||||
      $data = null;
 | 
					      $data = null;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      throw new Exception("Can't connect to the api: " . $url .
 | 
					      throw new APIClientException("Can't connect to the api: " . $url .
 | 
				
			||||||
        " response code: " .
 | 
					        " response code: " .
 | 
				
			||||||
        $response_info['http_code']);
 | 
					        $response_info['http_code'], 0, $response_info, $response);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return $data;
 | 
					    return $data;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -178,7 +199,7 @@ class APIClient {
 | 
				
			|||||||
   * @return string the serialized object
 | 
					   * @return string the serialized object
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public static function toPathValue($value) {
 | 
					  public static function toPathValue($value) {
 | 
				
			||||||
      return rawurlencode($value);
 | 
					      return rawurlencode(toString($value));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
@ -193,20 +214,48 @@ class APIClient {
 | 
				
			|||||||
        if (is_array($object)) {
 | 
					        if (is_array($object)) {
 | 
				
			||||||
            return implode(',', $object);
 | 
					            return implode(',', $object);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return $object;
 | 
					            return toString($object);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Just pass through the header value for now. Placeholder in case we
 | 
					   * Take value and turn it into a string suitable for inclusion in
 | 
				
			||||||
   * find out we need to do something with header values.
 | 
					   * the header. If it's a string, pass through unchanged
 | 
				
			||||||
 | 
					   * If it's a datetime object, format it in ISO8601
 | 
				
			||||||
   * @param string $value a string which will be part of the header
 | 
					   * @param string $value a string which will be part of the header
 | 
				
			||||||
   * @return string the header string
 | 
					   * @return string the header string
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public static function toHeaderValue($value) {
 | 
					  public static function toHeaderValue($value) {
 | 
				
			||||||
      return $value;
 | 
					      return toString($value);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Take value and turn it into a string suitable for inclusion in
 | 
				
			||||||
 | 
					   * the http body (form parameter). If it's a string, pass through unchanged
 | 
				
			||||||
 | 
					   * If it's a datetime object, format it in ISO8601
 | 
				
			||||||
 | 
					   * @param string $value the value of the form parameter
 | 
				
			||||||
 | 
					   * @return string the form string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public static function toFormValue($value) {
 | 
				
			||||||
 | 
					      return toString($value);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Take value and turn it into a string suitable for inclusion in
 | 
				
			||||||
 | 
					   * the parameter. If it's a string, pass through unchanged
 | 
				
			||||||
 | 
					   * If it's a datetime object, format it in ISO8601
 | 
				
			||||||
 | 
					   * @param string $value the value of the parameter
 | 
				
			||||||
 | 
					   * @return string the header string
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public static function toString($value) {
 | 
				
			||||||
 | 
					    if ($value instanceof \DateTime) { // datetime in ISO8601 format
 | 
				
			||||||
 | 
					      return $value->format(\DateTime::ISO8601);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					      return $value;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Deserialize a JSON string into an object
 | 
					   * Deserialize a JSON string into an object
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
@ -257,3 +306,20 @@ class APIClient {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class APIClientException extends Exception {
 | 
				
			||||||
 | 
					  protected $response, $response_info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function __construct($message="", $code=0, $response_info=null, $response=null) {
 | 
				
			||||||
 | 
					    parent::__construct($message, $code);
 | 
				
			||||||
 | 
					    $this->response_info = $response_info;
 | 
				
			||||||
 | 
					    $this->response = $response;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function getResponse() {
 | 
				
			||||||
 | 
					    return $this->response;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public function getResponseInfo() {
 | 
				
			||||||
 | 
					    return $this->response_info;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										359
									
								
								samples/client/petstore/ruby/lib/PetApi.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										359
									
								
								samples/client/petstore/ruby/lib/PetApi.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,359 @@
 | 
				
			|||||||
 | 
					require "uri"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class PetApi
 | 
				
			||||||
 | 
					  basePath = "http://petstore.swagger.io/v2"
 | 
				
			||||||
 | 
					  # apiInvoker = APIInvoker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.escapeString(string)
 | 
				
			||||||
 | 
					    URI.encode(string.to_s)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  def self.updatePet (body, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :body => body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if body != nil
 | 
				
			||||||
 | 
					      if body.is_a?(Array)
 | 
				
			||||||
 | 
					        array = Array.new
 | 
				
			||||||
 | 
					        body.each do |item|
 | 
				
			||||||
 | 
					          if item.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
					            array.push item.to_body
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            array.push item
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        post_body = array
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else 
 | 
				
			||||||
 | 
					        if body.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
						        post_body = body.to_body
 | 
				
			||||||
 | 
						      else
 | 
				
			||||||
 | 
						        post_body = body
 | 
				
			||||||
 | 
						      end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.addPet (body, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :body => body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if body != nil
 | 
				
			||||||
 | 
					      if body.is_a?(Array)
 | 
				
			||||||
 | 
					        array = Array.new
 | 
				
			||||||
 | 
					        body.each do |item|
 | 
				
			||||||
 | 
					          if item.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
					            array.push item.to_body
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            array.push item
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        post_body = array
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else 
 | 
				
			||||||
 | 
					        if body.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
						        post_body = body.to_body
 | 
				
			||||||
 | 
						      else
 | 
				
			||||||
 | 
						        post_body = body
 | 
				
			||||||
 | 
						      end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.findPetsByStatus (status, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = [:status]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :status => status
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet/findByStatus".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response.map {|response| Pet.new(response) }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.findPetsByTags (tags, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = [:tags]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :tags => tags
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet/findByTags".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response.map {|response| Pet.new(response) }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.getPetById (petId, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :petId => petId
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					     Pet.new(response)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.updatePetWithForm (petId,name,status, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :petId => petId,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :name => name,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :status => status
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.deletePet (api_key,petId, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :api_key => api_key,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :petId => petId
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = {
 | 
				
			||||||
 | 
					      api_key: api_key,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.uploadFile (petId,additionalMetadata,file, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :petId => petId,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :additionalMetadata => additionalMetadata,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :file => file
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										176
									
								
								samples/client/petstore/ruby/lib/StoreApi.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								samples/client/petstore/ruby/lib/StoreApi.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,176 @@
 | 
				
			|||||||
 | 
					require "uri"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class StoreApi
 | 
				
			||||||
 | 
					  basePath = "http://petstore.swagger.io/v2"
 | 
				
			||||||
 | 
					  # apiInvoker = APIInvoker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.escapeString(string)
 | 
				
			||||||
 | 
					    URI.encode(string.to_s)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  def self.getInventory ( opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/store/inventory".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response.map {|response| map.new(response) }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.placeOrder (body, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :body => body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/store/order".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if body != nil
 | 
				
			||||||
 | 
					      if body.is_a?(Array)
 | 
				
			||||||
 | 
					        array = Array.new
 | 
				
			||||||
 | 
					        body.each do |item|
 | 
				
			||||||
 | 
					          if item.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
					            array.push item.to_body
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            array.push item
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        post_body = array
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else 
 | 
				
			||||||
 | 
					        if body.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
						        post_body = body.to_body
 | 
				
			||||||
 | 
						      else
 | 
				
			||||||
 | 
						        post_body = body
 | 
				
			||||||
 | 
						      end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					     Order.new(response)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.getOrderById (orderId, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :orderId => orderId
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(orderId))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					     Order.new(response)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.deleteOrder (orderId, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :orderId => orderId
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(orderId))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										384
									
								
								samples/client/petstore/ruby/lib/UserApi.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										384
									
								
								samples/client/petstore/ruby/lib/UserApi.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,384 @@
 | 
				
			|||||||
 | 
					require "uri"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class UserApi
 | 
				
			||||||
 | 
					  basePath = "http://petstore.swagger.io/v2"
 | 
				
			||||||
 | 
					  # apiInvoker = APIInvoker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.escapeString(string)
 | 
				
			||||||
 | 
					    URI.encode(string.to_s)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  def self.createUser (body, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :body => body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if body != nil
 | 
				
			||||||
 | 
					      if body.is_a?(Array)
 | 
				
			||||||
 | 
					        array = Array.new
 | 
				
			||||||
 | 
					        body.each do |item|
 | 
				
			||||||
 | 
					          if item.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
					            array.push item.to_body
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            array.push item
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        post_body = array
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else 
 | 
				
			||||||
 | 
					        if body.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
						        post_body = body.to_body
 | 
				
			||||||
 | 
						      else
 | 
				
			||||||
 | 
						        post_body = body
 | 
				
			||||||
 | 
						      end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.createUsersWithArrayInput (body, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :body => body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user/createWithArray".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if body != nil
 | 
				
			||||||
 | 
					      if body.is_a?(Array)
 | 
				
			||||||
 | 
					        array = Array.new
 | 
				
			||||||
 | 
					        body.each do |item|
 | 
				
			||||||
 | 
					          if item.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
					            array.push item.to_body
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            array.push item
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        post_body = array
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else 
 | 
				
			||||||
 | 
					        if body.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
						        post_body = body.to_body
 | 
				
			||||||
 | 
						      else
 | 
				
			||||||
 | 
						        post_body = body
 | 
				
			||||||
 | 
						      end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.createUsersWithListInput (body, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :body => body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user/createWithList".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if body != nil
 | 
				
			||||||
 | 
					      if body.is_a?(Array)
 | 
				
			||||||
 | 
					        array = Array.new
 | 
				
			||||||
 | 
					        body.each do |item|
 | 
				
			||||||
 | 
					          if item.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
					            array.push item.to_body
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            array.push item
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        post_body = array
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else 
 | 
				
			||||||
 | 
					        if body.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
						        post_body = body.to_body
 | 
				
			||||||
 | 
						      else
 | 
				
			||||||
 | 
						        post_body = body
 | 
				
			||||||
 | 
						      end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.loginUser (username,password, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = [:username,:password]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :username => username,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :password => password
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user/login".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					     string.new(response)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.logoutUser ( opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user/logout".sub('{format}','json')
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.getUserByName (username, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :username => username
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
 | 
				
			||||||
 | 
					     User.new(response)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.updateUser (username,body, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :username => username,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :body => body
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if body != nil
 | 
				
			||||||
 | 
					      if body.is_a?(Array)
 | 
				
			||||||
 | 
					        array = Array.new
 | 
				
			||||||
 | 
					        body.each do |item|
 | 
				
			||||||
 | 
					          if item.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
					            array.push item.to_body
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            array.push item
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        post_body = array
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      else 
 | 
				
			||||||
 | 
					        if body.respond_to?("to_body".to_sym)
 | 
				
			||||||
 | 
						        post_body = body.to_body
 | 
				
			||||||
 | 
						      else
 | 
				
			||||||
 | 
						        post_body = body
 | 
				
			||||||
 | 
						      end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def self.deleteUser (username, opts={})
 | 
				
			||||||
 | 
					    query_param_keys = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # set default values and merge with input
 | 
				
			||||||
 | 
					    options = {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      :username => username
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    }.merge(opts)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #resource path
 | 
				
			||||||
 | 
					    path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # pull querystring keys from options
 | 
				
			||||||
 | 
					    queryopts = options.select do |key,value|
 | 
				
			||||||
 | 
					      query_param_keys.include? key
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    headers = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    post_body = nil
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
@ -87,4 +87,4 @@
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
# end
 | 
					# end
 | 
				
			||||||
@ -81,4 +81,4 @@ class ServerError < StandardError
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ClientError < StandardError
 | 
					class ClientError < StandardError
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@ -19,4 +19,4 @@ module Swagger
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@ -196,4 +196,4 @@ module Swagger
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@ -67,4 +67,4 @@ module Swagger
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@ -2,4 +2,3 @@ module Swagger
 | 
				
			|||||||
  VERSION = "4.06.08"
 | 
					  VERSION = "4.06.08"
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,26 +1,33 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class Category
 | 
					class Category
 | 
				
			||||||
  attr_accessor :id, :name
 | 
					  attr_accessor :id, :name
 | 
				
			||||||
 | 
					 | 
				
			||||||
  # :internal => :external
 | 
					  # :internal => :external
 | 
				
			||||||
  def self.attribute_map
 | 
					  def self.attribute_map
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :id => :id,
 | 
					      :id => :id,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :name => :name
 | 
					      :name => :name
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def initialize(attributes = {})
 | 
					  def initialize(attributes = {})
 | 
				
			||||||
    return if attributes.empty?
 | 
					    return if attributes.empty?
 | 
				
			||||||
    # Morph attribute keys into undescored rubyish style
 | 
					    # Morph attribute keys into undescored rubyish style
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if self.class.attribute_map[:"id"]
 | 
					    if self.class.attribute_map[:"id"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      @id = attributes["id"]
 | 
					      @id = attributes["id"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"name"]
 | 
					    end
 | 
				
			||||||
      @name = attributes["name"]
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"name"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @name = attributes["name"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def to_body
 | 
					  def to_body
 | 
				
			||||||
@ -31,4 +38,3 @@ class Category
 | 
				
			|||||||
    body
 | 
					    body
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,38 +1,65 @@
 | 
				
			|||||||
class Order
 | 
					 | 
				
			||||||
  attr_accessor :id, :pet_id, :quantity, :status, :ship_date
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Order
 | 
				
			||||||
 | 
					  attr_accessor :id, :petId, :quantity, :shipDate, :status, :complete
 | 
				
			||||||
  # :internal => :external
 | 
					  # :internal => :external
 | 
				
			||||||
  def self.attribute_map
 | 
					  def self.attribute_map
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :id => :id,
 | 
					      :id => :id,
 | 
				
			||||||
      :pet_id => :petId,
 | 
					      
 | 
				
			||||||
 | 
					      :petId => :petId,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :quantity => :quantity,
 | 
					      :quantity => :quantity,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      :shipDate => :shipDate,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :status => :status,
 | 
					      :status => :status,
 | 
				
			||||||
      :ship_date => :shipDate
 | 
					      
 | 
				
			||||||
 | 
					      :complete => :complete
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def initialize(attributes = {})
 | 
					  def initialize(attributes = {})
 | 
				
			||||||
    return if attributes.empty?
 | 
					    return if attributes.empty?
 | 
				
			||||||
    # Morph attribute keys into undescored rubyish style
 | 
					    # Morph attribute keys into undescored rubyish style
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if self.class.attribute_map[:"id"]
 | 
					    if self.class.attribute_map[:"id"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      @id = attributes["id"]
 | 
					      @id = attributes["id"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"pet_id"]
 | 
					    end
 | 
				
			||||||
      @pet_id = attributes["petId"]
 | 
					    
 | 
				
			||||||
    end
 | 
					    if self.class.attribute_map[:"petId"]
 | 
				
			||||||
    if self.class.attribute_map[:"quantity"]
 | 
					      
 | 
				
			||||||
      @quantity = attributes["quantity"]
 | 
					      @petId = attributes["petId"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"status"]
 | 
					    end
 | 
				
			||||||
      @status = attributes["status"]
 | 
					    
 | 
				
			||||||
    end
 | 
					    if self.class.attribute_map[:"quantity"]
 | 
				
			||||||
    if self.class.attribute_map[:"ship_date"]
 | 
					      
 | 
				
			||||||
      @ship_date = attributes["shipDate"]
 | 
					      @quantity = attributes["quantity"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"shipDate"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @shipDate = attributes["shipDate"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"status"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @status = attributes["status"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"complete"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @complete = attributes["complete"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def to_body
 | 
					  def to_body
 | 
				
			||||||
@ -43,4 +70,3 @@ class Order
 | 
				
			|||||||
    body
 | 
					    body
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,44 +1,69 @@
 | 
				
			|||||||
class Pet
 | 
					 | 
				
			||||||
  attr_accessor :id, :category, :name, :photo_urls, :tags, :status
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Pet
 | 
				
			||||||
 | 
					  attr_accessor :id, :category, :name, :photoUrls, :tags, :status
 | 
				
			||||||
  # :internal => :external
 | 
					  # :internal => :external
 | 
				
			||||||
  def self.attribute_map
 | 
					  def self.attribute_map
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :id => :id,
 | 
					      :id => :id,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :category => :category,
 | 
					      :category => :category,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :name => :name,
 | 
					      :name => :name,
 | 
				
			||||||
      :photo_urls => :photoUrls,
 | 
					      
 | 
				
			||||||
 | 
					      :photoUrls => :photoUrls,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :tags => :tags,
 | 
					      :tags => :tags,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :status => :status
 | 
					      :status => :status
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def initialize(attributes = {})
 | 
					  def initialize(attributes = {})
 | 
				
			||||||
    return if attributes.empty?
 | 
					    return if attributes.empty?
 | 
				
			||||||
    # Morph attribute keys into undescored rubyish style
 | 
					    # Morph attribute keys into undescored rubyish style
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if self.class.attribute_map[:"id"]
 | 
					    if self.class.attribute_map[:"id"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      @id = attributes["id"]
 | 
					      @id = attributes["id"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"category"]
 | 
					    end
 | 
				
			||||||
      @category = attributes["category"]
 | 
					    
 | 
				
			||||||
    end
 | 
					    if self.class.attribute_map[:"category"]
 | 
				
			||||||
    if self.class.attribute_map[:"name"]
 | 
					      
 | 
				
			||||||
      @name = attributes["name"]
 | 
					      @category = attributes["category"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"photo_urls"]
 | 
					    end
 | 
				
			||||||
      if (value = attributes["photoUrls"]).is_a?(Array)
 | 
					    
 | 
				
			||||||
          @photo_urls = valueend
 | 
					    if self.class.attribute_map[:"name"]
 | 
				
			||||||
      end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"tags"]
 | 
					      @name = attributes["name"]
 | 
				
			||||||
      if (value = attributes["tags"]).is_a?(Array)
 | 
					      
 | 
				
			||||||
          @tags = value.map{ |v| Tag.new(v) }end
 | 
					    end
 | 
				
			||||||
      end
 | 
					    
 | 
				
			||||||
    if self.class.attribute_map[:"status"]
 | 
					    if self.class.attribute_map[:"photoUrls"]
 | 
				
			||||||
      @status = attributes["status"]
 | 
					      
 | 
				
			||||||
 | 
					      if (value = attributes["photoUrls"]).is_a?(Array)
 | 
				
			||||||
 | 
					        @photoUrls = value
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"tags"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      if (value = attributes["tags"]).is_a?(Array)
 | 
				
			||||||
 | 
					        @tags = value.map{ |v| Tag.new(v) }
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"status"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @status = attributes["status"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def to_body
 | 
					  def to_body
 | 
				
			||||||
@ -49,4 +74,3 @@ class Pet
 | 
				
			|||||||
    body
 | 
					    body
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,26 +1,33 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class Tag
 | 
					class Tag
 | 
				
			||||||
  attr_accessor :id, :name
 | 
					  attr_accessor :id, :name
 | 
				
			||||||
 | 
					 | 
				
			||||||
  # :internal => :external
 | 
					  # :internal => :external
 | 
				
			||||||
  def self.attribute_map
 | 
					  def self.attribute_map
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :id => :id,
 | 
					      :id => :id,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :name => :name
 | 
					      :name => :name
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def initialize(attributes = {})
 | 
					  def initialize(attributes = {})
 | 
				
			||||||
    return if attributes.empty?
 | 
					    return if attributes.empty?
 | 
				
			||||||
    # Morph attribute keys into undescored rubyish style
 | 
					    # Morph attribute keys into undescored rubyish style
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if self.class.attribute_map[:"id"]
 | 
					    if self.class.attribute_map[:"id"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      @id = attributes["id"]
 | 
					      @id = attributes["id"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"name"]
 | 
					    end
 | 
				
			||||||
      @name = attributes["name"]
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"name"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @name = attributes["name"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def to_body
 | 
					  def to_body
 | 
				
			||||||
@ -31,4 +38,3 @@ class Tag
 | 
				
			|||||||
    body
 | 
					    body
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,50 +1,81 @@
 | 
				
			|||||||
class User
 | 
					 | 
				
			||||||
  attr_accessor :id, :first_name, :username, :last_name, :email, :password, :phone, :user_status
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class User
 | 
				
			||||||
 | 
					  attr_accessor :id, :username, :firstName, :lastName, :email, :password, :phone, :userStatus
 | 
				
			||||||
  # :internal => :external
 | 
					  # :internal => :external
 | 
				
			||||||
  def self.attribute_map
 | 
					  def self.attribute_map
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :id => :id,
 | 
					      :id => :id,
 | 
				
			||||||
      :first_name => :firstName,
 | 
					      
 | 
				
			||||||
      :username => :username,
 | 
					      :username => :username,
 | 
				
			||||||
      :last_name => :lastName,
 | 
					      
 | 
				
			||||||
 | 
					      :firstName => :firstName,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      :lastName => :lastName,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :email => :email,
 | 
					      :email => :email,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :password => :password,
 | 
					      :password => :password,
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      :phone => :phone,
 | 
					      :phone => :phone,
 | 
				
			||||||
      :user_status => :userStatus
 | 
					      
 | 
				
			||||||
 | 
					      :userStatus => :userStatus
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def initialize(attributes = {})
 | 
					  def initialize(attributes = {})
 | 
				
			||||||
    return if attributes.empty?
 | 
					    return if attributes.empty?
 | 
				
			||||||
    # Morph attribute keys into undescored rubyish style
 | 
					    # Morph attribute keys into undescored rubyish style
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    if self.class.attribute_map[:"id"]
 | 
					    if self.class.attribute_map[:"id"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      @id = attributes["id"]
 | 
					      @id = attributes["id"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"first_name"]
 | 
					    end
 | 
				
			||||||
      @first_name = attributes["firstName"]
 | 
					    
 | 
				
			||||||
    end
 | 
					    if self.class.attribute_map[:"username"]
 | 
				
			||||||
    if self.class.attribute_map[:"username"]
 | 
					      
 | 
				
			||||||
      @username = attributes["username"]
 | 
					      @username = attributes["username"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"last_name"]
 | 
					    end
 | 
				
			||||||
      @last_name = attributes["lastName"]
 | 
					    
 | 
				
			||||||
    end
 | 
					    if self.class.attribute_map[:"firstName"]
 | 
				
			||||||
    if self.class.attribute_map[:"email"]
 | 
					      
 | 
				
			||||||
      @email = attributes["email"]
 | 
					      @firstName = attributes["firstName"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"password"]
 | 
					    end
 | 
				
			||||||
      @password = attributes["password"]
 | 
					    
 | 
				
			||||||
    end
 | 
					    if self.class.attribute_map[:"lastName"]
 | 
				
			||||||
    if self.class.attribute_map[:"phone"]
 | 
					      
 | 
				
			||||||
      @phone = attributes["phone"]
 | 
					      @lastName = attributes["lastName"]
 | 
				
			||||||
    end
 | 
					      
 | 
				
			||||||
    if self.class.attribute_map[:"user_status"]
 | 
					    end
 | 
				
			||||||
      @user_status = attributes["userStatus"]
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"email"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @email = attributes["email"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"password"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @password = attributes["password"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"phone"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @phone = attributes["phone"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if self.class.attribute_map[:"userStatus"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      @userStatus = attributes["userStatus"]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def to_body
 | 
					  def to_body
 | 
				
			||||||
@ -55,4 +86,3 @@ class User
 | 
				
			|||||||
    body
 | 
					    body
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										22
									
								
								samples/client/petstore/ruby/swagger/configuration.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								samples/client/petstore/ruby/swagger/configuration.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					module Swagger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  class Configuration
 | 
				
			||||||
 | 
					    require 'swagger/version'    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    attr_accessor :format, :api_key, :username, :password, :auth_token, :scheme, :host, :base_path, :user_agent, :logger, :inject_format, :force_ending_format, :camelize_params
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # Defaults go in here..
 | 
				
			||||||
 | 
					    def initialize
 | 
				
			||||||
 | 
					      @format = 'json'
 | 
				
			||||||
 | 
					      @scheme = 'http'
 | 
				
			||||||
 | 
					      @host = 'api.wordnik.com'
 | 
				
			||||||
 | 
					      @base_path = '/v4'
 | 
				
			||||||
 | 
					      @user_agent = "ruby-#{Swagger::VERSION}"
 | 
				
			||||||
 | 
					      @inject_format = true
 | 
				
			||||||
 | 
					      @force_ending_format = false
 | 
				
			||||||
 | 
					      @camelize_params = true
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										199
									
								
								samples/client/petstore/ruby/swagger/request.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										199
									
								
								samples/client/petstore/ruby/swagger/request.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,199 @@
 | 
				
			|||||||
 | 
					module Swagger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  class Request
 | 
				
			||||||
 | 
					    require 'uri'
 | 
				
			||||||
 | 
					    require 'addressable/uri'
 | 
				
			||||||
 | 
					    require 'typhoeus'
 | 
				
			||||||
 | 
					    require "swagger/version"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    attr_accessor :host, :path, :format, :params, :body, :http_method, :headers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # All requests must have an HTTP method and a path
 | 
				
			||||||
 | 
					    # Optionals parameters are :params, :headers, :body, :format, :host
 | 
				
			||||||
 | 
					    # 
 | 
				
			||||||
 | 
					    def initialize(http_method, path, attributes={})
 | 
				
			||||||
 | 
					      attributes[:format] ||= Swagger.configuration.format
 | 
				
			||||||
 | 
					      attributes[:params] ||= {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Set default headers
 | 
				
			||||||
 | 
					      default_headers = {
 | 
				
			||||||
 | 
					        'Content-Type' => "application/#{attributes[:format].downcase}",
 | 
				
			||||||
 | 
					        :api_key => Swagger.configuration.api_key
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # api_key from headers hash trumps the default, even if its value is blank
 | 
				
			||||||
 | 
					      if attributes[:headers].present? && attributes[:headers].has_key?(:api_key)
 | 
				
			||||||
 | 
					        default_headers.delete(:api_key)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      # api_key from params hash trumps all others (headers and default_headers)
 | 
				
			||||||
 | 
					      if attributes[:params].present? && attributes[:params].has_key?(:api_key)
 | 
				
			||||||
 | 
					        default_headers.delete(:api_key)
 | 
				
			||||||
 | 
					        attributes[:headers].delete(:api_key) if attributes[:headers].present?
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      # Merge argument headers into defaults
 | 
				
			||||||
 | 
					      attributes[:headers] = default_headers.merge(attributes[:headers] || {})
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      # Stick in the auth token if there is one
 | 
				
			||||||
 | 
					      if Swagger.authenticated?
 | 
				
			||||||
 | 
					        attributes[:headers].merge!({:auth_token => Swagger.configuration.auth_token})
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					      self.http_method = http_method.to_sym
 | 
				
			||||||
 | 
					      self.path = path
 | 
				
			||||||
 | 
					      attributes.each do |name, value|
 | 
				
			||||||
 | 
					        send("#{name.to_s.underscore.to_sym}=", value)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Construct a base URL
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    def url(options = {})  
 | 
				
			||||||
 | 
					      u = Addressable::URI.new(
 | 
				
			||||||
 | 
					        :scheme => Swagger.configuration.scheme,
 | 
				
			||||||
 | 
					        :host => Swagger.configuration.host,
 | 
				
			||||||
 | 
					        :path => self.interpreted_path,
 | 
				
			||||||
 | 
					        :query => self.query_string.sub(/\?/, '')
 | 
				
			||||||
 | 
					      ).to_s
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      # Drop trailing question mark, if present
 | 
				
			||||||
 | 
					      u.sub! /\?$/, ''
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      # Obfuscate API key?
 | 
				
			||||||
 | 
					      u.sub! /api\_key=\w+/, 'api_key=YOUR_API_KEY' if options[:obfuscated]
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      u
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Iterate over the params hash, injecting any path values into the path string
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    # e.g. /word.{format}/{word}/entries => /word.json/cat/entries
 | 
				
			||||||
 | 
					    def interpreted_path
 | 
				
			||||||
 | 
					      p = self.path.dup
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Fill in the path params
 | 
				
			||||||
 | 
					      self.params.each_pair do |key, value|
 | 
				
			||||||
 | 
					        p = p.gsub("{#{key}}", value.to_s)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Stick a .{format} placeholder into the path if there isn't
 | 
				
			||||||
 | 
					      # one already or an actual format like json or xml
 | 
				
			||||||
 | 
					      # e.g. /words/blah => /words.{format}/blah
 | 
				
			||||||
 | 
					      if Swagger.configuration.inject_format
 | 
				
			||||||
 | 
					        unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
 | 
				
			||||||
 | 
					          p = p.sub(/^(\/?\w+)/, "\\1.#{format}")
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Stick a .{format} placeholder on the end of the path if there isn't
 | 
				
			||||||
 | 
					      # one already or an actual format like json or xml
 | 
				
			||||||
 | 
					      # e.g. /words/blah => /words/blah.{format}
 | 
				
			||||||
 | 
					      if Swagger.configuration.force_ending_format
 | 
				
			||||||
 | 
					        unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
 | 
				
			||||||
 | 
					          p = "#{p}.#{format}"   
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      p = p.sub("{format}", self.format.to_s)
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					    # Massage the request body into a state of readiness
 | 
				
			||||||
 | 
					    # If body is a hash, camelize all keys then convert to a json string
 | 
				
			||||||
 | 
					    #
 | 
				
			||||||
 | 
					    def body=(value)      
 | 
				
			||||||
 | 
					      if value.is_a?(Hash)
 | 
				
			||||||
 | 
					        value = value.inject({}) do |memo, (k,v)|
 | 
				
			||||||
 | 
					          memo[k.to_s.camelize(:lower).to_sym] = v
 | 
				
			||||||
 | 
					          memo
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      @body = value
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # If body is an object, JSONify it before making the actual request.
 | 
				
			||||||
 | 
					    # 
 | 
				
			||||||
 | 
					    def outgoing_body
 | 
				
			||||||
 | 
					      body.is_a?(String) ? body : body.to_json
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # Construct a query string from the query-string-type params
 | 
				
			||||||
 | 
					    def query_string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      # Iterate over all params,
 | 
				
			||||||
 | 
					      # .. removing the ones that are part of the path itself.
 | 
				
			||||||
 | 
					      # .. stringifying values so Addressable doesn't blow up.
 | 
				
			||||||
 | 
					      query_values = {}
 | 
				
			||||||
 | 
					      self.params.each_pair do |key, value|
 | 
				
			||||||
 | 
					        next if self.path.include? "{#{key}}"                                   # skip path params
 | 
				
			||||||
 | 
					        next if value.blank? && value.class != FalseClass                       # skip empties
 | 
				
			||||||
 | 
					        if Swagger.configuration.camelize_params
 | 
				
			||||||
 | 
					          key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key    # api_key is not a camelCased param
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					        query_values[key] = value.to_s
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      # We don't want to end up with '?' as our query string
 | 
				
			||||||
 | 
					      # if there aren't really any params
 | 
				
			||||||
 | 
					      return "" if query_values.blank?
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					      # Addressable requires query_values to be set after initialization..
 | 
				
			||||||
 | 
					      qs = Addressable::URI.new
 | 
				
			||||||
 | 
					      qs.query_values = query_values
 | 
				
			||||||
 | 
					      qs.to_s
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					    def make
 | 
				
			||||||
 | 
					      logger = Logger.new STDOUT
 | 
				
			||||||
 | 
					      logger.debug self.url
 | 
				
			||||||
 | 
					      response = case self.http_method.to_sym
 | 
				
			||||||
 | 
					      when :get,:GET
 | 
				
			||||||
 | 
					        Typhoeus::Request.get(
 | 
				
			||||||
 | 
					          self.url,
 | 
				
			||||||
 | 
					          :headers => self.headers.stringify_keys,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      when :post,:POST
 | 
				
			||||||
 | 
					        Typhoeus::Request.post(
 | 
				
			||||||
 | 
					          self.url,
 | 
				
			||||||
 | 
					          :body => self.outgoing_body,
 | 
				
			||||||
 | 
					          :headers => self.headers.stringify_keys,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      when :put,:PUT
 | 
				
			||||||
 | 
					        Typhoeus::Request.put(
 | 
				
			||||||
 | 
					          self.url,
 | 
				
			||||||
 | 
					          :body => self.outgoing_body,
 | 
				
			||||||
 | 
					          :headers => self.headers.stringify_keys,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      when :delete,:DELETE
 | 
				
			||||||
 | 
					        Typhoeus::Request.delete(
 | 
				
			||||||
 | 
					          self.url,
 | 
				
			||||||
 | 
					          :body => self.outgoing_body,
 | 
				
			||||||
 | 
					          :headers => self.headers.stringify_keys,
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					      Response.new(response)
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					    def response
 | 
				
			||||||
 | 
					      self.make
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					    def response_code_pretty
 | 
				
			||||||
 | 
					      return unless @response.present?
 | 
				
			||||||
 | 
					      @response.code.to_s    
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					    def response_headers_pretty
 | 
				
			||||||
 | 
					      return unless @response.present?
 | 
				
			||||||
 | 
					      # JSON.pretty_generate(@response.headers).gsub(/\n/, '<br/>') # <- This was for RestClient
 | 
				
			||||||
 | 
					      @response.headers.gsub(/\n/, '<br/>') # <- This is for Typhoeus
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										70
									
								
								samples/client/petstore/ruby/swagger/response.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								samples/client/petstore/ruby/swagger/response.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,70 @@
 | 
				
			|||||||
 | 
					module Swagger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  class Response
 | 
				
			||||||
 | 
					    require 'json'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    attr_accessor :raw
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def initialize(raw)
 | 
				
			||||||
 | 
					      self.raw = raw
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      case self.code
 | 
				
			||||||
 | 
					      when 500..510 then raise(ServerError, self.error_message)
 | 
				
			||||||
 | 
					      when 299..426 then raise(ClientError, self.error_message)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def code
 | 
				
			||||||
 | 
					      raw.code
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    # Account for error messages that take different forms...
 | 
				
			||||||
 | 
					    def error_message
 | 
				
			||||||
 | 
					      body['message']
 | 
				
			||||||
 | 
					    rescue
 | 
				
			||||||
 | 
					      body
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # If body is JSON, parse it
 | 
				
			||||||
 | 
					    # Otherwise return raw string
 | 
				
			||||||
 | 
					    def body
 | 
				
			||||||
 | 
					      JSON.parse raw.body
 | 
				
			||||||
 | 
					    rescue
 | 
				
			||||||
 | 
					      raw.body
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # `headers_hash` is a Typhoeus-specific extension of Hash, 
 | 
				
			||||||
 | 
					    # so simplify it back into a regular old Hash.
 | 
				
			||||||
 | 
					    def headers
 | 
				
			||||||
 | 
					      h = {}
 | 
				
			||||||
 | 
					      raw.headers_hash.each {|k,v| h[k] = v }
 | 
				
			||||||
 | 
					      h
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Extract the response format from the header hash
 | 
				
			||||||
 | 
					    # e.g. {'Content-Type' => 'application/json'}
 | 
				
			||||||
 | 
					    def format
 | 
				
			||||||
 | 
					      headers['Content-Type'].split("/").last.downcase
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def json?
 | 
				
			||||||
 | 
					      format == 'json'
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def xml?
 | 
				
			||||||
 | 
					      format == 'xml'
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def pretty_body
 | 
				
			||||||
 | 
					      return unless body.present?
 | 
				
			||||||
 | 
					      case format
 | 
				
			||||||
 | 
					      when 'json' then JSON.pretty_generate(body).gsub(/\n/, '<br/>')
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def pretty_headers
 | 
				
			||||||
 | 
					      JSON.pretty_generate(headers).gsub(/\n/, '<br/>')
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
							
								
								
									
										4
									
								
								samples/client/petstore/ruby/swagger/version.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								samples/client/petstore/ruby/swagger/version.rb
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					module Swagger
 | 
				
			||||||
 | 
					  VERSION = "4.06.08"
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user