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.

Body validation does not work?

See original GitHub issue

I’m trying to get validator to work on the body of this route:

  '/filtered':
    put:
      summary: blah
      parameters:
        - in: body
          name: body
          required: true
          schema:
            type: object
            required:
              - filtered
            properties:
              filtered:
                description: status of ssid
                type: boolean

here are my request parameters: { uri: 'http://127.0.0.1/apiv2/filtered', headers: { 'x-api-key': 'blah' }, json: { test: 'test' } }

I expect openapi-express to return 400, because body should be an object with filtered prop. Yet I get 200 response. Swaggerize express worked fine with this one. Am I doing something wrong here? I’ll edit this to make it more reproducible after lunch…

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
juliuszacommented, Mar 9, 2018

Thanks, you’re awesome. Looks like I’ll be able to replace swaggerize-express lib with this one after all.

0reactions
jsdevelcommented, Mar 9, 2018

You’re welcome! Happy to have you! Don’t hesitate to report issues here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring boot @Valid on requestBody in controller method not ...
Validations are working correctly on primitive variable in request (on age in below example) but not working on pojo request body.
Read more >
Validate Request Body and Parameter in Spring Boot
In this tutorial, we will see how to use Spring features to validate the request body and request parameters.
Read more >
Validate Request Body and Parameter in Spring Boot - Medium
When Spring finds an argument annotated with @Valid, it automatically validates the argument and throws an exception if the validation fails. Run the ......
Read more >
Validation with Spring Boot - the Complete Guide - Reflectoring
Very basically, Bean Validation works by defining constraints to the fields of a class by annotating them with certain annotations. Common ...
Read more >
JSR-303 @Valid validation is not invoked for @RequestBody ...
If an argument to a Spring MVC Controller method is annotated with both the @RequestBody and @Valid annotations, the argument should be passed...
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