8000 Multiple validation errors results in only one validation being shown in response · Issue #667 · go-swagger/go-swagger · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Multiple validation errors results in only one validation being shown in response #667
Closed
@ryanwalls

Description

@ryanwalls

Problem statement

Multiple validation errors are not being return in the json response.

Swagger specification


---
swagger: '2.0'

info:
  version: "0.1.0"
  title: Worlflow Signaler API

paths:
  /capacity-change-events:
    post:
      description: Inform the signaler that resource capacity has changed
      parameters:
        - name: event
          in: body
          schema:
            $ref: '#/definitions/CapacityChangeEvent'
          required: true
      responses:
        200:
          description: Successful response
  /resource-change-events:
    post:
      description: Inform the signaler that resource capacity has changed
      parameters:
        - name: event
          in: body
          schema:
            $ref: '#/definitions/ResourceChangeEvent'
          required: true
      responses:
        200:
          description: Successful response

produces:
- application/json

consumes:
- application/json

definitions:
  CapacityChangeEvent:
    type: object
    properties:
      customerID:
        type: integer
        description: ID of customer affected
      capacityChange:
        type: integer
        description: the amount of capacity change
    required:
    - customerID
    - capacityChange
  ResourceChangeEvent:
    type: object
    properties:
      cluster:
        type: string
        description: Cluster name that has new resource
      resourceChange:
        type: integer
        description: the number of servers that have changed
    required:
    - cluster
    - resourceChange

Steps to reproduce

Create an endpoint that accepts a POST
Create a model for the body of the POST with two required fields.
Send a post to that endpoint with no body.

Result

{
  "code": 602,
  "message": "cluster in body is required"
}

Expected it to return a "validation failure list" message from a CompositeValidationError https://github.com/go-openapi/errors/blob/master/schema.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmodelRelated to swagger generate model commandvalidatorRelated to codegen generation of validations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0