diff --git a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache index 528e71fa21c..bfde1e51a5b 100644 --- a/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/controller-api.mustache @@ -6,6 +6,7 @@ import ( "net/http" ){{#operation}} +// {{nickname}} - {{{summary}}} func {{nickname}}(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) diff --git a/modules/openapi-generator/src/main/resources/go-server/logger.mustache b/modules/openapi-generator/src/main/resources/go-server/logger.mustache index aa0d894d83a..e8464d6ad5f 100644 --- a/modules/openapi-generator/src/main/resources/go-server/logger.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/logger.mustache @@ -2,23 +2,23 @@ package {{packageName}} import ( - "log" - "net/http" - "time" + "log" + "net/http" + "time" ) func Logger(inner http.Handler, name string) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - start := time.Now() + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() - inner.ServeHTTP(w, r) + inner.ServeHTTP(w, r) - log.Printf( - "%s %s %s %s", - r.Method, - r.RequestURI, - name, - time.Since(start), - ) - }) + log.Printf( + "%s %s %s %s", + r.Method, + r.RequestURI, + name, + time.Since(start), + ) + }) } diff --git a/modules/openapi-generator/src/main/resources/go-server/model.mustache b/modules/openapi-generator/src/main/resources/go-server/model.mustache index d6562a39eb8..d006e1aa050 100644 --- a/modules/openapi-generator/src/main/resources/go-server/model.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/model.mustache @@ -15,7 +15,7 @@ const ( {{/enumVars}} {{/allowableValues}} ){{/isEnum}}{{^isEnum}}{{#description}} -// {{{description}}}{{/description}} +// {{classname}} - {{{description}}}{{/description}} type {{classname}} struct { {{#vars}}{{#description}} // {{{description}}}{{/description}} diff --git a/modules/openapi-generator/src/main/resources/go-server/routers.mustache b/modules/openapi-generator/src/main/resources/go-server/routers.mustache index e3f5bdf3455..815fc5f75a5 100644 --- a/modules/openapi-generator/src/main/resources/go-server/routers.mustache +++ b/modules/openapi-generator/src/main/resources/go-server/routers.mustache @@ -40,14 +40,14 @@ func Index(w http.ResponseWriter, r *http.Request) { } var routes = Routes{ - Route{ + { "Index", "GET", "{{{basePathWithoutHost}}}/", Index, },{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}} - Route{ + { "{{operationId}}", strings.ToUpper("{{httpMethod}}"), "{{{basePathWithoutHost}}}{{{path}}}", diff --git a/samples/server/petstore/go-api-server/go/api_pet.go b/samples/server/petstore/go-api-server/go/api_pet.go index d57c66e5b5b..02b798ec950 100644 --- a/samples/server/petstore/go-api-server/go/api_pet.go +++ b/samples/server/petstore/go-api-server/go/api_pet.go @@ -13,41 +13,49 @@ import ( "net/http" ) +// AddPet - Add a new pet to the store func AddPet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// DeletePet - Deletes a pet func DeletePet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// FindPetsByStatus - Finds Pets by status func FindPetsByStatus(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// FindPetsByTags - Finds Pets by tags func FindPetsByTags(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// GetPetById - Find pet by ID func GetPetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// UpdatePet - Update an existing pet func UpdatePet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// UpdatePetWithForm - Updates a pet in the store with form data func UpdatePetWithForm(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// UploadFile - uploads an image func UploadFile(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) diff --git a/samples/server/petstore/go-api-server/go/api_store.go b/samples/server/petstore/go-api-server/go/api_store.go index 85037e5b546..5174c6e7712 100644 --- a/samples/server/petstore/go-api-server/go/api_store.go +++ b/samples/server/petstore/go-api-server/go/api_store.go @@ -13,21 +13,25 @@ import ( "net/http" ) +// DeleteOrder - Delete purchase order by ID func DeleteOrder(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// GetInventory - Returns pet inventories by status func GetInventory(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// GetOrderById - Find purchase order by ID func GetOrderById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// PlaceOrder - Place an order for a pet func PlaceOrder(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) diff --git a/samples/server/petstore/go-api-server/go/api_user.go b/samples/server/petstore/go-api-server/go/api_user.go index 3aba6e039de..460afb24c2e 100644 --- a/samples/server/petstore/go-api-server/go/api_user.go +++ b/samples/server/petstore/go-api-server/go/api_user.go @@ -13,41 +13,49 @@ import ( "net/http" ) +// CreateUser - Create user func CreateUser(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// CreateUsersWithArrayInput - Creates list of users with given input array func CreateUsersWithArrayInput(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// CreateUsersWithListInput - Creates list of users with given input array func CreateUsersWithListInput(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// DeleteUser - Delete user func DeleteUser(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// GetUserByName - Get user by user name func GetUserByName(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// LoginUser - Logs user into the system func LoginUser(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// LogoutUser - Logs out current logged in user session func LogoutUser(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) } +// UpdateUser - Updated user func UpdateUser(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.WriteHeader(http.StatusOK) diff --git a/samples/server/petstore/go-api-server/go/logger.go b/samples/server/petstore/go-api-server/go/logger.go index 186d5d18ae4..08cc0ea3f1d 100644 --- a/samples/server/petstore/go-api-server/go/logger.go +++ b/samples/server/petstore/go-api-server/go/logger.go @@ -10,23 +10,23 @@ package petstoreserver import ( - "log" - "net/http" - "time" + "log" + "net/http" + "time" ) func Logger(inner http.Handler, name string) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - start := time.Now() + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() - inner.ServeHTTP(w, r) + inner.ServeHTTP(w, r) - log.Printf( - "%s %s %s %s", - r.Method, - r.RequestURI, - name, - time.Since(start), - ) - }) + log.Printf( + "%s %s %s %s", + r.Method, + r.RequestURI, + name, + time.Since(start), + ) + }) } diff --git a/samples/server/petstore/go-api-server/go/model_api_response.go b/samples/server/petstore/go-api-server/go/model_api_response.go index 48a48e715a2..2379e169080 100644 --- a/samples/server/petstore/go-api-server/go/model_api_response.go +++ b/samples/server/petstore/go-api-server/go/model_api_response.go @@ -9,7 +9,7 @@ package petstoreserver -// Describes the result of uploading an image resource +// ApiResponse - Describes the result of uploading an image resource type ApiResponse struct { Code int32 `json:"code,omitempty"` diff --git a/samples/server/petstore/go-api-server/go/model_category.go b/samples/server/petstore/go-api-server/go/model_category.go index ac0089074ee..5e6f9d247fa 100644 --- a/samples/server/petstore/go-api-server/go/model_category.go +++ b/samples/server/petstore/go-api-server/go/model_category.go @@ -9,7 +9,7 @@ package petstoreserver -// A category for a pet +// Category - A category for a pet type Category struct { Id int64 `json:"id,omitempty"` diff --git a/samples/server/petstore/go-api-server/go/model_order.go b/samples/server/petstore/go-api-server/go/model_order.go index 8a57968de18..a9d8dbb7957 100644 --- a/samples/server/petstore/go-api-server/go/model_order.go +++ b/samples/server/petstore/go-api-server/go/model_order.go @@ -13,7 +13,7 @@ import ( "time" ) -// An order for a pets from the pet store +// Order - An order for a pets from the pet store type Order struct { Id int64 `json:"id,omitempty"` diff --git a/samples/server/petstore/go-api-server/go/model_pet.go b/samples/server/petstore/go-api-server/go/model_pet.go index 011fb899ab6..ff09e500be5 100644 --- a/samples/server/petstore/go-api-server/go/model_pet.go +++ b/samples/server/petstore/go-api-server/go/model_pet.go @@ -9,7 +9,7 @@ package petstoreserver -// A pet for sale in the pet store +// Pet - A pet for sale in the pet store type Pet struct { Id int64 `json:"id,omitempty"` diff --git a/samples/server/petstore/go-api-server/go/model_tag.go b/samples/server/petstore/go-api-server/go/model_tag.go index d2194bba546..2fb07fb32c4 100644 --- a/samples/server/petstore/go-api-server/go/model_tag.go +++ b/samples/server/petstore/go-api-server/go/model_tag.go @@ -9,7 +9,7 @@ package petstoreserver -// A tag for a pet +// Tag - A tag for a pet type Tag struct { Id int64 `json:"id,omitempty"` diff --git a/samples/server/petstore/go-api-server/go/model_user.go b/samples/server/petstore/go-api-server/go/model_user.go index cb48644e59d..8f40d0ac04c 100644 --- a/samples/server/petstore/go-api-server/go/model_user.go +++ b/samples/server/petstore/go-api-server/go/model_user.go @@ -9,7 +9,7 @@ package petstoreserver -// A User who is purchasing from the pet store +// User - A User who is purchasing from the pet store type User struct { Id int64 `json:"id,omitempty"` diff --git a/samples/server/petstore/go-api-server/go/routers.go b/samples/server/petstore/go-api-server/go/routers.go index 1d6a6c0e1fb..986ce371ad0 100644 --- a/samples/server/petstore/go-api-server/go/routers.go +++ b/samples/server/petstore/go-api-server/go/routers.go @@ -48,147 +48,147 @@ func Index(w http.ResponseWriter, r *http.Request) { } var routes = Routes{ - Route{ + { "Index", "GET", "/v2/", Index, }, - Route{ + { "AddPet", strings.ToUpper("Post"), "/v2/pet", AddPet, }, - Route{ + { "DeletePet", strings.ToUpper("Delete"), "/v2/pet/{petId}", DeletePet, }, - Route{ + { "FindPetsByStatus", strings.ToUpper("Get"), "/v2/pet/findByStatus", FindPetsByStatus, }, - Route{ + { "FindPetsByTags", strings.ToUpper("Get"), "/v2/pet/findByTags", FindPetsByTags, }, - Route{ + { "GetPetById", strings.ToUpper("Get"), "/v2/pet/{petId}", GetPetById, }, - Route{ + { "UpdatePet", strings.ToUpper("Put"), "/v2/pet", UpdatePet, }, - Route{ + { "UpdatePetWithForm", strings.ToUpper("Post"), "/v2/pet/{petId}", UpdatePetWithForm, }, - Route{ + { "UploadFile", strings.ToUpper("Post"), "/v2/pet/{petId}/uploadImage", UploadFile, }, - Route{ + { "DeleteOrder", strings.ToUpper("Delete"), "/v2/store/order/{orderId}", DeleteOrder, }, - Route{ + { "GetInventory", strings.ToUpper("Get"), "/v2/store/inventory", GetInventory, }, - Route{ + { "GetOrderById", strings.ToUpper("Get"), "/v2/store/order/{orderId}", GetOrderById, }, - Route{ + { "PlaceOrder", strings.ToUpper("Post"), "/v2/store/order", PlaceOrder, }, - Route{ + { "CreateUser", strings.ToUpper("Post"), "/v2/user", CreateUser, }, - Route{ + { "CreateUsersWithArrayInput", strings.ToUpper("Post"), "/v2/user/createWithArray", CreateUsersWithArrayInput, }, - Route{ + { "CreateUsersWithListInput", strings.ToUpper("Post"), "/v2/user/createWithList", CreateUsersWithListInput, }, - Route{ + { "DeleteUser", strings.ToUpper("Delete"), "/v2/user/{username}", DeleteUser, }, - Route{ + { "GetUserByName", strings.ToUpper("Get"), "/v2/user/{username}", GetUserByName, }, - Route{ + { "LoginUser", strings.ToUpper("Get"), "/v2/user/login", LoginUser, }, - Route{ + { "LogoutUser", strings.ToUpper("Get"), "/v2/user/logout", LogoutUser, }, - Route{ + { "UpdateUser", strings.ToUpper("Put"), "/v2/user/{username}",