Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Update README, add JSON Swagger def tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kleijnweb committed Mar 12, 2016
1 parent 4f30142 commit 3869b6f
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Invert your workflow (contract first) using Swagger ([Open API](https://openapis
Aimed to be lightweight, this bundle does not depend on FOSRestBundle or Twig.

## Important Notes
* SwaggerBundle only supports json in- and output, and only YAML Swagger definitions
* SwaggerBundle only supports json in- and output
* This bundle is currently actively maintained.
* Go to the [release page](https://github.com/kleijnweb/swagger-bundle/releases) to find details about the latest release.

Expand All @@ -18,6 +18,7 @@ A minimal example is also [available](https://github.com/kleijnweb/symfony-swagg

## This bundle will..

* Handle both JSON and YAML swagger specs transparently.
* Configure routing based on your Swagger documents(s), accounting for things like type, enums and pattern matches.
* Validate body and parameters based on your Swagger documents(s).
* Coerce query and path parameters to their defined types when possible.
Expand All @@ -31,7 +32,6 @@ A minimal example is also [available](https://github.com/kleijnweb/symfony-swagg
* Handle Form posts.
* Generate your API documentation. Use your Swagger documents, plenty of options.
* Mix well with GUI bundles. The bundle is biased towards lightweight API-only apps.
* Work with JSON Swagger documents.
* Do content negotiation or support XML.

# Usage
Expand Down
35 changes: 35 additions & 0 deletions src/Tests/Functional/JsonDataApiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
* This file is part of the KleijnWeb\SwaggerBundle package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace KleijnWeb\SwaggerBundle\Tests\Functional;

use KleijnWeb\SwaggerBundle\Test\ApiTestCase;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

/**
* @author John Kleijn <john@kleijnweb.nl>
*/
class JsonDataApiTest extends WebTestCase
{
use ApiTestCase;

/**
* Use config_basic.yml
*
* @var bool
*/
protected $env = 'basic';

/**
* @test
*/
public function canInitSchemaManager()
{
static::initSchemaManager(__DIR__ . '/PetStore/app/swagger/data.json');
}
}
166 changes: 166 additions & 0 deletions src/Tests/Functional/PetStore/app/swagger/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"swagger": "2.0",
"info": {
"description": "Data api",
"version": "1.0.0"
},
"basePath": "/data/v1",
"paths": {
"/entity/{type}": {
"get": {
"operationId": "find",
"parameters": [
{
"in": "query",
"name": "lastModified",
"required": true,
"type": "string",
"format": "date-time"
}
],
"responses": {
"200": {
"description": "Found resources",
"schema": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
},
"post": {
"parameters": [
{
"in": "body",
"name": "data",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "The created resource",
"schema": {
"type": "object"
}
}
}
}
},
"/entity/{type}/findByCriteria": {
"post": {
"operationId": "findByCriteria",
"parameters": [
{
"in": "body",
"name": "criteria",
"required": true,
"schema": {
"$ref": "#/definitions/Criteria"
}
}
],
"responses": {
"200": {
"description": "Found resources",
"schema": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
}
},
"/entity/{type}/{id}": {
"put": {
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"type": "integer"
},
{
"in": "body",
"name": "data",
"required": true,
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "The modified resource",
"schema": {
"type": "object"
}
}
}
},
"delete": {
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"type": "integer"
}
],
"responses": {
"204": {
"description": "Empty response",
"schema": {
"type": null
}
}
}
},
"get": {
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "The requested resource",
"schema": {
"type": "object"
}
}
}
}
}
},
"definitions": {
"Criteria": {
"type": "array",
"items": {
"$ref": "#/definitions/FieldCriteria"
}
},
"FieldCriteria": {
"properties": {
"fieldName": {
"type": "string"
},
"operator": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
}
}

0 comments on commit 3869b6f

Please sign in to comment.