Output models for go-server #3851 (#7188)

* Output swagger models.

Fix route verbs and formatting

* Remove backup files

* Make postProcessOperations consistent with go client
This commit is contained in:
Ben Wells
2017-12-17 13:55:20 +00:00
committed by William Cheng
parent 8f2ed1c503
commit d25341d58d
23 changed files with 1380 additions and 150 deletions

View File

@@ -13,7 +13,7 @@ To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)
- API version: 1.0.0
- Build date: 2017-12-12T20:26:23.341Z
- Build date: 2017-12-17T09:38:04.917Z
### Running the server

View File

@@ -0,0 +1,21 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
// Describes the result of uploading an image resource
type ApiResponse struct {
Code int32 `json:"code,omitempty"`
Type_ string `json:"type,omitempty"`
Message string `json:"message,omitempty"`
}

View File

@@ -1 +0,0 @@
application: petstoreserver

View File

@@ -0,0 +1,19 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
// A category for a pet
type Category struct {
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}

View File

@@ -1,3 +1,13 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (

View File

@@ -0,0 +1,32 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (
"time"
)
// An order for a pets from the pet store
type Order struct {
Id int64 `json:"id,omitempty"`
PetId int64 `json:"petId,omitempty"`
Quantity int32 `json:"quantity,omitempty"`
ShipDate time.Time `json:"shipDate,omitempty"`
// Order Status
Status string `json:"status,omitempty"`
Complete bool `json:"complete,omitempty"`
}

View File

@@ -1,48 +1,28 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (
"net/http"
)
// A pet for sale in the pet store
type Pet struct {
}
func AddPet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Id int64 `json:"id,omitempty"`
func DeletePet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Category *Category `json:"category,omitempty"`
func FindPetsByStatus(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Name string `json:"name"`
func FindPetsByTags(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
PhotoUrls []string `json:"photoUrls"`
func GetPetById(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Tags []Tag `json:"tags,omitempty"`
func UpdatePet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func UpdatePetWithForm(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func UploadFile(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
// pet status in the store
Status string `json:"status,omitempty"`
}

View File

@@ -0,0 +1,55 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (
"net/http"
)
func AddPet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func DeletePet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func FindPetsByStatus(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func FindPetsByTags(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func GetPetById(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func UpdatePet(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func UpdatePetWithForm(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func UploadFile(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}

View File

@@ -1,8 +1,19 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (
"fmt"
"net/http"
"strings"
"github.com/gorilla/mux"
)
@@ -47,140 +58,140 @@ var routes = Routes{
Route{
"AddPet",
"POST",
strings.ToUpper("Post"),
"/v2/pet",
AddPet,
},
Route{
"DeletePet",
"DELETE",
strings.ToUpper("Delete"),
"/v2/pet/{petId}",
DeletePet,
},
Route{
"FindPetsByStatus",
"GET",
strings.ToUpper("Get"),
"/v2/pet/findByStatus",
FindPetsByStatus,
},
Route{
"FindPetsByTags",
"GET",
strings.ToUpper("Get"),
"/v2/pet/findByTags",
FindPetsByTags,
},
Route{
"GetPetById",
"GET",
strings.ToUpper("Get"),
"/v2/pet/{petId}",
GetPetById,
},
Route{
"UpdatePet",
"PUT",
strings.ToUpper("Put"),
"/v2/pet",
UpdatePet,
},
Route{
"UpdatePetWithForm",
"POST",
strings.ToUpper("Post"),
"/v2/pet/{petId}",
UpdatePetWithForm,
},
Route{
"UploadFile",
"POST",
strings.ToUpper("Post"),
"/v2/pet/{petId}/uploadImage",
UploadFile,
},
Route{
"DeleteOrder",
"DELETE",
strings.ToUpper("Delete"),
"/v2/store/order/{orderId}",
DeleteOrder,
},
Route{
"GetInventory",
"GET",
strings.ToUpper("Get"),
"/v2/store/inventory",
GetInventory,
},
Route{
"GetOrderById",
"GET",
strings.ToUpper("Get"),
"/v2/store/order/{orderId}",
GetOrderById,
},
Route{
"PlaceOrder",
"POST",
strings.ToUpper("Post"),
"/v2/store/order",
PlaceOrder,
},
Route{
"CreateUser",
"POST",
strings.ToUpper("Post"),
"/v2/user",
CreateUser,
},
Route{
"CreateUsersWithArrayInput",
"POST",
strings.ToUpper("Post"),
"/v2/user/createWithArray",
CreateUsersWithArrayInput,
},
Route{
"CreateUsersWithListInput",
"POST",
strings.ToUpper("Post"),
"/v2/user/createWithList",
CreateUsersWithListInput,
},
Route{
"DeleteUser",
"DELETE",
strings.ToUpper("Delete"),
"/v2/user/{username}",
DeleteUser,
},
Route{
"GetUserByName",
"GET",
strings.ToUpper("Get"),
"/v2/user/{username}",
GetUserByName,
},
Route{
"LoginUser",
"GET",
strings.ToUpper("Get"),
"/v2/user/login",
LoginUser,
},
Route{
"LogoutUser",
"GET",
strings.ToUpper("Get"),
"/v2/user/logout",
LogoutUser,
},
Route{
"UpdateUser",
"PUT",
strings.ToUpper("Put"),
"/v2/user/{username}",
UpdateUser,
},

View File

@@ -1,12 +1,19 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (
"net/http"
)
type Store struct {
}
func DeleteOrder(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)

View File

@@ -0,0 +1,19 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
// A tag for a pet
type Tag struct {
Id int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
}

View File

@@ -1,48 +1,32 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (
"net/http"
)
// A User who is purchasing from the pet store
type User struct {
}
func CreateUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Id int64 `json:"id,omitempty"`
func CreateUsersWithArrayInput(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Username string `json:"username,omitempty"`
func CreateUsersWithListInput(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
FirstName string `json:"firstName,omitempty"`
func DeleteUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
LastName string `json:"lastName,omitempty"`
func GetUserByName(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Email string `json:"email,omitempty"`
func LoginUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Password string `json:"password,omitempty"`
func LogoutUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
Phone string `json:"phone,omitempty"`
func UpdateUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
// User Status
UserStatus int32 `json:"userStatus,omitempty"`
}

View File

@@ -0,0 +1,55 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* API version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package petstoreserver
import (
"net/http"
)
func CreateUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func CreateUsersWithArrayInput(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func CreateUsersWithListInput(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func DeleteUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func GetUserByName(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func LoginUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func LogoutUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
func UpdateUser(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}