I'm working in building out a api test suite for a php application. Right now the app is using swagger annotation and I can easily create a swagger.json. But from looking at the swagger test template, it looks like I have to create a nodejs app first using swagger node? Is there a way I can skip that step and use my php app instead?
Edit: I already have the swagger docs up and running using swagger-php. Just wondering if it's possible to use swagger-test-template without using swagger-node.
I am one of the contributors on swagger-test-templates. (I haven't answered anything on SO before so bear with me)
I was brought to your question through a Github issue someone recently opened to address this! I answered it there, but I will copy it here and expand on it some more. I hope it helps. Please follow up if I didn't completely answer your question.
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.
I had the same question today, and found this thread which had no resolution.
So I asked the project developers and they said it can do what you want.
Simple answer: No, it is not exclusively for Node.js APIs.
Longer answer: 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 (obviously), but as long as you point
the tests at a running server (localhost:1337, my.api.test.net) the
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.
You can generate server application for different platforms not only nodejs, using their tool 'swagger-codegen' or in online editor: paste you swagger configuration and choose generate server -> Silex PHP.
The PHP API client generated by Swagger Codegen comes with test cases (template) that need to be updated with test data. You can find some examples in this folder
To run the test cases, just follow the instruction in the README.md
Definately you can do so. Go to https://github.com/swagger-api/swagger-ui
, download the zip. Zip file has a dist
folder. That is all you need for developing the swagger docs in your API server. Include this folder in your server directory along with the Php code. Inside dist
there is index.html and swagger.json. You can modify these two files to create your own docs and test your API.