forked from loafle/openapi-generator-original
		
	added contianer check to simplify models
This commit is contained in:
		
							parent
							
								
									58cfacc4cf
								
							
						
					
					
						commit
						ce1b4ec347
					
				@ -1,13 +1,19 @@
 | 
			
		||||
import com.wordnik.swagger.codegen.BasicRubyGenerator
 | 
			
		||||
 | 
			
		||||
import com.wordnik.swagger.core._
 | 
			
		||||
import com.wordnik.swagger.codegen.util.ScalaJsonUtil
 | 
			
		||||
 | 
			
		||||
object RubyPetstoreCodegen extends BasicRubyGenerator {
 | 
			
		||||
  def main(args: Array[String]) = generateClient(args)
 | 
			
		||||
  
 | 
			
		||||
  // to avoid recompiling ...
 | 
			
		||||
  override def templateDir = "src/main/resources/ruby"
 | 
			
		||||
 | 
			
		||||
  // where to write generated code
 | 
			
		||||
  override def destinationDir = "samples/client/petstore/ruby"
 | 
			
		||||
 | 
			
		||||
  // package for models
 | 
			
		||||
  override def modelPackage = Some("models")
 | 
			
		||||
  override def processModelMap(m: Map[String, AnyRef]): Map[String, AnyRef] = {
 | 
			
		||||
  	println(json.writeValueAsString(m))
 | 
			
		||||
  	m
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -16,33 +16,15 @@ class Category
 | 
			
		||||
      if Category.attribute_map["id".to_sym] != nil
 | 
			
		||||
        name = "id".to_sym
 | 
			
		||||
        value = attributes["id"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Category.attribute_map["name".to_sym] != nil
 | 
			
		||||
        name = "name".to_sym
 | 
			
		||||
        value = attributes["name"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
      end
 | 
			
		||||
  end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def to_body
 | 
			
		||||
    body = {}
 | 
			
		||||
 | 
			
		||||
@ -16,75 +16,30 @@ class Order
 | 
			
		||||
      if Order.attribute_map["id".to_sym] != nil
 | 
			
		||||
        name = "id".to_sym
 | 
			
		||||
        value = attributes["id"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Order.attribute_map["pet_id".to_sym] != nil
 | 
			
		||||
        name = "pet_id".to_sym
 | 
			
		||||
        value = attributes["petId"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Order.attribute_map["status".to_sym] != nil
 | 
			
		||||
        name = "status".to_sym
 | 
			
		||||
        value = attributes["status"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Order.attribute_map["quantity".to_sym] != nil
 | 
			
		||||
        name = "quantity".to_sym
 | 
			
		||||
        value = attributes["quantity"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Order.attribute_map["ship_date".to_sym] != nil
 | 
			
		||||
        name = "ship_date".to_sym
 | 
			
		||||
        value = attributes["shipDate"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push Date.new(arrayValue)
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
      end
 | 
			
		||||
  end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def to_body
 | 
			
		||||
    body = {}
 | 
			
		||||
 | 
			
		||||
@ -16,85 +16,43 @@ class Pet
 | 
			
		||||
      if Pet.attribute_map["id".to_sym] != nil
 | 
			
		||||
        name = "id".to_sym
 | 
			
		||||
        value = attributes["id"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Pet.attribute_map["tags".to_sym] != nil
 | 
			
		||||
        name = "tags".to_sym
 | 
			
		||||
        value = attributes["tags"]
 | 
			
		||||
 | 
			
		||||
        if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push Tag.new(arrayValue)
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
	        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
        end
 | 
			
		||||
      if Pet.attribute_map["category".to_sym] != nil
 | 
			
		||||
        name = "category".to_sym
 | 
			
		||||
        value = attributes["category"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push Category.new(arrayValue)
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Pet.attribute_map["status".to_sym] != nil
 | 
			
		||||
        name = "status".to_sym
 | 
			
		||||
        value = attributes["status"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Pet.attribute_map["name".to_sym] != nil
 | 
			
		||||
        name = "name".to_sym
 | 
			
		||||
        value = attributes["name"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Pet.attribute_map["photo_urls".to_sym] != nil
 | 
			
		||||
        name = "photo_urls".to_sym
 | 
			
		||||
        value = attributes["photoUrls"]
 | 
			
		||||
 | 
			
		||||
        if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
	        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -16,33 +16,15 @@ class Tag
 | 
			
		||||
      if Tag.attribute_map["id".to_sym] != nil
 | 
			
		||||
        name = "id".to_sym
 | 
			
		||||
        value = attributes["id"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if Tag.attribute_map["name".to_sym] != nil
 | 
			
		||||
        name = "name".to_sym
 | 
			
		||||
        value = attributes["name"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
      end
 | 
			
		||||
  end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def to_body
 | 
			
		||||
    body = {}
 | 
			
		||||
 | 
			
		||||
@ -16,117 +16,45 @@ class User
 | 
			
		||||
      if User.attribute_map["id".to_sym] != nil
 | 
			
		||||
        name = "id".to_sym
 | 
			
		||||
        value = attributes["id"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if User.attribute_map["last_name".to_sym] != nil
 | 
			
		||||
        name = "last_name".to_sym
 | 
			
		||||
        value = attributes["lastName"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if User.attribute_map["username".to_sym] != nil
 | 
			
		||||
        name = "username".to_sym
 | 
			
		||||
        value = attributes["username"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if User.attribute_map["phone".to_sym] != nil
 | 
			
		||||
        name = "phone".to_sym
 | 
			
		||||
        value = attributes["phone"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if User.attribute_map["email".to_sym] != nil
 | 
			
		||||
        name = "email".to_sym
 | 
			
		||||
        value = attributes["email"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if User.attribute_map["user_status".to_sym] != nil
 | 
			
		||||
        name = "user_status".to_sym
 | 
			
		||||
        value = attributes["userStatus"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if User.attribute_map["first_name".to_sym] != nil
 | 
			
		||||
        name = "first_name".to_sym
 | 
			
		||||
        value = attributes["firstName"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
      if User.attribute_map["password".to_sym] != nil
 | 
			
		||||
        name = "password".to_sym
 | 
			
		||||
        value = attributes["password"]
 | 
			
		||||
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
	          array.push arrayValue
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
      end
 | 
			
		||||
  end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def to_body
 | 
			
		||||
    body = {}
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@ class {{classname}}
 | 
			
		||||
      if {{classname}}.attribute_map["{{{name}}}".to_sym] != nil
 | 
			
		||||
        name = "{{{name}}}".to_sym
 | 
			
		||||
        value = attributes["{{{baseName}}}"]
 | 
			
		||||
 | 
			
		||||
        {{#isContainer}}
 | 
			
		||||
	      if value.is_a?(Array)
 | 
			
		||||
	        array = Array.new
 | 
			
		||||
	        value.each do |arrayValue|
 | 
			
		||||
@ -30,9 +30,11 @@ class {{classname}}
 | 
			
		||||
	        {{/complexType}}
 | 
			
		||||
	        end
 | 
			
		||||
	        send("#{name}=", array) if self.respond_to?(name)
 | 
			
		||||
	      else
 | 
			
		||||
	        send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      end
 | 
			
		||||
        {{/isContainer}}
 | 
			
		||||
        {{^isContainer}}
 | 
			
		||||
	      send("#{name}=", value) if self.respond_to?(name)
 | 
			
		||||
	      {{/isContainer}}
 | 
			
		||||
	    end
 | 
			
		||||
      {{/vars}}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user