replace 4-space with tab (#4188)

This commit is contained in:
William Cheng
2019-10-20 00:46:25 +08:00
committed by GitHub
parent fd24088dda
commit f43c720b08
12 changed files with 336 additions and 336 deletions

View File

@@ -3,7 +3,7 @@ package {{packageName}}
import (
"net/http"{{#apiInfo}}{{#apis}}{{#imports}}
"{{import}}"{{/imports}}{{/apis}}{{/apiInfo}}
"{{import}}"{{/imports}}{{/apis}}{{/apiInfo}}
)
{{#apiInfo}}{{#apis}}
@@ -20,5 +20,5 @@ type {{classname}}Router interface { {{#operations}}{{#operation}}
// while the service implementation can ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type {{classname}}Servicer interface { {{#operations}}{{#operation}}
{{operationId}}({{#allParams}}{{dataType}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) (interface{}, error){{/operation}}{{/operations}}
{{operationId}}({{#allParams}}{{dataType}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) (interface{}, error){{/operation}}{{/operations}}
}{{/apis}}{{/apiInfo}}

View File

@@ -11,12 +11,12 @@ import (
// A {{classname}}Controller binds http requests to an api service and writes the service results to the http response
type {{classname}}Controller struct {
service {{classname}}Servicer
service {{classname}}Servicer
}
// New{{classname}}Controller creates a default api controller
func New{{classname}}Controller(s {{classname}}Servicer) {{classname}}Router {
return &{{classname}}Controller{ service: s }
return &{{classname}}Controller{ service: s }
}
// Routes returns all of the api route for the {{classname}}Controller
@@ -35,51 +35,51 @@ func (c *{{classname}}Controller) Routes() Routes {
func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Request) { {{#hasFormParams}}
err := r.ParseForm()
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
{{/hasFormParams}}{{#hasPathParams}}
params := mux.Vars(r){{/hasPathParams}}{{#hasQueryParams}}
query := r.URL.Query(){{/hasQueryParams}}{{#allParams}}{{#isPathParam}}{{#isLong}}
params := mux.Vars(r){{/hasPathParams}}{{#hasQueryParams}}
query := r.URL.Query(){{/hasQueryParams}}{{#allParams}}{{#isPathParam}}{{#isLong}}
{{paramName}}, err := parseIntParameter(params["{{paramName}}"])
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
{{/isLong}}{{^isLong}}
{{paramName}} := params["{{paramName}}"]{{/isLong}}{{/isPathParam}}{{#isQueryParam}}{{#isLong}}
{{paramName}}, err := parseIntParameter(query.Get("{{paramName}}"))
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
{{/isLong}}{{^isLong}}
{{paramName}} := {{#isListContainer}}strings.Split({{/isListContainer}}query.Get("{{paramName}}"){{#isListContainer}}, ","){{/isListContainer}}{{/isLong}}{{/isQueryParam}}{{#isFormParam}}{{#isFile}}
{{paramName}} := {{#isListContainer}}strings.Split({{/isListContainer}}query.Get("{{paramName}}"){{#isListContainer}}, ","){{/isListContainer}}{{/isLong}}{{/isQueryParam}}{{#isFormParam}}{{#isFile}}
{{paramName}}, err := ReadFormFileToTempFile(r, "{{paramName}}")
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
{{/isFile}}{{#isLong}}
{{paramName}}, err := parseIntParameter( r.FormValue("{{paramName}}"))
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
{{/isLong}}{{^isFile}}{{^isLong}}
{{paramName}} := r.FormValue("{{paramName}}"){{/isLong}}{{/isFile}}{{/isFormParam}}{{#isHeaderParam}}
{{paramName}} := r.Header.Get("{{paramName}}"){{/isHeaderParam}}{{#isBodyParam}}
{{paramName}} := &{{dataType}}{}
if err := json.NewDecoder(r.Body).Decode(&{{paramName}}); err != nil {
w.WriteHeader(500)
return
}
{{paramName}} := r.FormValue("{{paramName}}"){{/isLong}}{{/isFile}}{{/isFormParam}}{{#isHeaderParam}}
{{paramName}} := r.Header.Get("{{paramName}}"){{/isHeaderParam}}{{#isBodyParam}}
{{paramName}} := &{{dataType}}{}
if err := json.NewDecoder(r.Body).Decode(&{{paramName}}); err != nil {
w.WriteHeader(500)
return
}
{{/isBodyParam}}{{/allParams}}
result, err := c.service.{{nickname}}({{#allParams}}{{#isBodyParam}}*{{/isBodyParam}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.{{nickname}}({{#allParams}}{{#isBodyParam}}*{{/isBodyParam}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}{{/operation}}{{/operations}}

View File

@@ -3,7 +3,7 @@ package {{packageName}}
import (
"encoding/json"
"io/ioutil"
"io/ioutil"
"net/http"
"os"
"strconv"

View File

@@ -2,8 +2,8 @@
package {{packageName}}
import (
"errors"{{#imports}}
"{{import}}"{{/imports}}
"errors"{{#imports}}
"{{import}}"{{/imports}}
)
// {{classname}}Service is a service that implents the logic for the {{classname}}Servicer
@@ -14,12 +14,12 @@ type {{classname}}Service struct {
// New{{classname}}Service creates a default api service
func New{{classname}}Service() {{classname}}Servicer {
return &{{classname}}Service{}
return &{{classname}}Service{}
}{{#operations}}{{#operation}}
// {{nickname}} - {{summary}}
func (s *{{classname}}Service) {{nickname}}({{#allParams}}{{paramName}} {{dataType}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) (interface{}, error) {
// TODO - update {{nickname}} with the required logic for this service method.
// Add {{classFilename}}_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method '{{nickname}}' not implemented")
// TODO - update {{nickname}} with the required logic for this service method.
// Add {{classFilename}}_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method '{{nickname}}' not implemented")
}{{/operation}}{{/operations}}

View File

@@ -11,7 +11,7 @@ package petstoreserver
import (
"net/http"
"os"
"os"
)
@@ -57,14 +57,14 @@ type UserApiRouter interface {
// while the service implementation can ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type PetApiServicer interface {
AddPet(Pet) (interface{}, error)
DeletePet(int64, string) (interface{}, error)
FindPetsByStatus([]string) (interface{}, error)
FindPetsByTags([]string) (interface{}, error)
GetPetById(int64) (interface{}, error)
UpdatePet(Pet) (interface{}, error)
UpdatePetWithForm(int64, string, string) (interface{}, error)
UploadFile(int64, string, *os.File) (interface{}, error)
AddPet(Pet) (interface{}, error)
DeletePet(int64, string) (interface{}, error)
FindPetsByStatus([]string) (interface{}, error)
FindPetsByTags([]string) (interface{}, error)
GetPetById(int64) (interface{}, error)
UpdatePet(Pet) (interface{}, error)
UpdatePetWithForm(int64, string, string) (interface{}, error)
UploadFile(int64, string, *os.File) (interface{}, error)
}
@@ -73,10 +73,10 @@ type PetApiServicer interface {
// while the service implementation can ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type StoreApiServicer interface {
DeleteOrder(string) (interface{}, error)
GetInventory() (interface{}, error)
GetOrderById(int64) (interface{}, error)
PlaceOrder(Order) (interface{}, error)
DeleteOrder(string) (interface{}, error)
GetInventory() (interface{}, error)
GetOrderById(int64) (interface{}, error)
PlaceOrder(Order) (interface{}, error)
}
@@ -85,12 +85,12 @@ type StoreApiServicer interface {
// while the service implementation can ignored with the .openapi-generator-ignore file
// and updated with the logic required for the API.
type UserApiServicer interface {
CreateUser(User) (interface{}, error)
CreateUsersWithArrayInput([]User) (interface{}, error)
CreateUsersWithListInput([]User) (interface{}, error)
DeleteUser(string) (interface{}, error)
GetUserByName(string) (interface{}, error)
LoginUser(string, string) (interface{}, error)
LogoutUser() (interface{}, error)
UpdateUser(string, User) (interface{}, error)
CreateUser(User) (interface{}, error)
CreateUsersWithArrayInput([]User) (interface{}, error)
CreateUsersWithListInput([]User) (interface{}, error)
DeleteUser(string) (interface{}, error)
GetUserByName(string) (interface{}, error)
LoginUser(string, string) (interface{}, error)
LogoutUser() (interface{}, error)
UpdateUser(string, User) (interface{}, error)
}

View File

@@ -19,12 +19,12 @@ import (
// A PetApiController binds http requests to an api service and writes the service results to the http response
type PetApiController struct {
service PetApiServicer
service PetApiServicer
}
// NewPetApiController creates a default api controller
func NewPetApiController(s PetApiServicer) PetApiRouter {
return &PetApiController{ service: s }
return &PetApiController{ service: s }
}
// Routes returns all of the api route for the PetApiController
@@ -83,154 +83,154 @@ func (c *PetApiController) Routes() Routes {
// AddPet - Add a new pet to the store
func (c *PetApiController) AddPet(w http.ResponseWriter, r *http.Request) {
body := &Pet{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
body := &Pet{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.AddPet(*body)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.AddPet(*body)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// DeletePet - Deletes a pet
func (c *PetApiController) DeletePet(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
params := mux.Vars(r)
petId, err := parseIntParameter(params["petId"])
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
apiKey := r.Header.Get("apiKey")
result, err := c.service.DeletePet(petId, apiKey)
if err != nil {
w.WriteHeader(500)
return
}
apiKey := r.Header.Get("apiKey")
result, err := c.service.DeletePet(petId, apiKey)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// FindPetsByStatus - Finds Pets by status
func (c *PetApiController) FindPetsByStatus(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
status := strings.Split(query.Get("status"), ",")
result, err := c.service.FindPetsByStatus(status)
if err != nil {
w.WriteHeader(500)
return
}
query := r.URL.Query()
status := strings.Split(query.Get("status"), ",")
result, err := c.service.FindPetsByStatus(status)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// FindPetsByTags - Finds Pets by tags
func (c *PetApiController) FindPetsByTags(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
tags := strings.Split(query.Get("tags"), ",")
result, err := c.service.FindPetsByTags(tags)
if err != nil {
w.WriteHeader(500)
return
}
query := r.URL.Query()
tags := strings.Split(query.Get("tags"), ",")
result, err := c.service.FindPetsByTags(tags)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// GetPetById - Find pet by ID
func (c *PetApiController) GetPetById(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
params := mux.Vars(r)
petId, err := parseIntParameter(params["petId"])
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
result, err := c.service.GetPetById(petId)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.GetPetById(petId)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// UpdatePet - Update an existing pet
func (c *PetApiController) UpdatePet(w http.ResponseWriter, r *http.Request) {
body := &Pet{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
body := &Pet{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.UpdatePet(*body)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.UpdatePet(*body)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// UpdatePetWithForm - Updates a pet in the store with form data
func (c *PetApiController) UpdatePetWithForm(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
params := mux.Vars(r)
params := mux.Vars(r)
petId, err := parseIntParameter(params["petId"])
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
name := r.FormValue("name")
status := r.FormValue("status")
result, err := c.service.UpdatePetWithForm(petId, name, status)
if err != nil {
w.WriteHeader(500)
return
}
name := r.FormValue("name")
status := r.FormValue("status")
result, err := c.service.UpdatePetWithForm(petId, name, status)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// UploadFile - uploads an image
func (c *PetApiController) UploadFile(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
params := mux.Vars(r)
params := mux.Vars(r)
petId, err := parseIntParameter(params["petId"])
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
additionalMetadata := r.FormValue("additionalMetadata")
additionalMetadata := r.FormValue("additionalMetadata")
file, err := ReadFormFileToTempFile(r, "file")
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
result, err := c.service.UploadFile(petId, additionalMetadata, file)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.UploadFile(petId, additionalMetadata, file)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}

View File

@@ -10,8 +10,8 @@
package petstoreserver
import (
"errors"
"os"
"errors"
"os"
)
// PetApiService is a service that implents the logic for the PetApiServicer
@@ -22,61 +22,61 @@ type PetApiService struct {
// NewPetApiService creates a default api service
func NewPetApiService() PetApiServicer {
return &PetApiService{}
return &PetApiService{}
}
// AddPet - Add a new pet to the store
func (s *PetApiService) AddPet(body Pet) (interface{}, error) {
// TODO - update AddPet with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'AddPet' not implemented")
// TODO - update AddPet with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'AddPet' not implemented")
}
// DeletePet - Deletes a pet
func (s *PetApiService) DeletePet(petId int64, apiKey string) (interface{}, error) {
// TODO - update DeletePet with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'DeletePet' not implemented")
// TODO - update DeletePet with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'DeletePet' not implemented")
}
// FindPetsByStatus - Finds Pets by status
func (s *PetApiService) FindPetsByStatus(status []string) (interface{}, error) {
// TODO - update FindPetsByStatus with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'FindPetsByStatus' not implemented")
// TODO - update FindPetsByStatus with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'FindPetsByStatus' not implemented")
}
// FindPetsByTags - Finds Pets by tags
func (s *PetApiService) FindPetsByTags(tags []string) (interface{}, error) {
// TODO - update FindPetsByTags with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'FindPetsByTags' not implemented")
// TODO - update FindPetsByTags with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'FindPetsByTags' not implemented")
}
// GetPetById - Find pet by ID
func (s *PetApiService) GetPetById(petId int64) (interface{}, error) {
// TODO - update GetPetById with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetPetById' not implemented")
// TODO - update GetPetById with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetPetById' not implemented")
}
// UpdatePet - Update an existing pet
func (s *PetApiService) UpdatePet(body Pet) (interface{}, error) {
// TODO - update UpdatePet with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UpdatePet' not implemented")
// TODO - update UpdatePet with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UpdatePet' not implemented")
}
// UpdatePetWithForm - Updates a pet in the store with form data
func (s *PetApiService) UpdatePetWithForm(petId int64, name string, status string) (interface{}, error) {
// TODO - update UpdatePetWithForm with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UpdatePetWithForm' not implemented")
// TODO - update UpdatePetWithForm with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UpdatePetWithForm' not implemented")
}
// UploadFile - uploads an image
func (s *PetApiService) UploadFile(petId int64, additionalMetadata string, file *os.File) (interface{}, error) {
// TODO - update UploadFile with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UploadFile' not implemented")
// TODO - update UploadFile with the required logic for this service method.
// Add api_pet_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UploadFile' not implemented")
}

View File

@@ -19,12 +19,12 @@ import (
// A StoreApiController binds http requests to an api service and writes the service results to the http response
type StoreApiController struct {
service StoreApiServicer
service StoreApiServicer
}
// NewStoreApiController creates a default api controller
func NewStoreApiController(s StoreApiServicer) StoreApiRouter {
return &StoreApiController{ service: s }
return &StoreApiController{ service: s }
}
// Routes returns all of the api route for the StoreApiController
@@ -59,59 +59,59 @@ func (c *StoreApiController) Routes() Routes {
// DeleteOrder - Delete purchase order by ID
func (c *StoreApiController) DeleteOrder(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
params := mux.Vars(r)
orderId := params["orderId"]
result, err := c.service.DeleteOrder(orderId)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.DeleteOrder(orderId)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// GetInventory - Returns pet inventories by status
func (c *StoreApiController) GetInventory(w http.ResponseWriter, r *http.Request) {
result, err := c.service.GetInventory()
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.GetInventory()
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// GetOrderById - Find purchase order by ID
func (c *StoreApiController) GetOrderById(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
params := mux.Vars(r)
orderId, err := parseIntParameter(params["orderId"])
if err != nil {
w.WriteHeader(500)
return
}
w.WriteHeader(500)
return
}
result, err := c.service.GetOrderById(orderId)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.GetOrderById(orderId)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// PlaceOrder - Place an order for a pet
func (c *StoreApiController) PlaceOrder(w http.ResponseWriter, r *http.Request) {
body := &Order{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
body := &Order{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.PlaceOrder(*body)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.PlaceOrder(*body)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}

View File

@@ -10,7 +10,7 @@
package petstoreserver
import (
"errors"
"errors"
)
// StoreApiService is a service that implents the logic for the StoreApiServicer
@@ -21,33 +21,33 @@ type StoreApiService struct {
// NewStoreApiService creates a default api service
func NewStoreApiService() StoreApiServicer {
return &StoreApiService{}
return &StoreApiService{}
}
// DeleteOrder - Delete purchase order by ID
func (s *StoreApiService) DeleteOrder(orderId string) (interface{}, error) {
// TODO - update DeleteOrder with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'DeleteOrder' not implemented")
// TODO - update DeleteOrder with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'DeleteOrder' not implemented")
}
// GetInventory - Returns pet inventories by status
func (s *StoreApiService) GetInventory() (interface{}, error) {
// TODO - update GetInventory with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetInventory' not implemented")
// TODO - update GetInventory with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetInventory' not implemented")
}
// GetOrderById - Find purchase order by ID
func (s *StoreApiService) GetOrderById(orderId int64) (interface{}, error) {
// TODO - update GetOrderById with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetOrderById' not implemented")
// TODO - update GetOrderById with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetOrderById' not implemented")
}
// PlaceOrder - Place an order for a pet
func (s *StoreApiService) PlaceOrder(body Order) (interface{}, error) {
// TODO - update PlaceOrder with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'PlaceOrder' not implemented")
// TODO - update PlaceOrder with the required logic for this service method.
// Add api_store_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'PlaceOrder' not implemented")
}

View File

@@ -19,12 +19,12 @@ import (
// A UserApiController binds http requests to an api service and writes the service results to the http response
type UserApiController struct {
service UserApiServicer
service UserApiServicer
}
// NewUserApiController creates a default api controller
func NewUserApiController(s UserApiServicer) UserApiRouter {
return &UserApiController{ service: s }
return &UserApiController{ service: s }
}
// Routes returns all of the api route for the UserApiController
@@ -83,121 +83,121 @@ func (c *UserApiController) Routes() Routes {
// CreateUser - Create user
func (c *UserApiController) CreateUser(w http.ResponseWriter, r *http.Request) {
body := &User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
body := &User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.CreateUser(*body)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.CreateUser(*body)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// CreateUsersWithArrayInput - Creates list of users with given input array
func (c *UserApiController) CreateUsersWithArrayInput(w http.ResponseWriter, r *http.Request) {
body := &[]User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
body := &[]User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.CreateUsersWithArrayInput(*body)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.CreateUsersWithArrayInput(*body)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// CreateUsersWithListInput - Creates list of users with given input array
func (c *UserApiController) CreateUsersWithListInput(w http.ResponseWriter, r *http.Request) {
body := &[]User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
body := &[]User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.CreateUsersWithListInput(*body)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.CreateUsersWithListInput(*body)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// DeleteUser - Delete user
func (c *UserApiController) DeleteUser(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
params := mux.Vars(r)
username := params["username"]
result, err := c.service.DeleteUser(username)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.DeleteUser(username)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// GetUserByName - Get user by user name
func (c *UserApiController) GetUserByName(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
params := mux.Vars(r)
username := params["username"]
result, err := c.service.GetUserByName(username)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.GetUserByName(username)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// LoginUser - Logs user into the system
func (c *UserApiController) LoginUser(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
username := query.Get("username")
password := query.Get("password")
result, err := c.service.LoginUser(username, password)
if err != nil {
w.WriteHeader(500)
return
}
query := r.URL.Query()
username := query.Get("username")
password := query.Get("password")
result, err := c.service.LoginUser(username, password)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// LogoutUser - Logs out current logged in user session
func (c *UserApiController) LogoutUser(w http.ResponseWriter, r *http.Request) {
result, err := c.service.LogoutUser()
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.LogoutUser()
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}
// UpdateUser - Updated user
func (c *UserApiController) UpdateUser(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
params := mux.Vars(r)
username := params["username"]
body := &User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
body := &User{}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.UpdateUser(username, *body)
if err != nil {
w.WriteHeader(500)
return
}
result, err := c.service.UpdateUser(username, *body)
if err != nil {
w.WriteHeader(500)
return
}
EncodeJSONResponse(result, nil, w)
EncodeJSONResponse(result, nil, w)
}

View File

@@ -10,7 +10,7 @@
package petstoreserver
import (
"errors"
"errors"
)
// UserApiService is a service that implents the logic for the UserApiServicer
@@ -21,61 +21,61 @@ type UserApiService struct {
// NewUserApiService creates a default api service
func NewUserApiService() UserApiServicer {
return &UserApiService{}
return &UserApiService{}
}
// CreateUser - Create user
func (s *UserApiService) CreateUser(body User) (interface{}, error) {
// TODO - update CreateUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'CreateUser' not implemented")
// TODO - update CreateUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'CreateUser' not implemented")
}
// CreateUsersWithArrayInput - Creates list of users with given input array
func (s *UserApiService) CreateUsersWithArrayInput(body []User) (interface{}, error) {
// TODO - update CreateUsersWithArrayInput with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'CreateUsersWithArrayInput' not implemented")
// TODO - update CreateUsersWithArrayInput with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'CreateUsersWithArrayInput' not implemented")
}
// CreateUsersWithListInput - Creates list of users with given input array
func (s *UserApiService) CreateUsersWithListInput(body []User) (interface{}, error) {
// TODO - update CreateUsersWithListInput with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'CreateUsersWithListInput' not implemented")
// TODO - update CreateUsersWithListInput with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'CreateUsersWithListInput' not implemented")
}
// DeleteUser - Delete user
func (s *UserApiService) DeleteUser(username string) (interface{}, error) {
// TODO - update DeleteUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'DeleteUser' not implemented")
// TODO - update DeleteUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'DeleteUser' not implemented")
}
// GetUserByName - Get user by user name
func (s *UserApiService) GetUserByName(username string) (interface{}, error) {
// TODO - update GetUserByName with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetUserByName' not implemented")
// TODO - update GetUserByName with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'GetUserByName' not implemented")
}
// LoginUser - Logs user into the system
func (s *UserApiService) LoginUser(username string, password string) (interface{}, error) {
// TODO - update LoginUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'LoginUser' not implemented")
// TODO - update LoginUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'LoginUser' not implemented")
}
// LogoutUser - Logs out current logged in user session
func (s *UserApiService) LogoutUser() (interface{}, error) {
// TODO - update LogoutUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'LogoutUser' not implemented")
// TODO - update LogoutUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'LogoutUser' not implemented")
}
// UpdateUser - Updated user
func (s *UserApiService) UpdateUser(username string, body User) (interface{}, error) {
// TODO - update UpdateUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UpdateUser' not implemented")
// TODO - update UpdateUser with the required logic for this service method.
// Add api_user_service.go to the .openapi-generator-ignore to avoid overwriting this service implementation when updating open api generation.
return nil, errors.New("service method 'UpdateUser' not implemented")
}

View File

@@ -11,7 +11,7 @@ package petstoreserver
import (
"encoding/json"
"io/ioutil"
"io/ioutil"
"net/http"
"os"
"strconv"