udpate type mapping for go, fix indention in go model

This commit is contained in:
wing328 2016-04-11 23:44:06 +08:00
parent 87af119d9a
commit d8963d0a85
11 changed files with 28 additions and 26 deletions

View File

@ -79,11 +79,12 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.clear(); typeMapping.clear();
typeMapping.put("integer", "int32"); typeMapping.put("integer", "int32");
typeMapping.put("long", "int64"); typeMapping.put("long", "int64");
typeMapping.put("number", "float32");
typeMapping.put("float", "float32"); typeMapping.put("float", "float32");
typeMapping.put("double", "float64"); typeMapping.put("double", "float64");
typeMapping.put("boolean", "bool"); typeMapping.put("boolean", "bool");
typeMapping.put("string", "string"); typeMapping.put("string", "string");
typeMapping.put("Date", "time.Time"); typeMapping.put("date", "time.Time");
typeMapping.put("DateTime", "time.Time"); typeMapping.put("DateTime", "time.Time");
typeMapping.put("password", "string"); typeMapping.put("password", "string");
typeMapping.put("File", "*os.File"); typeMapping.put("File", "*os.File");
@ -91,6 +92,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
// map binary to string as a workaround // map binary to string as a workaround
// the correct solution is to use []byte // the correct solution is to use []byte
typeMapping.put("binary", "string"); typeMapping.put("binary", "string");
typeMapping.put("ByteArray", "string");
importMapping = new HashMap<String, String>(); importMapping = new HashMap<String, String>();
importMapping.put("time.Time", "time"); importMapping.put("time.Time", "time");

View File

@ -8,7 +8,8 @@ import (
{{#model}} {{#model}}
type {{classname}} struct { type {{classname}} struct {
{{#vars}}{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"` {{#vars}}
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
{{/vars}} {{/vars}}
} }
{{/model}} {{/model}}

View File

@ -1427,7 +1427,7 @@
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
}, },
"dateTime" : { "password" : {
"type": "string", "type": "string",
"format": "password" "format": "password"
} }

View File

@ -5,6 +5,6 @@ import (
type ApiResponse struct { type ApiResponse struct {
Code int32 `json:"code,omitempty"` Code int32 `json:"code,omitempty"`
Type_ string `json:"type,omitempty"` Type_ string `json:"type,omitempty"`
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
} }

View File

@ -5,5 +5,5 @@ import (
type Category struct { type Category struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
} }

View File

@ -5,5 +5,4 @@ import (
type ModelReturn struct { type ModelReturn struct {
Return_ int32 `json:"return,omitempty"` Return_ int32 `json:"return,omitempty"`
} }

View File

@ -5,5 +5,5 @@ import (
type Name struct { type Name struct {
Name int32 `json:"name,omitempty"` Name int32 `json:"name,omitempty"`
SnakeCase int32 `json:"snake_case,omitempty"`
} }

View File

@ -6,9 +6,9 @@ import (
type Order struct { type Order struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
PetId int64 `json:"petId,omitempty"` PetId int64 `json:"petId,omitempty"`
Quantity int32 `json:"quantity,omitempty"` Quantity int32 `json:"quantity,omitempty"`
ShipDate time.Time `json:"shipDate,omitempty"` ShipDate time.Time `json:"shipDate,omitempty"`
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
Complete bool `json:"complete,omitempty"` Complete bool `json:"complete,omitempty"`
} }

View File

@ -5,9 +5,9 @@ import (
type Pet struct { type Pet struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Category Category `json:"category,omitempty"` Category Category `json:"category,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
PhotoUrls []string `json:"photoUrls,omitempty"` PhotoUrls []string `json:"photoUrls,omitempty"`
Tags []Tag `json:"tags,omitempty"` Tags []Tag `json:"tags,omitempty"`
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
} }

View File

@ -5,5 +5,5 @@ import (
type Tag struct { type Tag struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
} }

View File

@ -5,11 +5,11 @@ import (
type User struct { type User struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
Username string `json:"username,omitempty"` Username string `json:"username,omitempty"`
FirstName string `json:"firstName,omitempty"` FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"` LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"` Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
Phone string `json:"phone,omitempty"` Phone string `json:"phone,omitempty"`
UserStatus int32 `json:"userStatus,omitempty"` UserStatus int32 `json:"userStatus,omitempty"`
} }