Skip to content

Commit 150bbaf

Browse files
authored
v0.1.0
2 parents 0ad48d2 + 6a03ca6 commit 150bbaf

File tree

62 files changed

+2698
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2698
-86
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ vendor
22
build
33
#A library must not provide a composer.lock file
44
composer.lock
5+
6+
features/demo_app/var/

.scrutinizer.yml

+2-8
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,14 @@ build:
1515
tests:
1616
stop_on_failure: true
1717
override:
18-
- php-scrutinizer-run --enable-security-analysis
19-
-
20-
command: make codestyle
21-
analysis:
22-
file: 'build/reports/cs-data'
23-
format: 'php-cs-checkstyle'
2418
-
2519
command: make coverage
2620
idle_timeout: 1200
2721
coverage:
2822
file: 'build/coverage/clover.xml'
2923
format: 'php-clover'
24+
- php-scrutinizer-run --enable-security-analysis
25+
- make codestyle
3026
cache:
3127
directories:
3228
- ~/.composer
@@ -39,8 +35,6 @@ build:
3935
COMPOSER_OPTIONS: '--optimize-autoloader'
4036
COVERAGE_OUTPUT_STYLE: 'clover'
4137
COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml'
42-
PHPCS_REPORT_STYLE: 'checkstyle'
43-
PHPCS_REPORT_FILE: 'build/reports/cs-data'
4438
php:
4539
version: "7.1"
4640
timezone: UTC

.travis.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
language: php
22

33
php:
4-
- '7.0'
54
- '7.1'
65
- '7.2'
6+
- '7.3'
77

88
env:
99
global:
1010
CI: 'true'
1111
TEST_OUTPUT_STYLE: 'pretty'
1212
PHPCS_REPORT_STYLE: 'full'
1313
COMPOSER_OPTIONS: '--optimize-autoloader'
14+
matrix:
15+
- SYMFONY_VERSION: '~3.0'
16+
- SYMFONY_VERSION: '~4.0'
1417

1518
sudo: false
1619

@@ -19,9 +22,10 @@ matrix:
1922

2023
before_install:
2124
# remove xdebug to speed up build
22-
- phpenv config-rm xdebug.ini
25+
- phpenv config-rm xdebug.ini || true
2326

2427
install:
28+
- composer require symfony/http-kernel:$SYMFONY_VERSION symfony/config:$SYMFONY_VERSION symfony/dependency-injection:$SYMFONY_VERSION
2529
- make build
2630
script:
2731
- make test-technical
@@ -31,3 +35,7 @@ cache:
3135
directories:
3236
- $HOME/.composer
3337
- vendor
38+
39+
branches:
40+
except:
41+
- /.*\-dev$/

Makefile

+16-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ COVERAGE_OUTPUT_STYLE ?= html
66
BUILD_DIRECTORY ?= build
77
REPORTS_DIRECTORY ?= ${BUILD_DIRECTORY}/reports
88
COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/coverage
9+
BEHAT_COVERAGE_DIRECTORY ?= ${BUILD_DIRECTORY}/behat-coverage
910
COVERAGE_CLOVER_FILE_PATH ?= ${COVERAGE_DIRECTORY}/clover.xml
1011

1112
## Commands options
1213
### Composer
1314
#COMPOSER_OPTIONS=
1415
### Phpcs
1516
PHPCS_REPORT_STYLE ?= full
17+
PHPCS_DISABLE_WARNING ?= "false"
1618
#PHPCS_REPORT_FILE=
1719
#PHPCS_REPORT_FILE_OPTION=
1820

@@ -51,6 +53,12 @@ ifneq ("${PHPCS_REPORT_FILE}","")
5153
PHPCS_REPORT_FILE_OPTION ?= --report-file=${PHPCS_REPORT_FILE}
5254
endif
5355

56+
ifneq ("${PHPCS_DISABLE_WARNING}","true")
57+
PHPCS_DISABLE_WARNING_OPTION=
58+
else
59+
PHPCS_DISABLE_WARNING_OPTION=-n
60+
endif
61+
5462

5563
## Project build (install and configure)
5664
build: install configure
@@ -76,20 +84,26 @@ test-functional:
7684
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets
7785

