有哪些方法可以自动测试 Swagger 端点?
What are some ways to automatically test Swagger endpoints?
构建 C# .NET Core API,我想在构建过程中自动测试 Swagger 生成的文档中的端点。
是否有一些预构建的软件包或工具可以用来轻松地完成此操作?
No more outdated API documentation.
这是Dredd的承诺。所以应该可以帮助你
automatically test the endpoints in the documentation that is generated by Swagger as part of my build
我在一个项目中使用过它,它会读取描述并逐步验证您的 API 实施是否按照描述的那样使用响应进行回复。不过有一个问题。它无法扩展以达到真正的测试框架,该框架可以帮助您涵盖通过后端的复杂(链式)用户旅程。如果你走这条路,它会带来巨大的开销。但是,如果您需要简单的文档验证 - 它工作得很好。它很容易成为您的第一道防线,CICD 管道的阶段。
Postman 具有 beta API 功能,可以导入 OAS 文档(有一些限制),然后根据规范生成集合。然后您可以很容易地添加测试和 运行 它们。 https://learning.getpostman.com/docs/postman/design_and_develop_apis/the_api_workflow/
我认为我们需要的是指定测试断言的 OAS3 扩展。然后 Postman 或其他人可以直接从规范生成自动化测试。
还有 Schemathesis, which utilizes property-based testing and generates and runs tests for Open API 2/3 schemas. It requires no configuration by default and works as a CLI tool. It also verifies all examples specified in the schema, which overlaps with some Dredd 功能 - 但您不必指定所有示例;该工具将生成缺少的所有内容。
构建 C# .NET Core API,我想在构建过程中自动测试 Swagger 生成的文档中的端点。
是否有一些预构建的软件包或工具可以用来轻松地完成此操作?
No more outdated API documentation.
这是Dredd的承诺。所以应该可以帮助你
automatically test the endpoints in the documentation that is generated by Swagger as part of my build
我在一个项目中使用过它,它会读取描述并逐步验证您的 API 实施是否按照描述的那样使用响应进行回复。不过有一个问题。它无法扩展以达到真正的测试框架,该框架可以帮助您涵盖通过后端的复杂(链式)用户旅程。如果你走这条路,它会带来巨大的开销。但是,如果您需要简单的文档验证 - 它工作得很好。它很容易成为您的第一道防线,CICD 管道的阶段。
Postman 具有 beta API 功能,可以导入 OAS 文档(有一些限制),然后根据规范生成集合。然后您可以很容易地添加测试和 运行 它们。 https://learning.getpostman.com/docs/postman/design_and_develop_apis/the_api_workflow/
我认为我们需要的是指定测试断言的 OAS3 扩展。然后 Postman 或其他人可以直接从规范生成自动化测试。
还有 Schemathesis, which utilizes property-based testing and generates and runs tests for Open API 2/3 schemas. It requires no configuration by default and works as a CLI tool. It also verifies all examples specified in the schema, which overlaps with some Dredd 功能 - 但您不必指定所有示例;该工具将生成缺少的所有内容。