Swagger: Schema Error on PUT

10 views
Skip to first unread message

Jonathan Eustace

unread,
Sep 22, 2016, 9:41:00 PM9/22/16
to Swagger
 keep getting a failed schema validation error on a successful response using swagger. However, I'm pretty sure my syntax is correct. Any ideas on what is going wrong here?

My controller

function putAReview(req, res){
      fakeDB.addReview(req.body.reviewObject.id, req.body.reviewObject.reviewInteger)
      .then( res => {
        res.json({result: {result: res}}); //Outputs : { result: { result: 'success' } }

      })
      .catch( err =>{
        res.status(500).json({error: {error: err}});
      });
    }

My route (YAML)

/review:
    x-swagger-router-controller: wine
    put:
      operationId: putAReview
      description: Review a wine based on ID
      parameters:
        - name: reviewObject
          description: The ID and review integer of the wine to review
          in: body
          required: true
          schema:
            $ref: "#/definitions/ReviewWineByID"
      # define the type of response for Success "200" and Error
      responses:
        "200":
          description: Success
          schema:
            $ref: "#/definitions/ReviewWineByIDResponse"
        default:
          description: Error
          schema:
            $ref: "#/definitions/ReviewWineByIDErrorResponse"

My schema

 ReviewWineByIDResponse:
    required:
    - result
    properties:
      result:
        type: object
        properties:
            result:
              type: string
Reply all
Reply to author
Forward
0 new messages