Skip to content
Snippets Groups Projects
Unverified Commit ead5c151 authored by Bob Callaway's avatar Bob Callaway Committed by GitHub
Browse files

Mark request body for create entry as required (#81)


We can't insert a blank entry, so mark request body as required.

Signed-off-by: default avatarBob Callaway <bcallawa@redhat.com>
parent b4faddc4
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,7 @@ paths:
name: proposedEntry
schema:
$ref: '#/definitions/ProposedEntry'
required: true
responses:
201:
description: Returns the entry created in the transparency log
......
......@@ -115,6 +115,7 @@ func init() {
{
"name": "proposedEntry",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ProposedEntry"
}
......@@ -579,6 +580,7 @@ func init() {
{
"name": "proposedEntry",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ProposedEntry"
}
......
......@@ -24,6 +24,7 @@ package entries
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
......@@ -51,6 +52,7 @@ type CreateLogEntryParams struct {
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
ProposedEntry models.ProposedEntry
......@@ -69,6 +71,9 @@ func (o *CreateLogEntryParams) BindRequest(r *http.Request, route *middleware.Ma
defer r.Body.Close()
body, err := models.UnmarshalProposedEntry(r.Body, route.Consumer)
if err != nil {
if err == io.EOF {
err = errors.Required("proposedEntry", "body", "")
}
res = append(res, err)
} else {
// validate body object
......@@ -85,6 +90,8 @@ func (o *CreateLogEntryParams) BindRequest(r *http.Request, route *middleware.Ma
o.ProposedEntry = body
}
}
} else {
res = append(res, errors.Required("proposedEntry", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment