better format of model properties

This commit is contained in:
wing328 2016-09-11 18:44:36 +08:00
parent bd3a15e273
commit ac69f45ddc
24 changed files with 98 additions and 102 deletions

View File

@ -11,24 +11,33 @@ import org.joda.time.DateTime
{{#models}}
{{#model}}
case class {{classname}} (
{{#vars}}{{#description}}/* {{{description}}} */
{{/description}}{{{name}}}: {{^required}}Option[{{/required}}{{^isEnum}}{{datatype}}{{/isEnum}}{{#isEnum}}{{classname}}Enums.{{datatypeWithEnum}}{{/isEnum}}{{^required}}]{{/required}}{{#hasMore}},{{/hasMore}}{{^hasMore}}){{/hasMore}}
{{/vars}} extends ApiModel
{{#vars}}
{{#description}}
/* {{{description}}} */
{{/description}}
{{{name}}}: {{^required}}Option[{{/required}}{{^isEnum}}{{datatype}}{{/isEnum}}{{#isEnum}}{{classname}}Enums.{{datatypeWithEnum}}{{/isEnum}}{{^required}}]{{/required}}{{#hasMore}},{{/hasMore}}
{{/vars}}
) extends ApiModel
{{#hasEnums}}
object {{classname}}Enums {
{{#vars}}{{#isEnum}}type {{datatypeWithEnum}} = {{datatypeWithEnum}}.Value
{{/isEnum}}{{/vars}}
{{#vars}}{{#isEnum}}object {{datatypeWithEnum}} extends Enumeration {
{{#vars}}
{{#isEnum}}
type {{datatypeWithEnum}} = {{datatypeWithEnum}}.Value
{{/isEnum}}
{{/vars}}
{{#vars}}
{{#isEnum}}
object {{datatypeWithEnum}} extends Enumeration {
{{#_enum}}
val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}")
{{/_enum}}
}
{{/isEnum}}{{/vars}}
{{/isEnum}}
{{/vars}}
}
{{/hasEnums}}
{{/model}}

View File

@ -1,16 +1,19 @@
{{>licenseInfo}}
package {{package}}
{{#imports}}import {{import}}
{{#imports}}
import {{import}}
{{/imports}}
{{#models}}
{{#model}}
case class {{classname}} (
{{#vars}}{{#description}}/* {{{description}}} */
{{/description}}{{name}}: {{{datatype}}}{{#hasMore}},{{/hasMore}}{{^hasMore}}){{/hasMore}}
{{#vars}}
{{#description}}
/* {{{description}}} */
{{/description}}
{{name}}: {{{datatype}}}{{#hasMore}},{{/hasMore}}
{{/vars}}
)
{{/model}}
{{/models}}

View File

@ -6,10 +6,13 @@ package {{package}}
{{/imports}}
{{#models}}
{{#model}}
case class {{classname}} (
{{#vars}}{{name}}: {{^required}}Option[{{/required}}{{datatype}}{{^required}}]{{/required}}{{#hasMore}},{{/hasMore}}{{#description}} // {{description}}{{/description}}
{{#vars}}
{{#description}}
/* {{{description}}} */
{{/description}}
{{name}}: {{^required}}Option[{{/required}}{{datatype}}{{^required}}]{{/required}}{{#hasMore}},{{/hasMore}}
{{/vars}}
)
{{/model}}

View File

@ -6,8 +6,8 @@
package io.swagger.client.api
import io.swagger.client.model.Pet
import java.io.File
import io.swagger.client.model.ApiResponse
import java.io.File
import io.swagger.client.core._
import io.swagger.client.core.CollectionFormats._
import io.swagger.client.core.ApiKeyLocations._

View File

@ -9,11 +9,10 @@ package io.swagger.client.model
import io.swagger.client.core.ApiModel
import org.joda.time.DateTime
case class ApiResponse (
code: Option[Int],
`type`: Option[String],
message: Option[String])
extends ApiModel
message: Option[String]
) extends ApiModel

View File

@ -9,10 +9,9 @@ package io.swagger.client.model
import io.swagger.client.core.ApiModel
import org.joda.time.DateTime
case class Category (
id: Option[Long],
name: Option[String])
extends ApiModel
name: Option[String]
) extends ApiModel

View File

@ -9,7 +9,6 @@ package io.swagger.client.model
import io.swagger.client.core.ApiModel
import org.joda.time.DateTime
case class Order (
id: Option[Long],
petId: Option[Long],
@ -17,19 +16,17 @@ case class Order (
shipDate: Option[DateTime],
/* Order Status */
status: Option[OrderEnums.Status],
complete: Option[Boolean])
extends ApiModel
complete: Option[Boolean]
) extends ApiModel
object OrderEnums {
type Status = Status.Value
object Status extends Enumeration {
val Placed = Value("placed")
val Approved = Value("approved")
val Delivered = Value("delivered")
}
}

View File

@ -9,7 +9,6 @@ package io.swagger.client.model
import io.swagger.client.core.ApiModel
import org.joda.time.DateTime
case class Pet (
id: Option[Long],
category: Option[Category],
@ -17,19 +16,17 @@ case class Pet (
photoUrls: Seq[String],
tags: Option[Seq[Tag]],
/* pet status in the store */
status: Option[PetEnums.Status])
extends ApiModel
status: Option[PetEnums.Status]
) extends ApiModel
object PetEnums {
type Status = Status.Value
object Status extends Enumeration {
val Available = Value("available")
val Pending = Value("pending")
val Sold = Value("sold")
}
}

View File

@ -9,10 +9,9 @@ package io.swagger.client.model
import io.swagger.client.core.ApiModel
import org.joda.time.DateTime
case class Tag (
id: Option[Long],
name: Option[String])
extends ApiModel
name: Option[String]
) extends ApiModel

View File

@ -9,7 +9,6 @@ package io.swagger.client.model
import io.swagger.client.core.ApiModel
import org.joda.time.DateTime
case class User (
id: Option[Long],
username: Option[String],
@ -19,7 +18,7 @@ case class User (
password: Option[String],
phone: Option[String],
/* User Status */
userStatus: Option[Int])
extends ApiModel
userStatus: Option[Int]
) extends ApiModel

View File

@ -25,8 +25,8 @@
package io.swagger.client.api
import io.swagger.client.model.Pet
import java.io.File
import io.swagger.client.model.ApiResponse
import java.io.File
import io.swagger.client.ApiInvoker
import io.swagger.client.ApiException

View File

@ -25,9 +25,8 @@
package io.swagger.client.model
case class ApiResponse (
code: Integer,
_type: String,
message: String)
_type: String,
message: String
)

View File

@ -25,8 +25,7 @@
package io.swagger.client.model
case class Category (
id: Long,
name: String)
name: String
)

View File

@ -26,13 +26,12 @@ package io.swagger.client.model
import org.joda.time.DateTime
case class Order (
id: Long,
petId: Long,
quantity: Integer,
shipDate: DateTime,
/* Order Status */
petId: Long,
quantity: Integer,
shipDate: DateTime,
/* Order Status */
status: String,
complete: Boolean)
complete: Boolean
)

View File

@ -25,13 +25,12 @@
package io.swagger.client.model
case class Pet (
id: Long,
category: Category,
name: String,
photoUrls: List[String],
tags: List[Tag],
/* pet status in the store */
status: String)
category: Category,
name: String,
photoUrls: List[String],
tags: List[Tag],
/* pet status in the store */
status: String
)

View File

@ -25,8 +25,7 @@
package io.swagger.client.model
case class Tag (
id: Long,
name: String)
name: String
)

View File

@ -25,15 +25,14 @@
package io.swagger.client.model
case class User (
id: Long,
username: String,
firstName: String,
lastName: String,
email: String,
password: String,
phone: String,
/* User Status */
userStatus: Integer)
username: String,
firstName: String,
lastName: String,
email: String,
password: String,
phone: String,
/* User Status */
userStatus: Integer
)

View File

@ -25,8 +25,8 @@
package com.wordnik.client.api
import com.wordnik.client.model.Pet
import java.io.File
import com.wordnik.client.model.ApiResponse
import java.io.File
import java.io.File

View File

@ -25,9 +25,8 @@
package com.wordnik.client.model
case class ApiResponse (
code: Option[Int],
_type: Option[String],
message: Option[String]
_type: Option[String],
message: Option[String]
)

View File

@ -25,8 +25,7 @@
package com.wordnik.client.model
case class Category (
id: Option[Long],
name: Option[String]
name: Option[String]
)

View File

@ -26,12 +26,12 @@ package com.wordnik.client.model
import java.util.Date
case class Order (
id: Option[Long],
petId: Option[Long],
quantity: Option[Int],
shipDate: Option[Date],
status: Option[String], // Order Status
complete: Option[Boolean]
petId: Option[Long],
quantity: Option[Int],
shipDate: Option[Date],
/* Order Status */
status: Option[String],
complete: Option[Boolean]
)

View File

@ -25,12 +25,12 @@
package com.wordnik.client.model
case class Pet (
id: Option[Long],
category: Option[Category],
name: String,
photoUrls: List[String],
tags: Option[List[Tag]],
status: Option[String] // pet status in the store
category: Option[Category],
name: String,
photoUrls: List[String],
tags: Option[List[Tag]],
/* pet status in the store */
status: Option[String]
)

View File

@ -25,8 +25,7 @@
package com.wordnik.client.model
case class Tag (
id: Option[Long],
name: Option[String]
name: Option[String]
)

View File

@ -25,14 +25,14 @@
package com.wordnik.client.model
case class User (
id: Option[Long],
username: Option[String],
firstName: Option[String],
lastName: Option[String],
email: Option[String],
password: Option[String],
phone: Option[String],
userStatus: Option[Int] // User Status
username: Option[String],
firstName: Option[String],
lastName: Option[String],
email: Option[String],
password: Option[String],
phone: Option[String],
/* User Status */
userStatus: Option[Int]
)