forked from loafle/openapi-generator-original
Go server clean up (#328)
This commit is contained in:
parent
97bab928bd
commit
c51986d657
@ -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)
|
||||
|
@ -15,7 +15,7 @@ const (
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
){{/isEnum}}{{^isEnum}}{{#description}}
|
||||
// {{{description}}}{{/description}}
|
||||
// {{classname}} - {{{description}}}{{/description}}
|
||||
type {{classname}} struct {
|
||||
{{#vars}}{{#description}}
|
||||
// {{{description}}}{{/description}}
|
||||
|
@ -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}}}",
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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"`
|
||||
|
@ -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"`
|
||||
|
@ -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"`
|
||||
|
@ -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"`
|
||||
|
@ -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"`
|
||||
|
@ -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"`
|
||||
|
@ -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}",
|
||||
|
Loading…
x
Reference in New Issue
Block a user