7886
codestyle: create-reports-directory
79-
./vendor/bin/phpcs --standard=phpcs.xml.dist ${PHPCS_COLOR_OPTION} ${PHPCS_REPORT_FILE_OPTION} --report=${PHPCS_REPORT_STYLE}
87+
./vendor/bin/phpcs ${PHPCS_DISABLE_WARNING_OPTION} --standard=phpcs.xml.dist ${PHPCS_COLOR_OPTION} ${PHPCS_REPORT_FILE_OPTION} --report=${PHPCS_REPORT_STYLE}
8088

8189
coverage: create-coverage-directory
8290
./vendor/bin/phpunit ${PHPUNIT_COLOR_OPTION} ${PHPUNIT_OUTPUT_STYLE_OPTION} ${PHPUNIT_COVERAGE_OPTION}
8391

92+
behat-coverage: create-behat-coverage-directory
93+
composer required leanphp/behat-code-coverage
94+
./vendor/bin/behat ${BEHAT_COLOR_OPTION} ${BEHAT_OUTPUT_STYLE_OPTION} --no-snippets --profile coverage
8495

8596

8697
# Internal commands
8798
create-coverage-directory:
8899
mkdir -p ${COVERAGE_DIRECTORY}
89100

101+
create-behat-coverage-directory:
102+
mkdir -p ${BEHAT_COVERAGE_DIRECTORY}
103+
90104
create-reports-directory:
91105
mkdir -p ${REPORTS_DIRECTORY}
92106

93107

94-
.PHONY: build install configure test test-technical test-functional codestyle coverage create-coverage-directory create-reports-directory
108+
.PHONY: build install configure test test-technical test-functional codestyle coverage behat-coverage create-coverage-directory create-behat-coverage-directory create-reports-directory
95109
.DEFAULT: build

README.md

