-
Notifications
You must be signed in to change notification settings - Fork 21
/
swagger_bake.php
89 lines (85 loc) · 3.33 KB
/
swagger_bake.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
use Cake\Core\Configure;
/**
* ################################
* # REQUIRED SETTINGS:
* ################################
*
* @var string $prefix The route scope that SwaggerBake will scan for your APIs routes (e.g. `/api/`)
*
* @var string $yml A base Swagger YML file, see example in assets (e.g. `/config/swagger.yml`).
*
* @var string $json Web accessible file path the JSON file is written to (e.g. `/webroot/swagger.json`).
*
* @var string $webPath The URL browsers will use to access the JSON file (e.g. `/swagger.json`).
*
* ################################
* # RECOMMENDED SETTINGS:
* ################################
*
* @var bool $hotReload Regenerate swagger on page reloaded. This only works if you are using the built-in Swagger UI.
* Using your applications debug value is recommended as an easy way to define this.
* Default: false
*
* ################################
* # OPTIONAL SETTINGS:
* ################################
*
* @var string $connectionName The connection name to use when loading tables for building schemas from models.
* Default: default
*
* @var array $editActionMethods The default HTTP methods to use for CakePHPs edit() action.
* Default: ['PATCH']
*
* @var int $jsonOptions A bitmask of options passed as second parameter to json_encode function. Accepted values are
* described at https://www.php.net/manual/en/function.json-encode.php
* Default: JSON_PRETTY_PRINT
*
* @var string[] $requestAccepts Array of mime types accepted. Can be used if your application accepts JSON, XML etc...
* Default: ['application/json']
*
* @var string[] $responseContentTypes Array of mime types returned. Can be used if your application returns XML etc...
* Default: ['application/json']
*
* @var string $docType The default doc type. Options are swagger and redoc.
* Default: swagger
*
* @var string|null $exceptionSchema The short name of your Exception schema in swagger.yaml components > schemas.
* Default: Exception.
*
* @var array[] $namespaces Array of namespaces. Useful if your controllers or entities exist in non-standard
* namespace such as a plugin. This was mostly added to aid in unit testing, but there are cases where controllers
* may exist in a plugin namespace etc...
* Default: ['controllers' => ['\App\\'], 'entities' => ['\App\\'], 'tables' => ['\App\\']]
*/
return [
'SwaggerBake' => [
'prefix' => '/your-relative-api-url',
'yml' => '/config/swagger.yml',
'json' => '/webroot/swagger.json',
'webPath' => '/swagger.json',
'hotReload' => Configure::read('debug'),
'jsonOptions' => Configure::read('debug') ? JSON_PRETTY_PRINT : JSON_UNESCAPED_UNICODE,
/*
'editActionMethods' => ['PATCH'],
'requestAccepts' => [
'application/json',
'application/x-www-form-urlencoded',
'application/xml',
],
'responseContentTypes' => [
'application/json',
'application/xml',
'application/hal+json',
'application/json+ld'
],
'docType' => 'swagger',
'exceptionSchema' => 'Exception',
'namespaces' => [
'controllers' => ['\App\\'],
'entities' => ['\App\\'],
'tables' => ['\App\\']
],
*/
]
];