From 5e76480aee071c2506891dd3e8b11176f1b2611f Mon Sep 17 00:00:00 2001 From: Michael Filanov Date: Mon, 16 Jul 2018 09:14:35 +0300 Subject: [PATCH] update go-swagger source to swagger:0.15.0 update generated example --- Dockerfile | 2 +- .../client/store/inventory_get_responses.go | 18 +----------------- .../operations/pet/pet_create_parameters.go | 1 - .../operations/pet/pet_delete_parameters.go | 2 ++ .../operations/pet/pet_get_parameters.go | 1 + .../operations/pet/pet_list_parameters.go | 8 +++----- .../operations/pet/pet_update_parameters.go | 2 +- .../restapi/operations/store/inventory_get.go | 16 ---------------- .../store/inventory_get_responses.go | 6 +++--- .../store/order_create_parameters.go | 1 - .../store/order_delete_parameters.go | 2 ++ .../operations/store/order_get_parameters.go | 2 ++ 12 files changed, 16 insertions(+), 45 deletions(-) diff --git a/Dockerfile b/Dockerfile index f18b83b..61d0352 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/goswagger/swagger:0.14.0 +FROM quay.io/goswagger/swagger:0.15.0 ADD ./templates /templates ADD ./entrypoint.sh /entrypoint.sh diff --git a/example/client/store/inventory_get_responses.go b/example/client/store/inventory_get_responses.go index 71256e5..c2eebea 100644 --- a/example/client/store/inventory_get_responses.go +++ b/example/client/store/inventory_get_responses.go @@ -9,7 +9,6 @@ import ( "fmt" "io" - "github.com/go-openapi/errors" "github.com/go-openapi/runtime" strfmt "github.com/go-openapi/strfmt" @@ -46,7 +45,7 @@ func NewInventoryGetOK() *InventoryGetOK { successful operation */ type InventoryGetOK struct { - Payload InventoryGetOKBody + Payload map[string]int32 } func (o *InventoryGetOK) Error() string { @@ -62,18 +61,3 @@ func (o *InventoryGetOK) readResponse(response runtime.ClientResponse, consumer return nil } - -/*InventoryGetOKBody inventory get o k body -swagger:model InventoryGetOKBody -*/ -type InventoryGetOKBody map[string]int32 - -// Validate validates this inventory get o k body -func (o InventoryGetOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/example/restapi/operations/pet/pet_create_parameters.go b/example/restapi/operations/pet/pet_create_parameters.go index cc3f0af..de944f1 100644 --- a/example/restapi/operations/pet/pet_create_parameters.go +++ b/example/restapi/operations/pet/pet_create_parameters.go @@ -58,7 +58,6 @@ func (o *PetCreateParams) BindRequest(r *http.Request, route *middleware.Matched res = append(res, errors.NewParseError("pet", "body", "", err)) } } else { - // validate body object if err := body.Validate(route.Formats); err != nil { res = append(res, err) diff --git a/example/restapi/operations/pet/pet_delete_parameters.go b/example/restapi/operations/pet/pet_delete_parameters.go index d13221d..c6f19c7 100644 --- a/example/restapi/operations/pet/pet_delete_parameters.go +++ b/example/restapi/operations/pet/pet_delete_parameters.go @@ -66,6 +66,7 @@ func (o *PetDeleteParams) BindRequest(r *http.Request, route *middleware.Matched return nil } +// bindAPIKey binds and validates parameter APIKey from header. func (o *PetDeleteParams) bindAPIKey(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { @@ -83,6 +84,7 @@ func (o *PetDeleteParams) bindAPIKey(rawData []string, hasKey bool, formats strf return nil } +// bindPetID binds and validates parameter PetID from path. func (o *PetDeleteParams) bindPetID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { diff --git a/example/restapi/operations/pet/pet_get_parameters.go b/example/restapi/operations/pet/pet_get_parameters.go index e607696..1706478 100644 --- a/example/restapi/operations/pet/pet_get_parameters.go +++ b/example/restapi/operations/pet/pet_get_parameters.go @@ -58,6 +58,7 @@ func (o *PetGetParams) BindRequest(r *http.Request, route *middleware.MatchedRou return nil } +// bindPetID binds and validates parameter PetID from path. func (o *PetGetParams) bindPetID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { diff --git a/example/restapi/operations/pet/pet_list_parameters.go b/example/restapi/operations/pet/pet_list_parameters.go index 738321e..4771ee7 100644 --- a/example/restapi/operations/pet/pet_list_parameters.go +++ b/example/restapi/operations/pet/pet_list_parameters.go @@ -63,6 +63,9 @@ func (o *PetListParams) BindRequest(r *http.Request, route *middleware.MatchedRo return nil } +// bindStatus binds and validates array parameter Status from query. +// +// Arrays are parsed according to CollectionFormat: "multi" (defaults to "csv" when empty). func (o *PetListParams) bindStatus(rawData []string, hasKey bool, formats strfmt.Registry) error { if !hasKey { return errors.Required("status", "query") @@ -90,8 +93,3 @@ func (o *PetListParams) bindStatus(rawData []string, hasKey bool, formats strfmt return nil } - -func (o *PetListParams) validateStatus(formats strfmt.Registry) error { - - return nil -} diff --git a/example/restapi/operations/pet/pet_update_parameters.go b/example/restapi/operations/pet/pet_update_parameters.go index 842bdec..cf9f8fe 100644 --- a/example/restapi/operations/pet/pet_update_parameters.go +++ b/example/restapi/operations/pet/pet_update_parameters.go @@ -66,7 +66,6 @@ func (o *PetUpdateParams) BindRequest(r *http.Request, route *middleware.Matched res = append(res, errors.NewParseError("pet", "body", "", err)) } } else { - // validate body object if err := body.Validate(route.Formats); err != nil { res = append(res, err) @@ -90,6 +89,7 @@ func (o *PetUpdateParams) BindRequest(r *http.Request, route *middleware.Matched return nil } +// bindPetID binds and validates parameter PetID from path. func (o *PetUpdateParams) bindPetID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { diff --git a/example/restapi/operations/store/inventory_get.go b/example/restapi/operations/store/inventory_get.go index 320b060..fc4f12f 100644 --- a/example/restapi/operations/store/inventory_get.go +++ b/example/restapi/operations/store/inventory_get.go @@ -8,9 +8,7 @@ package store import ( "net/http" - errors "github.com/go-openapi/errors" middleware "github.com/go-openapi/runtime/middleware" - strfmt "github.com/go-openapi/strfmt" ) // InventoryGetHandlerFunc turns a function with the right signature into a inventory get handler @@ -71,17 +69,3 @@ func (o *InventoryGet) ServeHTTP(rw http.ResponseWriter, r *http.Request) { o.Context.Respond(rw, r, route.Produces, route, res) } - -// InventoryGetOKBody inventory get o k body -// swagger:model InventoryGetOKBody -type InventoryGetOKBody map[string]int32 - -// Validate validates this inventory get o k body -func (o InventoryGetOKBody) Validate(formats strfmt.Registry) error { - var res []error - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/example/restapi/operations/store/inventory_get_responses.go b/example/restapi/operations/store/inventory_get_responses.go index b41570b..9abf6ad 100644 --- a/example/restapi/operations/store/inventory_get_responses.go +++ b/example/restapi/operations/store/inventory_get_responses.go @@ -23,7 +23,7 @@ type InventoryGetOK struct { /* In: Body */ - Payload InventoryGetOKBody `json:"body,omitempty"` + Payload map[string]int32 `json:"body,omitempty"` } // NewInventoryGetOK creates InventoryGetOK with default headers values @@ -33,13 +33,13 @@ func NewInventoryGetOK() *InventoryGetOK { } // WithPayload adds the payload to the inventory get o k response -func (o *InventoryGetOK) WithPayload(payload InventoryGetOKBody) *InventoryGetOK { +func (o *InventoryGetOK) WithPayload(payload map[string]int32) *InventoryGetOK { o.Payload = payload return o } // SetPayload sets the payload to the inventory get o k response -func (o *InventoryGetOK) SetPayload(payload InventoryGetOKBody) { +func (o *InventoryGetOK) SetPayload(payload map[string]int32) { o.Payload = payload } diff --git a/example/restapi/operations/store/order_create_parameters.go b/example/restapi/operations/store/order_create_parameters.go index 55dfd60..16762fc 100644 --- a/example/restapi/operations/store/order_create_parameters.go +++ b/example/restapi/operations/store/order_create_parameters.go @@ -58,7 +58,6 @@ func (o *OrderCreateParams) BindRequest(r *http.Request, route *middleware.Match res = append(res, errors.NewParseError("order", "body", "", err)) } } else { - // validate body object if err := body.Validate(route.Formats); err != nil { res = append(res, err) diff --git a/example/restapi/operations/store/order_delete_parameters.go b/example/restapi/operations/store/order_delete_parameters.go index 0e08ccc..2626564 100644 --- a/example/restapi/operations/store/order_delete_parameters.go +++ b/example/restapi/operations/store/order_delete_parameters.go @@ -60,6 +60,7 @@ func (o *OrderDeleteParams) BindRequest(r *http.Request, route *middleware.Match return nil } +// bindOrderID binds and validates parameter OrderID from path. func (o *OrderDeleteParams) bindOrderID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { @@ -82,6 +83,7 @@ func (o *OrderDeleteParams) bindOrderID(rawData []string, hasKey bool, formats s return nil } +// validateOrderID carries on validations for parameter OrderID func (o *OrderDeleteParams) validateOrderID(formats strfmt.Registry) error { if err := validate.MinimumInt("orderId", "path", int64(o.OrderID), 1, false); err != nil { diff --git a/example/restapi/operations/store/order_get_parameters.go b/example/restapi/operations/store/order_get_parameters.go index 42a3f21..903e1c7 100644 --- a/example/restapi/operations/store/order_get_parameters.go +++ b/example/restapi/operations/store/order_get_parameters.go @@ -61,6 +61,7 @@ func (o *OrderGetParams) BindRequest(r *http.Request, route *middleware.MatchedR return nil } +// bindOrderID binds and validates parameter OrderID from path. func (o *OrderGetParams) bindOrderID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { @@ -83,6 +84,7 @@ func (o *OrderGetParams) bindOrderID(rawData []string, hasKey bool, formats strf return nil } +// validateOrderID carries on validations for parameter OrderID func (o *OrderGetParams) validateOrderID(formats strfmt.Registry) error { if err := validate.MinimumInt("orderId", "path", int64(o.OrderID), 1, false); err != nil {