question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validating and documenting a 204 No Content endpoint

See original GitHub issue

Context

  • hapi-swgger version: 7.6.0
  • any other relevant information:

What are you trying to achieve or the steps to reproduce ?

I’m trying to document my delete endpoint. It returns a statusCode of 204 No Content. I’m not sure how to document this endpoint and the response. If I leave the statusCode out in the validation, it won’t show up in /documentation. If I put 204: Joi.string().length(0) it fails validation.

What is the proper way to validate and document and endpoint which returns 204 No Content?


// handler
function (req, reply) {
  // ...
  return reply().code(204);
}

// Response validation
// ...
      response: {
        status: {
          204: ?
          404: schema.responseNotFound
        }
      }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

5reactions
fvalmeidacommented, Jul 11, 2019

Could you please review this PR #601

This will allow setting a No Content endpoint by just specifying:

      response: {
        status: {
          204: undefined
        }
      }
1reaction
ebicklecommented, Jan 9, 2018

Using “204: Joi.only(null)” has started to produce invalid Swagger contracts; might have a regression somewhere.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validating and documenting a 204 No Content endpoint #392
What are you trying to achieve or the steps to reproduce ? I'm trying to document my delete endpoint. It returns a statusCode...
Read more >
HTTP Status 204 (No Content) - REST
HTTP Status 204 (No Content) indicates that the server has successfully fulfilled the request and that there is no content to send in...
Read more >
204 No Content - HTTP - MDN Web Docs - Mozilla
The HTTP 204 No Content success status response code indicates that a request has succeeded, but that the client doesn't need to navigate ......
Read more >
GA4 event Validation only returns 204 - Stack Overflow
It seems a 204 status code is to be expected from GA4, i.e. no content should be returned. From inspecting the response given...
Read more >
What is HTTP Status Code 204 (No Content)? - Abstract API
The HTTP Status Code 204 means that the server successfully processed the client's request, and that the server is not returning any content...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found