mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
29 lines
509 B
Go
29 lines
509 B
Go
package main
|
|
|
|
import (
|
|
sw "./swagger"
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
func main() {
|
|
|
|
s := sw.NewPetApi()
|
|
|
|
// test POST(body)
|
|
newPet := (sw.Pet{Id: 12830, Name: "gopher",
|
|
PhotoUrls: []string{"http://1.com", "http://2.com"}, Status: "pending"})
|
|
|
|
jsonNewPet, _ := json.Marshal(newPet)
|
|
fmt.Println("newPet:", string(jsonNewPet))
|
|
s.AddPet(newPet)
|
|
|
|
// test POST(form)
|
|
s.UpdatePetWithForm(12830, "golang", "available")
|
|
|
|
// test GET
|
|
resp, err := s.GetPetById(12830)
|
|
fmt.Println("GetPetById: ", resp, err)
|
|
|
|
}
|