Make "mappings" a required property

This was an oversight. Without this, it would be legal to have a
response of {}.
pull/10616/head
Tim Raymond 2016-10-12 15:24:37 -04:00
parent 4831ae4d29
commit 9ffb6c4489
2 changed files with 9 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/go-openapi/swag"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*Mappings mappings
@ -17,8 +18,10 @@ swagger:model Mappings
type Mappings struct {
/* mappings
*/
Mappings []*Mapping `json:"mappings,omitempty"`
Required: true
*/
Mappings []*Mapping `json:"mappings"`
}
// Validate validates this mappings
@ -38,8 +41,8 @@ func (m *Mappings) Validate(formats strfmt.Registry) error {
func (m *Mappings) validateMappings(formats strfmt.Registry) error {
if swag.IsZero(m.Mappings) { // not required
return nil
if err := validate.Required("mappings", "body", m.Mappings); err != nil {
return err
}
for i := 0; i < len(m.Mappings); i++ {

View File

@ -1299,6 +1299,8 @@ definitions:
$ref: "#/definitions/Link"
Mappings:
type: object
required:
- mappings
properties:
mappings:
type: array