Skip to content

Commit f4503fa

Browse files
committed
Unit tests.
1 parent 635cb5c commit f4503fa

File tree

19 files changed

+309
-4
lines changed

19 files changed

+309
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor

Controller/StaticResourcesController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
/**
1919
* Class StaticResourcesController
2020
*
21-
* @package ActiveLAMP\Bundle\SwaggerUIBundle\Controller
2221
* @author Bez Hermoso <bez@activelamp.com>
2322
*/
2423
class StaticResourcesController extends Controller

Controller/SwaggerUIController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
66
use Symfony\Component\HttpFoundation\Request;
77

8+
/**
9+
* @author Bez Hermoso <bez@activelamp.com>
10+
*/
811
class SwaggerUIController extends Controller
912
{
1013
public function indexAction(Request $request)

DependencyInjection/ALSwaggerUIExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ActiveLAMP\Bundle\SwaggerUIBundle\DependencyInjection;
44

5+
use Symfony\Component\Config\Resource\FileResource;
56
use Symfony\Component\DependencyInjection\ContainerBuilder;
67
use Symfony\Component\Config\FileLocator;
78
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

Resources/views/SwaggerUI/index.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
docExpansion: {{ js_config.expansion|json_encode|raw }},
4646
sorter: {{ js_config.sorter|json_encode|raw }},
4747
booleanValues: {{ js_config.boolean_values|json_encode|raw }},
48-
highlightSizeThreshold: {{ json_config.highlight_size_threshold|json_encode|raw }}
48+
highlightSizeThreshold: {{ js_config.highlight_size_threshold|json_encode|raw }}
4949
});
5050
5151
/* $('#input_apiKey').change(function() {

Tests/Application/AppKernel.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
4+
namespace ActiveLAMP\Bundle\SwaggerUIBundle\Tests\Application;
5+
6+
use ActiveLAMP\Bundle\SwaggerUIBundle\ALSwaggerUIBundle;
7+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
8+
use Symfony\Bundle\TwigBundle\TwigBundle;
9+
use Symfony\Component\Config\Loader\LoaderInterface;
10+
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
11+
use Symfony\Component\HttpKernel\Kernel;
12+
13+
class AppKernel extends Kernel
14+
{
15+
/**
16+
* Returns an array of bundles to register.
17+
*
18+
* @return BundleInterface[] An array of bundle instances.
19+
*
20+
* @api
21+
*/
22+
public function registerBundles()
23+
{
24+
$bundles = array(
25+
new FrameworkBundle(),
26+
new TwigBundle(),
27+
new ALSwaggerUIBundle(),
28+
);
29+
30+
return $bundles;
31+
}
32+
33+
/**
34+
* Loads the container configuration.
35+
*
36+
* @param LoaderInterface $loader A LoaderInterface instance
37+
*
38+
* @api
39+
*/
40+
public function registerContainerConfiguration(LoaderInterface $loader)
41+
{
42+
$loader->load(__DIR__ . '/config/config_' . $this->environment . '.yml');
43+
}
44+
45+
public function getCacheDir()
46+
{
47+
return sys_get_temp_dir() . '/al_swagger_ui/' . Kernel::VERSION . '/cache/' . $this->environment;
48+
}
49+
50+
public function getLogDir()
51+
{
52+
return sys_get_temp_dir() . '/al_swagger_ui/' . Kernel::VERSION . '/logs';
53+
}
54+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"apiVersion":"1.0.0","swaggerVersion":"1.2","apis":[{"path":"/pet","description":"Operations about pets"},{"path":"/user","description":"Operations about user"},{"path":"/store","description":"Operations about store"}],"authorizations":{"oauth2":{"type":"oauth2","scopes":[{"scope":"write:pets","description":"Modify pets in your account"},{"scope":"read:pets","description":"Read your pets"}],"grantTypes":{"implicit":{"loginEndpoint":{"url":"http://petstore.swagger.wordnik.com/api/oauth/dialog"},"tokenName":"access_token"},"authorization_code":{"tokenRequestEndpoint":{"url":"http://petstore.swagger.wordnik.com/api/oauth/requestToken","clientIdName":"client_id","clientSecretName":"client_secret"},"tokenEndpoint":{"url":"http://petstore.swagger.wordnik.com/api/oauth/token","tokenName":"auth_code"}}}}},"info":{"title":"Swagger Sample App","description":"This is a sample server Petstore server. You can find out more about Swagger \n at <a href=\"http://swagger.wordnik.com\">http://swagger.wordnik.com</a> or on irc.freenode.net, #swagger. For this sample,\n you can use the api key \"special-key\" to test the authorization filters","termsOfServiceUrl":"http://helloreverb.com/terms/","contact":"apiteam@wordnik.com","license":"Apache 2.0","licenseUrl":"http://www.apache.org/licenses/LICENSE-2.0.html"}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"http://petstore.swagger.wordnik.com/api","resourcePath":"/pet","produces":["application/json","application/xml","text/plain","text/html"],"apis":[{"path":"/pet/{petId}","operations":[{"method":"GET","summary":"Find pet by ID","notes":"Returns a pet based on ID","type":"Pet","nickname":"getPetById","authorizations":[],"parameters":[{"name":"petId","description":"ID of pet that needs to be fetched","required":true,"type":"integer","format":"int64","paramType":"path","allowMultiple":false,"minimum":"1.0","maximum":"100000.0"}],"responseMessages":[{"code":400,"message":"Invalid ID supplied"},{"code":404,"message":"Pet not found"}]},{"method":"POST","summary":"Updates a pet in the store with form data","notes":"","type":"void","nickname":"updatePetWithForm","consumes":["application/x-www-form-urlencoded"],"authorizations":{"oauth2":[{"scope":"write:pets","description":"modify pets in your account"}]},"parameters":[{"name":"petId","description":"ID of pet that needs to be updated","required":true,"type":"string","paramType":"path","allowMultiple":false},{"name":"name","description":"Updated name of the pet","required":false,"type":"string","paramType":"form","allowMultiple":false},{"name":"status","description":"Updated status of the pet","required":false,"type":"string","paramType":"form","allowMultiple":false}],"responseMessages":[{"code":405,"message":"Invalid input"}]},{"method":"DELETE","summary":"Deletes a pet","notes":"","type":"void","nickname":"deletePet","authorizations":{"oauth2":[{"scope":"write:pets","description":"modify pets in your account"}]},"parameters":[{"name":"petId","description":"Pet id to delete","required":true,"type":"string","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid pet value"}]},{"method":"PATCH","summary":"partial updates to a pet","notes":"","type":"array","items":{"$ref":"Pet"},"nickname":"partialUpdate","produces":["application/json","application/xml"],"consumes":["application/json","application/xml"],"authorizations":{"oauth2":[{"scope":"write:pets","description":"modify pets in your account"}]},"parameters":[{"name":"petId","description":"ID of pet that needs to be fetched","required":true,"type":"string","paramType":"path","allowMultiple":false},{"name":"body","description":"Pet object that needs to be added to the store","required":true,"type":"Pet","paramType":"body","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid tag value"}]}]},{"path":"/pet","operations":[{"method":"POST","summary":"Add a new pet to the store","notes":"","type":"void","nickname":"addPet","consumes":["application/json","application/xml"],"authorizations":{"oauth2":[{"scope":"write:pets","description":"modify pets in your account"}]},"parameters":[{"name":"body","description":"Pet object that needs to be added to the store","required":true,"type":"Pet","paramType":"body","allowMultiple":false}],"responseMessages":[{"code":405,"message":"Invalid input"}]},{"method":"PUT","summary":"Update an existing pet","notes":"","type":"void","nickname":"updatePet","authorizations":[],"parameters":[{"name":"body","description":"Pet object that needs to be updated in the store","required":true,"type":"Pet","paramType":"body","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid ID supplied"},{"code":404,"message":"Pet not found"},{"code":405,"message":"Validation exception"}]}]},{"path":"/pet/findByStatus","operations":[{"method":"GET","summary":"Finds Pets by status","notes":"Multiple status values can be provided with comma seperated strings","type":"array","items":{"$ref":"Pet"},"nickname":"findPetsByStatus","authorizations":[],"parameters":[{"name":"status","description":"Status values that need to be considered for filter","defaultValue":"available","required":true,"type":"string","paramType":"query","allowMultiple":true,"enum":["available","pending","sold"]}],"responseMessages":[{"code":400,"message":"Invalid status value"}]}]},{"path":"/pet/findByTags","operations":[{"method":"GET","summary":"Finds Pets by tags","notes":"Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.","type":"array","items":{"$ref":"Pet"},"nickname":"findPetsByTags","authorizations":[],"parameters":[{"name":"tags","description":"Tags to filter by","required":true,"type":"string","paramType":"query","allowMultiple":true}],"responseMessages":[{"code":400,"message":"Invalid tag value"}],"deprecated":"true"}]},{"path":"/pet/uploadImage","operations":[{"method":"POST","summary":"uploads an image","notes":"","type":"void","nickname":"uploadFile","consumes":["multipart/form-data"],"authorizations":{"oauth2":[{"scope":"write:pets","description":"modify pets in your account"},{"scope":"read:pets","description":"read your pets"}]},"parameters":[{"name":"additionalMetadata","description":"Additional data to pass to server","required":false,"type":"string","paramType":"form","allowMultiple":false},{"name":"file","description":"file to upload","required":false,"type":"File","paramType":"form","allowMultiple":false}]}]}],"models":{"Tag":{"id":"Tag","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}}},"Pet":{"id":"Pet","required":["id","name"],"properties":{"id":{"type":"integer","format":"int64","description":"unique identifier for the pet","minimum":"0.0","maximum":"100.0"},"category":{"$ref":"Category"},"name":{"type":"string"},"photoUrls":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"$ref":"Tag"}},"status":{"type":"string","description":"pet status in the store","enum":["available","pending","sold"]}}},"Category":{"id":"Category","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}}}}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"http://petstore.swagger.wordnik.com/api","resourcePath":"/store","produces":["application/json"],"apis":[{"path":"/store/order","operations":[{"method":"POST","summary":"Place an order for a pet","notes":"","type":"void","nickname":"placeOrder","authorizations":{"oauth2":[{"scope":"write:pets","description":"write to your pets"}]},"parameters":[{"name":"body","description":"order placed for purchasing the pet","required":true,"type":"Order","paramType":"body","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid order"}]}]},{"path":"/store/order/{orderId}","operations":[{"method":"DELETE","summary":"Delete purchase order by ID","notes":"For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors","type":"void","nickname":"deleteOrder","authorizations":{"oauth2":[{"scope":"write:pets","description":"write to your pets"}]},"parameters":[{"name":"orderId","description":"ID of the order that needs to be deleted","required":true,"type":"string","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid ID supplied"},{"code":404,"message":"Order not found"}]},{"method":"GET","summary":"Find purchase order by ID","notes":"For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors","type":"Order","nickname":"getOrderById","authorizations":[],"parameters":[{"name":"orderId","description":"ID of pet that needs to be fetched","required":true,"type":"string","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid ID supplied"},{"code":404,"message":"Order not found"}]}]}],"models":{"Order":{"id":"Order","properties":{"id":{"type":"integer","format":"int64"},"petId":{"type":"integer","format":"int64"},"quantity":{"type":"integer","format":"int32"},"status":{"type":"string","description":"Order Status","enum":["placed"," approved"," delivered"]},"shipDate":{"type":"string","format":"date-time"}}}}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"http://petstore.swagger.wordnik.com/api","resourcePath":"/user","produces":["application/json"],"apis":[{"path":"/user/{username}","operations":[{"method":"PUT","summary":"Updated user","notes":"This can only be done by the logged in user.","type":"void","nickname":"updateUser","authorizations":{"oauth2":[{"scope":"test:anything","description":"anything"}]},"parameters":[{"name":"username","description":"name that need to be deleted","required":true,"type":"string","paramType":"path","allowMultiple":false},{"name":"body","description":"Updated user object","required":true,"type":"User","paramType":"body","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid username supplied"},{"code":404,"message":"User not found"}]},{"method":"DELETE","summary":"Delete user","notes":"This can only be done by the logged in user.","type":"void","nickname":"deleteUser","authorizations":{"oauth2":[{"scope":"test:anything","description":"anything"}]},"parameters":[{"name":"username","description":"The name that needs to be deleted","required":true,"type":"string","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid username supplied"},{"code":404,"message":"User not found"}]},{"method":"GET","summary":"Get user by user name","notes":"","type":"User","nickname":"getUserByName","authorizations":[],"parameters":[{"name":"username","description":"The name that needs to be fetched. Use user1 for testing.","required":true,"type":"string","paramType":"path","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid username supplied"},{"code":404,"message":"User not found"}]}]},{"path":"/user/login","operations":[{"method":"GET","summary":"Logs user into the system","notes":"","type":"string","nickname":"loginUser","authorizations":[],"parameters":[{"name":"username","description":"The user name for login","required":true,"type":"string","paramType":"query","allowMultiple":false},{"name":"password","description":"The password for login in clear text","required":true,"type":"string","paramType":"query","allowMultiple":false}],"responseMessages":[{"code":400,"message":"Invalid username and password combination"}]}]},{"path":"/user/logout","operations":[{"method":"GET","summary":"Logs out current logged in user session","notes":"","type":"void","nickname":"logoutUser","authorizations":[],"parameters":[]}]},{"path":"/user/createWithArray","operations":[{"method":"POST","summary":"Creates list of users with given input array","notes":"","type":"void","nickname":"createUsersWithArrayInput","authorizations":{"oauth2":[{"scope":"test:anything","description":"anything"}]},"parameters":[{"name":"body","description":"List of user object","required":true,"type":"array","items":{"$ref":"User"},"paramType":"body","allowMultiple":false}]}]},{"path":"/user/createWithList","operations":[{"method":"POST","summary":"Creates list of users with given list input","notes":"","type":"void","nickname":"createUsersWithListInput","authorizations":{"oauth2":[{"scope":"test:anything","description":"anything"}]},"parameters":[{"name":"body","description":"List of user object","required":true,"type":"array","items":{"$ref":"User"},"paramType":"body","allowMultiple":false}]}]},{"path":"/user","operations":[{"method":"POST","summary":"Create user","notes":"This can only be done by the logged in user.","type":"void","nickname":"createUser","authorizations":{"oauth2":[{"scope":"test:anything","description":"anything"}]},"parameters":[{"name":"body","description":"Created user object","required":true,"type":"User","paramType":"body","allowMultiple":false}]}]}],"models":{"User":{"id":"User","properties":{"id":{"type":"integer","format":"int64"},"firstName":{"type":"string"},"username":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"password":{"type":"string"},"phone":{"type":"string"},"userStatus":{"type":"integer","format":"int32","description":"User Status","enum":["1-registered","2-active","3-closed"]}}}}}

0 commit comments

Comments
 (0)