当前位置:   article > 正文

java json校验框架,根据Java中的Swagger定义验证JSON消息

swagger规范验证

I created a REST API using a Swagger definition, now I need to validate incoming messages using that swagger schema. I found several solutions however all of them rely on some specific use case. The closest to what I need is this and true to it's description it works well with provided json schema, however when I deliver much more complex swagger definition, it just marks everything as valid. My question is. Is there any better, more complete or competent solution, library perhaps, that would natively validate given JSON messages against Swagger definition? I need this because I'm implementing WSO2 API REST solution and this would greatly help.

解决方案

There is the swagger-request-validator having several adapters for various frameworks, e.g.: Spring Web MVC

It is capable of validating requests and / or responses against Swagger / OpenAPI 2 or OpenAPI 3 schemes.

It doesn't simply validate the defined JSON body. It validates the rest of the request, too, like path (variables), headers, etc.

The validator is capable of i18n.

Up until now the most complete validation against Swagger and OpenAPI in Java.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/58784
推荐阅读
相关标签
  

闽ICP备14008679号