The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Create a Node.js function for an HTTP PUT request for a Swagger API

Create a Node.js function for an HTTP PUT request for a Swagger API

2:52
This lesson will teach you how to update a Todo item in Elasticsearch when received from an HTTP PUT method in your API server built with Swagger.
Watch this lesson now
Avatar
egghead.io

This lesson will teach you how to update a Todo item in Elasticsearch when received from an HTTP PUT method in your API server built with Swagger.

Avatar
Victor Alfonso Hazbun Anuff

I got this when trying to do a PUT request to the API, I already installed and setup cors. Can you please help me getting this working? TY.

{"message":"Response validation failed: void does not allow a value","code":"INVALID_TYPE","failedValidation":true,"path":["paths","/todo/{id}","put","responses","200"],"originalResponse":"{}"}
Avatar
Alberto

I was not able to end the response with res.end(). I got a JSON parsing error. So I sent back the response. Then I got Victor Alonso's error. I changed the swagger specs to:

responses:
         200:
           description: "Todo updated"
           schema:
              title: reset
              properties:
                message:
                  type: string
        400:
           description: "Yikes! An error!"
  x-swagger-router-controller: "UpdateTodoById"

as indicated at http://stackoverflow.com/questions/34226739/implementing-a-void-in-swagger-documentation

What exactly am I doing??? Not clear :-(

In reply to Victor Alfonso Hazbun Anuff
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?