-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kindly provide us the implementation process. #15
Comments
Hello, Your question is so broad. Could you specify a little bit more? |
I am installing this using composer after that i am hitting the url where src path is but could not able to run. cannot able to implement this. |
This library does not provide a REST Server. This component can validate if your REST application (previously created and working) is receiving and responding the values that are defined previously in your swagger JSON file. So basically you have three usages: Using it as Functional Test casesIn that case you need to have a REST Server running and need to have a PHPUnit class and create your test cases. See below an example of test case: public function testPost()
{
$request = new \ByJG\Swagger\SwaggerRequester();
$request
->withMethod('POST')
->withPath("/path/for/post/2")
->withRequestBody(['name'=>'new name', 'field' => 'value']);
$this->assertRequest($request);
} This code will try do a POST request to server is defined in the swagger.json, with path "/path/for/post/2" and with a URL-Form-Enconded parameter. If the request fail, or if the response is not as expected in the SWAGGER.JSON then a exception will be throwed and you know there are something not expected according your documentation. Using it as Unit Test casesIn that case you are just validate the request and response parameter without make a REAL Request to your rest server. You have to create a test case and pass the parameters and Assert if all results as a expected. For example: <?php
// Create the SwaggerSchema object;
$swaggerSchema = new \ByJG\Swagger\SwaggerSchema($contentsOfSwaggerJson);
// Get the definitions you want to test
$path = '/path/to/method';
$statusExpected = 200;
$method = 'POST';
$bodyRequestDef = $swaggerSchema->getRequestParameters($path, $method);
$bodyResponseDef = $swaggerSchema->getResponseParameters($path, $method, $statusExpected);
// Match the result. If failed an exception will be throwed:
$bodyRequestDef->match($requestBody);
$bodyResponseDef->match($responseBody); Using it as Runtime parameters validatorIn that case you'll put the Swagger Test in front of your request and make the validations before execute your method. This is guarantee your are receiving exactly you defined in the documentation. |
This component is totally based on your swagger.json file. In your case you are reading the JSON file at line 252. Your "path" has 2 errors:
Both (host and parameters) and the path also are provided by the swagger.json. I create a swagger.json that fit in your example: {
"swagger": "2.0",
"host": "122.176.28.104",
"schemes": [
"http"
],
"paths": {
"/skylineuniversity/local/lingk/mvcswagger/getuser.php": {
"get": {
"parameters": [
{
"in": "query",
"name": "wstoken",
"description": "The authentication token",
"required": true
}
],
"responses": {
"200": {
"description": "Everything is OK"
}
}
}
}
}
} And change the line 254 to: $path = "/skylineuniversity/local/lingk/mvcswagger/getuser.php" And provide the follow value for the $requestBody variable before the line 264: $requestBody = [
"wstoken" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
]; Some notes
|
Sorry, please remove the $requestBody parameter by putting Until this moment the class is not validating parameters in the "QUERY". Only in the PATH or BODY. |
As I said before, instead to purely remove the $requestBody parameter you have to empty it, doing this: $requestBody = [] |
May I close this issue? |
Could not able to implement this in php. Kindly provide us the implementation process.
The text was updated successfully, but these errors were encountered: