php - 我可以在非 Nodejs 应用程序中使用 swagger 测试模板吗?

标签 php swagger web-api-testing

我正在为 php 应用程序构建一个 api 测试套件。现在该应用程序正在使用 swagger 注释,我可以轻松创建 swagger.json。但从the swagger test template来看,看来我必须首先使用 swagger 节点创建一个 Nodejs 应用程序?有没有办法可以跳过该步骤并使用我的 php 应用程序?

编辑:我已经使用 swagger-php 启动并运行了 swagger 文档。只是想知道是否可以使用 swagger-test-template 而不使用 swagger-node。

最佳答案

我是 swagger-test-templates 的贡献者之一。 (我之前没有回答过任何问题,所以请耐心等待)

我是通过最近有人打开的一个 Github 问题来解决这个问题的!我在那里回答了它,但我将在这里复制它并进一步扩展它。我希望它有帮助。如果我没有完全回答您的问题,请跟进。

Simple answer: No, it is not exclusively for Node.js APIs or swagger-node.

Longer answer: You can use STT like any other Node.js module in a Node.js project, completely on its own. See the Readme or the test files for an example of how to run it standalone. Furthermore, the API doesn't have to be implemented in Node.js for a STT generated test to target it with an HTTP request. You have to use Node.js to utilize this module's functionality, but as long as you point the tests at a running server (localhost:1337, my.api.test.net) the backend implementation doesn't matter. The caveat here is that this module was designed to run with mocha which is a Node.js test runner/framework. So the tests have to be in a Node.js project, but the server implementation doesn't.

关于php - 我可以在非 Nodejs 应用程序中使用 swagger 测试模板吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35657134/

相关文章:

php - 使用 mysql 和 mysqli

php - 将数组项合并到字符串中

Swagger UI 不在 POST 中显示图像/png 内容

python - 将输入从变量传递到 URL 路径参数 - Python

php - 插入后创建触发器Mysql问题

java - Swagger 的 Spring MVC 项目

java - 如何在从 Java 代码生成的 Swagger 规范中创建可重用的枚举?

cucumber - 如何从 Excel 电子表格读取输入数据并在 Karate 框架中传递 JSON 负载?

python - 最佳实践 : automated web API testing

PHP 命名空间和单例问题