Skip to content

Commit 75968f1

Browse files
committed
Initial commit
0 parents  commit 75968f1

Some content is hidden

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

60 files changed

+7587
-0
lines changed

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/docs/ export-ignore
4+
/phpunit.xml.dist export-ignore
5+
/php-cs-fixer.php export-ignore
6+
/test/ export-ignore
7+
/.idea/ export-ignore
8+
/vendor/ export-ignore

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.idea
2+
/vendor
3+
4+
/.php-cs-fixer.cache
5+
/.phpunit.result.cache

.php-cs-fixer.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->files()
7+
->name('*.php')
8+
->in(__DIR__ . '/config')
9+
->in(__DIR__ . '/src')
10+
->in(__DIR__ . '/test');
11+
12+
return (new PhpCsFixer\Config())
13+
->setIndent(' ')
14+
->setLineEnding("\n")
15+
->setRules([
16+
'@PSR12' => true,
17+
'no_trailing_whitespace_in_comment' => false,
18+
])
19+
->setRiskyAllowed(true)
20+
->setFinder($finder);

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PHP Swagger Module Change Log
2+
=============================
3+
4+
0.1-dev [2022-07-17]
5+
---------------------
6+
- First release

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2022 Simon Rodin<dev@genxoft.dev> and contributors (see https://github.com/genxoft/php-swagger-module/contributors)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Swagger PHP module
2+
3+
## Description
4+
5+
Swagger PHP module adapted for Mezzio/Laminas.
6+
7+
## Requirements
8+
9+
- PHP >7.4
10+
- Mezzio\Template\TemplateRendererInterface
11+
12+
## Installation
13+
14+
15+
The preferred way to install this wrapper is through [composer](http://getcomposer.org/download/).
16+
17+
```bash
18+
php composer.phar require genxoft/php-swagger-module
19+
```
20+
21+
or
22+
23+
```bash
24+
composer require genxoft/php-swagger-module
25+
```
26+
27+
or add to the require section of `composer.json`
28+
29+
```
30+
"genxoft/php-swagger-module" : "*"
31+
```
32+
33+
## Setup
34+
35+
After installation of the package, you need to complete the following steps to use PHP Swagger module:
36+
37+
1. Add ```\Genxoft\SwaggerPhpModule\ConfigProvider::class``` to your config aggregator
38+
2. Add and customize (if necessary) configuration (add file ```php-swagger.global.php``` into ```config/autoload```)
39+
```php
40+
<?php
41+
return [
42+
'swagger_php' => [
43+
'scanDirs' => [
44+
__DIR__ . '/module'
45+
],
46+
'jsonUrl' => '/api-oas-docs/json',
47+
],
48+
'routes' => [
49+
'swagger_php.route.json' => [
50+
'path' => '/api-oas-docs/json',
51+
'middleware' => [
52+
\Genxoft\SwaggerPhpModule\Handler\JsonAction::class,
53+
],
54+
'allowed_methods' => ['GET'],
55+
],
56+
'swagger_php.route.ui' => [
57+
'path' => '/api-oas-docs/ui',
58+
'middleware' => [
59+
\Genxoft\SwaggerPhpModule\Handler\UiAction::class,
60+
],
61+
'allowed_methods' => ['GET'],
62+
],
63+
],
64+
];
65+
```
66+
67+
## Open Api Swagger 3 example annotation
68+
69+
Api server description
70+
71+
```php
72+
/**
73+
* @OA\Info(
74+
* version="1.0",
75+
* title="Application API",
76+
* description="Server - Mobile app API",
77+
* @OA\Contact(
78+
* name="John Smith",
79+
* email="john@example.com",
80+
* ),
81+
* ),
82+
* @OA\Server(
83+
* url="https://example.com/api",
84+
* description="main server",
85+
* )
86+
* @OA\Server(
87+
* url="https://dev.example.com/api",
88+
* description="dev server",
89+
* )
90+
*/
91+
...
92+
```
93+
94+
Handler annotation
95+
96+
```php
97+
/**
98+
* @OA\Get(path="/",
99+
* summary="Handshake",
100+
* tags={"handshake"},
101+
* @OA\Parameter(
102+
* name="access-token",
103+
* in="header",
104+
* required=false,
105+
* @OA\Schema(
106+
* type="string"
107+
* )
108+
* ),
109+
* @OA\Response(
110+
* response=200,
111+
* description="Returns Hello object",
112+
* @OA\MediaType(
113+
* mediaType="application/json",
114+
* @OA\Schema(ref="#/components/schemas/Hello"),
115+
* ),
116+
* ),
117+
* )
118+
*/
119+
class HelloHandler implements RequestHandlerInterface
120+
{
121+
...
122+
```
123+
Model annotation
124+
```php
125+
/**
126+
*@OA\Schema(
127+
* schema="Hello",
128+
* @OA\Property(
129+
* property="message",
130+
* type="string",
131+
* description="Text message"
132+
* ),
133+
* @OA\Property(
134+
* property="time",
135+
* type="integer",
136+
* description="Server current Unix time"
137+
* ),
138+
* @OA\Property(
139+
* property="date",
140+
* type="string",
141+
* format="date-time",
142+
* description="Server current date time"
143+
* )
144+
*)
145+
*/
146+
class HelloModel
147+
{
148+
...
149+
```
150+
151+
## Screenshot
152+
153+
![Swagger UI Screenshot](/docs/swagger-ui-screenshot.png)
154+
155+
## Donate
156+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2PURUX2SHUD9E"><img src="https://www.paypalobjects.com/en_US/RU/i/btn/btn_donateCC_LG.gif"></a>
157+
158+
## LICENSE
159+
This curl wrapper is released under the [MIT license](https://github.com/genxoft/php-swagger-module/LICENSE.md).

asset/swagger-ui/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ORIGIN https://github.com/swagger-api/swagger-ui
2+
3+
LICENSE https://github.com/swagger-api/swagger-ui/blob/master/LICENSE

asset/swagger-ui/favicon-16x16.png

665 Bytes
Loading

asset/swagger-ui/favicon-32x32.png

628 Bytes
Loading

asset/swagger-ui/index.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
html {
2+
box-sizing: border-box;
3+
overflow: -moz-scrollbars-vertical;
4+
overflow-y: scroll;
5+
}
6+
7+
*,
8+
*:before,
9+
*:after {
10+
box-sizing: inherit;
11+
}
12+
13+
body {
14+
margin: 0;
15+
background: #fafafa;
16+
}

0 commit comments

Comments
 (0)