upvotes
This commit is contained in:
@@ -32,6 +32,11 @@ type UpvoteFeedbackParams struct {
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: query
|
||||
*/
|
||||
Action string
|
||||
/*Feedback UUID
|
||||
Required: true
|
||||
In: path
|
||||
@@ -55,6 +60,11 @@ func (o *UpvoteFeedbackParams) BindRequest(r *http.Request, route *middleware.Ma
|
||||
|
||||
qs := runtime.Values(r.URL.Query())
|
||||
|
||||
qAction, qhkAction, _ := qs.GetOK("action")
|
||||
if err := o.bindAction(qAction, qhkAction, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rFeedbackUUID, rhkFeedbackUUID, _ := route.Params.GetOK("feedback_uuid")
|
||||
if err := o.bindFeedbackUUID(rFeedbackUUID, rhkFeedbackUUID, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
@@ -70,6 +80,41 @@ func (o *UpvoteFeedbackParams) BindRequest(r *http.Request, route *middleware.Ma
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindAction binds and validates parameter Action from query.
|
||||
func (o *UpvoteFeedbackParams) bindAction(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
if !hasKey {
|
||||
return errors.Required("action", "query", rawData)
|
||||
}
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// AllowEmptyValue: false
|
||||
|
||||
if err := validate.RequiredString("action", "query", raw); err != nil {
|
||||
return err
|
||||
}
|
||||
o.Action = raw
|
||||
|
||||
if err := o.validateAction(formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateAction carries on validations for parameter Action
|
||||
func (o *UpvoteFeedbackParams) validateAction(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.EnumCase("action", "query", o.Action, []interface{}{"upvote", "downvote"}, true); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindFeedbackUUID binds and validates parameter FeedbackUUID from path.
|
||||
func (o *UpvoteFeedbackParams) bindFeedbackUUID(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
|
||||
Reference in New Issue
Block a user