Esempio n. 1
0
func cloneSchema(schema *swspec.Schema) (*swspec.Schema, error) {
	var sch swspec.Schema
	if err := swag.FromDynamicJSON(schema, &sch); err != nil {
		return nil, fmt.Errorf("name inlined schema: %v", err)
	}
	return &sch, nil
}
Esempio n. 2
0
	api.RegisterOperation("get", "/pets/{id}", getPetByID)

	return middleware.Serve(spec, api), nil
}

var getAllPets = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) {
	fmt.Println("getAllPets")
	fmt.Printf("%#v\n", data)
	return pets, nil
})
var createPet = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) {
	fmt.Println("createPet")
	fmt.Printf("%#v\n", data)
	body := data.(map[string]interface{})["pet"]
	var pet Pet
	if err := swag.FromDynamicJSON(body, &pet); err != nil {
		return nil, err
	}
	addPet(pet)
	return body, nil
})

var deletePet = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) {
	fmt.Println("deletePet")
	fmt.Printf("%#v\n", data)
	id := data.(map[string]interface{})["id"].(int64)
	removePet(id)
	return nil, nil
})

var getPetByID = runtime.OperationHandlerFunc(func(data interface{}) (interface{}, error) {