2019-10-09 18:35:56 +08:00

324 lines
4.8 KiB
Go

/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* API version: 1.0.0
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package petstoreserver
import (
"fmt"
"net/http"
"strings"
"github.com/gorilla/mux"
)
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
func NewRouter() *mux.Router {
router := mux.NewRouter().StrictSlash(true)
for _, route := range routes {
var handler http.Handler
handler = route.HandlerFunc
handler = Logger(handler, route.Name)
router.
Methods(route.Method).
Path(route.Pattern).
Name(route.Name).
Handler(handler)
}
return router
}
func Index(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
}
var routes = Routes{
{
"Index",
"GET",
"/v2/",
Index,
},
{
"Call123TestSpecialTags",
strings.ToUpper("Patch"),
"/v2/another-fake/dummy",
Call123TestSpecialTags,
},
{
"FooGet",
strings.ToUpper("Get"),
"/v2/foo",
FooGet,
},
{
"FakeHealthGet",
strings.ToUpper("Get"),
"/v2/fake/health",
FakeHealthGet,
},
{
"FakeOuterBooleanSerialize",
strings.ToUpper("Post"),
"/v2/fake/outer/boolean",
FakeOuterBooleanSerialize,
},
{
"FakeOuterCompositeSerialize",
strings.ToUpper("Post"),
"/v2/fake/outer/composite",
FakeOuterCompositeSerialize,
},
{
"FakeOuterNumberSerialize",
strings.ToUpper("Post"),
"/v2/fake/outer/number",
FakeOuterNumberSerialize,
},
{
"FakeOuterStringSerialize",
strings.ToUpper("Post"),
"/v2/fake/outer/string",
FakeOuterStringSerialize,
},
{
"TestBodyWithFileSchema",
strings.ToUpper("Put"),
"/v2/fake/body-with-file-schema",
TestBodyWithFileSchema,
},
{
"TestBodyWithQueryParams",
strings.ToUpper("Put"),
"/v2/fake/body-with-query-params",
TestBodyWithQueryParams,
},
{
"TestClientModel",
strings.ToUpper("Patch"),
"/v2/fake",
TestClientModel,
},
{
"TestEndpointParameters",
strings.ToUpper("Post"),
"/v2/fake",
TestEndpointParameters,
},
{
"TestEnumParameters",
strings.ToUpper("Get"),
"/v2/fake",
TestEnumParameters,
},
{
"TestGroupParameters",
strings.ToUpper("Delete"),
"/v2/fake",
TestGroupParameters,
},
{
"TestInlineAdditionalProperties",
strings.ToUpper("Post"),
"/v2/fake/inline-additionalProperties",
TestInlineAdditionalProperties,
},
{
"TestJsonFormData",
strings.ToUpper("Get"),
"/v2/fake/jsonFormData",
TestJsonFormData,
},
{
"TestQueryParameterCollectionFormat",
strings.ToUpper("Put"),
"/v2/fake/test-query-paramters",
TestQueryParameterCollectionFormat,
},
{
"TestClassname",
strings.ToUpper("Patch"),
"/v2/fake_classname_test",
TestClassname,
},
{
"AddPet",
strings.ToUpper("Post"),
"/v2/pet",
AddPet,
},
{
"DeletePet",
strings.ToUpper("Delete"),
"/v2/pet/{petId}",
DeletePet,
},
{
"FindPetsByStatus",
strings.ToUpper("Get"),
"/v2/pet/findByStatus",
FindPetsByStatus,
},
{
"FindPetsByTags",
strings.ToUpper("Get"),
"/v2/pet/findByTags",
FindPetsByTags,
},
{
"GetPetById",
strings.ToUpper("Get"),
"/v2/pet/{petId}",
GetPetById,
},
{
"UpdatePet",
strings.ToUpper("Put"),
"/v2/pet",
UpdatePet,
},
{
"UpdatePetWithForm",
strings.ToUpper("Post"),
"/v2/pet/{petId}",
UpdatePetWithForm,
},
{
"UploadFile",
strings.ToUpper("Post"),
"/v2/pet/{petId}/uploadImage",
UploadFile,
},
{
"UploadFileWithRequiredFile",
strings.ToUpper("Post"),
"/v2/fake/{petId}/uploadImageWithRequiredFile",
UploadFileWithRequiredFile,
},
{
"DeleteOrder",
strings.ToUpper("Delete"),
"/v2/store/order/{order_id}",
DeleteOrder,
},
{
"GetInventory",
strings.ToUpper("Get"),
"/v2/store/inventory",
GetInventory,
},
{
"GetOrderById",
strings.ToUpper("Get"),
"/v2/store/order/{order_id}",
GetOrderById,
},
{
"PlaceOrder",
strings.ToUpper("Post"),
"/v2/store/order",
PlaceOrder,
},
{
"CreateUser",
strings.ToUpper("Post"),
"/v2/user",
CreateUser,
},
{
"CreateUsersWithArrayInput",
strings.ToUpper("Post"),
"/v2/user/createWithArray",
CreateUsersWithArrayInput,
},
{
"CreateUsersWithListInput",
strings.ToUpper("Post"),
"/v2/user/createWithList",
CreateUsersWithListInput,
},
{
"DeleteUser",
strings.ToUpper("Delete"),
"/v2/user/{username}",
DeleteUser,
},
{
"GetUserByName",
strings.ToUpper("Get"),
"/v2/user/{username}",
GetUserByName,
},
{
"LoginUser",
strings.ToUpper("Get"),
"/v2/user/login",
LoginUser,
},
{
"LogoutUser",
strings.ToUpper("Get"),
"/v2/user/logout",
LogoutUser,
},
{
"UpdateUser",
strings.ToUpper("Put"),
"/v2/user/{username}",
UpdateUser,
},
}