mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-10 09:12:51 +01:00
Release catalyst
This commit is contained in:
116
generated/restapi/operations/tickets/add_comment_parameters.go
Normal file
116
generated/restapi/operations/tickets/add_comment_parameters.go
Normal file
@@ -0,0 +1,116 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// AddCommentEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func AddCommentEndpoint(handler func(ctx context.Context, params *AddCommentParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewAddCommentParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewAddCommentParams creates a new AddCommentParams object
|
||||
// with the default values initialized.
|
||||
func NewAddCommentParams() *AddCommentParams {
|
||||
var ()
|
||||
return &AddCommentParams{}
|
||||
}
|
||||
|
||||
// AddCommentParams contains all the bound params for the add comment operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters addComment
|
||||
type AddCommentParams struct {
|
||||
|
||||
/*Ticket comment
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Comment *models.CommentForm
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *AddCommentParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.CommentForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("comment", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("comment", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Comment = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("comment", "body", ""))
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *AddCommentParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user