+61-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,73 @@
1-
# JSON-RPC server documentation
2-
[![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server-doc) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server-doc) [![PHP Versions](https://img.shields.io/badge/php-7.0%20%2F%207.1%20%2F%207.2-8892BF.svg)](https://php.net/)
1+
# Symfony JSON-RPC server documentation
2+
[![License](https://img.shields.io/github/license/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server-doc) [![Code size](https://img.shields.io/github/languages/code-size/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://github.com/yoanm/symfony-jsonrpc-http-server-doc) [![Dependencies](https://img.shields.io/librariesio/github/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://libraries.io/packagist/yoanm%2Fsymfony-jsonrpc-http-server-doc)
33

4-
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/?branch=master) [![Build Status](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/badges/build.png?b=master)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/build-status/master) [![Code Coverage](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/?branch=master)
4+
[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-http-server-doc.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/build-status/master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/symfony-jsonrpc-http-server-doc/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/symfony-jsonrpc-http-server-doc/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/?branch=master)
55

6-
[![Travis Build Status](https://img.shields.io/travis/yoanm/symfony-jsonrpc-http-server-doc/master.svg?label=travis)](https://travis-ci.org/yoanm/symfony-jsonrpc-http-server-doc) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://travis-ci.org/yoanm/symfony-jsonrpc-http-server-doc)
6+
[![Travis Build Status](https://img.shields.io/travis/com/yoanm/symfony-jsonrpc-http-server-doc/master.svg?label=Travis&logo=travis)](https://travis-ci.com/yoanm/symfony-jsonrpc-http-server-doc) [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/symfony-jsonrpc-http-server-doc.svg?logo=travis)](https://php.net/) [![Travis Symfony Versions](https://img.shields.io/badge/Symfony-v3%20%2F%20v4-8892BF.svg?logo=travis)](https://symfony.com/)
77

88
[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server-doc) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server-doc)
99

1010
Symfony bundle for easy JSON-RPC server documentation
1111

12+
Symfony bundle for [`yoanm/jsonrpc-server-doc-sdk`](https://raw.githubusercontent.com/yoanm/php-jsonrpc-server-doc-sdk)
13+
14+
See [yoanm/symfony-jsonrpc-params-sf-constraints-doc](https://github.com/yoanm/symfony-jsonrpc-params-sf-constraints-doc) for params documentation generation.
15+
16+
## Availble formats
17+
18+
- Raw : Built-in `json` format at `/doc` or `/doc/raw.json`
19+
- Swagger : [yoanm/symfony-jsonrpc-http-server-swagger-doc](https://github.com/yoanm/symfony-jsonrpc-http-server-swagger-doc)
20+
- OpenApi : [yoanm/symfony-jsonrpc-http-server-openapi-doc](https://github.com/yoanm/symfony-jsonrpc-http-server-openapi-doc)
21+
1222
## How to use
1323

14-
 
24+
Once configured, your project is ready to handle HTTP `GET` request on `/doc/{?filename}` endpoint.
25+
26+
See below how to configure it.
27+
28+
## Configuration
29+
30+
*[Behat demo app configuration folders](./features/demo_app/) can be used as examples.*
31+
32+
- Add the bundles in your `config/bundles.php` file:
33+
```php
34+
// config/bundles.php
35+
return [
36+
...
37+
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
38+
Yoanm\SymfonyJsonRpcHttpServer\JsonRpcHttpServerBundle::class => ['all' => true],
39+
Yoanm\SymfonyJsonRpcHttpServerDoc\JsonRpcHttpServerDocBundle::class => ['all' => true],
40+
...
41+
];
42+
```
43+
44+
- Add the following in your routing configuration :
45+
```yaml
46+
# config/routes.yaml
47+
json-rpc-endpoint:
48+
resource: '@JsonRpcHttpServerBundle/Resources/config/routing/endpoint.xml'
49+
50+
json-rpc-endpoint-doc:
51+
resource: '@JsonRpcHttpServerDocBundle/Resources/config/routing/endpoint.xml'
52+
```
53+
54+
- Add the following in your configuration :
55+
```yaml
56+
# config/config.yaml
57+
framework:
58+
secret: '%env(APP_SECRET)%'
59+
60+
json_rpc_http_server: ~
61+
62+
json_rpc_http_server_doc: ~
63+
# Or the following in case you want to customize endpoint path
64+
#json_rpc_http_server_doc:
65+
# endpoint: '/my-custom-doc-endpoint' # Default to '/doc'
66+
```
67+
68+
- Register JSON-RPC methods as described on [yoanm/symfony-jsonrpc-http-server](https://github.com/yoanm/symfony-jsonrpc-http-server) documentation.
69+
70+
- Query your project at `/doc` endpoint and you will have a `json` documentation of your server.
1571

1672
## Contributing
1773
See [contributing note](./CONTRIBUTING.md)

behat.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@ default:
22
suites:
33
default:
44
contexts:
5-
- Tests\Functional\BehatContext\FeatureContext: ~
5+
- Tests\Functional\BehatContext\DemoAppContext: ~
6+
coverage:
7+
extensions:
8+
LeanPHP\Behat\CodeCoverage\Extension:
9+
drivers:
10+
- local
11+
filter:
12+
whitelist:
13+
include:
14+
directories:
15+
'src': ~
16+
report:
17+
format: html
18+
options:
19+
target: build/behat-coverage

composer.json

+49-43
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,52 @@
11
{
2-
"name": "yoanm/symfony-jsonrpc-http-server-doc",
3-
"description": "Symfony bundle for easy JSON-RPC server documentation",
4-
"license": "MIT",
5-
"type": "library",
6-
"support": {
7-
"issues": "https://github.com/yoanm/symfony-jsonrpc-http-server-doc/issues"
8-
},
9-
"authors": [
10-
{
11-
"name": "Yoanm",
12-
"email": "yoanm@users.noreply.github.com",
13-
"role": "Developer"
14-
}
15-
],
16-
"autoload": {
17-
"psr-4": {
18-
"Yoanm\\SymfonyJsonRpcHttpServerDoc\\": "src"
19-
}
20-
},
21-
"autoload-dev": {
22-
"psr-4": {
23-
"Tests\\": "tests",
24-
"Tests\\Functional\\BehatContext\\": "features/bootstrap"
25-
}
26-
},
27-
"require": {
28-
"php": ">=5.5",
29-
"yoanm/jsonrpc-server-sdk": "dev-release/3.0.0 || dev-master",
30-
"yoanm/jsonrpc-server-doc-sdk": "dev-release/1.0.0 || dev-master",
31-
"yoanm/symfony-jsonrpc-http-server": "dev-release/3.0.0 || dev-master",
32-
"symfony/http-foundation": "^3.0 || ^4.0",
33-
"symfony/http-kernel": "^3.0 || ^4.0",
34-
"symfony/config": "^3.0 || ^4.0",
35-
"symfony/dependency-injection": "^3.0 || ^4.0"
36-
},
37-
"require-dev": {
38-
"behat/behat": "~3.0",
39-
"squizlabs/php_codesniffer": "3.*",
40-
"phpunit/phpunit": "^6.0 || ^7.0",
41-
"matthiasnoback/symfony-dependency-injection-test": "^2.0 || ^3.0",
42-
"matthiasnoback/symfony-config-test": "^3.0 || ^4.0",
43-
"symfony/framework-bundle": "^3.4",
44-
"yoanm/php-unit-extended": "~1.0"
2+
"name": "yoanm/symfony-jsonrpc-http-server-doc",
3+
"description": "Symfony bundle for easy JSON-RPC server documentation",
4+
"license": "MIT",
5+
"type": "library",
6+
"support": {
7+
"issues": "https://github.com/yoanm/symfony-jsonrpc-http-server-doc/issues"
8+
},
9+
"authors": [
10+
{
11+
"name": "Yoanm",
12+
"email": "yoanm@users.noreply.github.com",
13+
"role": "Developer"
4514
}
15+
],
16+
"autoload": {
17+
"psr-4": {
18+
"Yoanm\\SymfonyJsonRpcHttpServerDoc\\": "src"
19+
}
20+
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"Tests\\": "tests",
24+
"Tests\\Functional\\BehatContext\\": "features/bootstrap",
25+
"DemoApp\\": "features/demo_app/src"
26+
}
27+
},
28+
"suggest": {
29+
"yoanm/symfony-jsonrpc-http-server": "Symfony Bundle to convert an HTTP json-rpc request into HTTP json-rpc response",
30+
"yoanm/symfony-jsonrpc-params-sf-constraints-doc": "Symfony bundle for easy Symfony constraints to JSON-RPC documentation transformation",
31+
"yoanm/symfony-jsonrpc-http-server-openapi-doc": "Symfony bundle for easy JSON-RPC server OpenAPI 3.0.0 documentation",
32+
"yoanm/symfony-jsonrpc-http-server-swagger-doc": "Symfony bundle for easy JSON-RPC server Swagger 2.0 documentation"
33+
},
34+
"require": {
35+
"php": ">=7.1",
36+
"yoanm/jsonrpc-server-sdk": "^3.0",
37+
"yoanm/jsonrpc-server-doc-sdk": "^0.1",
38+
"yoanm/symfony-jsonrpc-http-server": "^2.0",
39+
"symfony/http-kernel": "^3.0 || ^4.0",
40+
"symfony/config": "^3.0 || ^4.0",
41+
"symfony/dependency-injection": "^3.0 || ^4.0"
42+
},
43+
"require-dev": {
44+
"behat/behat": "~3.0",
45+
"squizlabs/php_codesniffer": "3.*",
46+
"phpunit/phpunit": "^6.0 || ^7.0",
47+
"matthiasnoback/symfony-dependency-injection-test": "^2.0 || ^3.0",
48+
"matthiasnoback/symfony-config-test": "^3.0 || ^4.0",
49+
"symfony/framework-bundle": "^3.0 || ^4.0",
50+
"yoanm/php-unit-extended": "~1.0"
51+
}
4652
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
namespace Tests\Functional\BehatContext;
3+
4+
use Behat\Behat\Context\Context;
5+
6+
class AbstractContext implements Context
7+
{
8+
protected function jsonDecode($encodedData)
9+
{
10+
$decoded = json_decode($encodedData, true);
11+
12+
if (JSON_ERROR_NONE != json_last_error()) {
13+
throw new \Exception(
14+
json_last_error_msg(),
15+
json_last_error()
16+
);
17+
}
18+
19+
return $decoded;
20+
}
21+
}

0 commit comments

Comments
 (0)