fly2never
V2EX  ›  问与答

Swagger 怎么做 Reponse 的 validate?

  •  
  •   fly2never · Jul 19, 2017 · 2627 views
    This topic created in 3234 days ago, the information mentioned may be changed or developed.

    我们用 Swagger 做 API 规范, 在 Swagger-ui 中有一个 try it out 的功能, 可以请求服务器和展示 Response.但是我没有找到任何地方可以根据 Swagger 的 API 定义去验证返回 json 的正确性.

    比如 API 定义了返回字段里面必须有 id, 而且这个字段是 integer, 结果服务器接口返回的是 string 或者压根没有这个字段, 这个时候 try it out 显示的结果应该报错, Swagger 有这个功能吗? 如果不行是不是只能用 postman 自己写测试了?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1280 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 174ms · UTC 23:40 · PVG 07:40 · LAX 16:40 · JFK 19:40
    ♥ Do have faith in what you're doing.