@@ -33,7 +33,7 @@ private function docsToOpenApi(array $docs)
33
33
{
34
34
$ this ->openApi ['paths ' ] = [];
35
35
foreach ($ docs as $ doc ) {
36
- $ requestHasFile = false ;
36
+ $ requestHasFile = false ;
37
37
$ httpMethod = strtolower ($ doc ['httpMethod ' ]);
38
38
$ isGet = $ httpMethod == 'get ' ;
39
39
$ isPost = $ httpMethod == 'post ' ;
@@ -45,21 +45,21 @@ private function docsToOpenApi(array $docs)
45
45
46
46
$ this ->openApi ['paths ' ][$ doc ['uri ' ]][$ httpMethod ]['responses ' ] = config ('request-docs.open_api.responses ' , []);
47
47
48
- foreach ($ doc ['rules ' ] as $ attribute => $ rules ) {
48
+ foreach ($ doc ['rules ' ] as $ attribute => $ rules ) {
49
49
foreach ($ rules as $ rule ) {
50
- if ($ isPost || $ isPut || $ isDelete ) {
51
- $ requestHasFile = $ this ->attributeIsFile ($ rule );
50
+ if ($ isPost || $ isPut || $ isDelete ) {
51
+ $ requestHasFile = $ this ->attributeIsFile ($ rule );
52
52
53
- if ($ requestHasFile ) {
54
- break 2 ;
55
- }
56
- }
57
- }
58
- }
53
+ if ($ requestHasFile ) {
54
+ break 2 ;
55
+ }
56
+ }
57
+ }
58
+ }
59
59
60
- $ contentType = $ requestHasFile ? 'multipart/form-data ' : 'application/json ' ;
60
+ $ contentType = $ requestHasFile ? 'multipart/form-data ' : 'application/json ' ;
61
61
62
- if ($ isGet ) {
62
+ if ($ isGet ) {
63
63
$ this ->openApi ['paths ' ][$ doc ['uri ' ]][$ httpMethod ]['parameters ' ] = [];
64
64
}
65
65
if ($ isPost || $ isPut || $ isDelete ) {
@@ -80,10 +80,10 @@ private function docsToOpenApi(array $docs)
80
80
}
81
81
}
82
82
83
- protected function attributeIsFile (string $ rule )
84
- {
85
- return str_contains ($ rule , 'file ' ) || str_contains ($ rule , 'image ' );
86
- }
83
+ protected function attributeIsFile (string $ rule )
84
+ {
85
+ return str_contains ($ rule , 'file ' ) || str_contains ($ rule , 'image ' );
86
+ }
87
87
88
88
protected function makeQueryParameterItem (string $ attribute , string $ rule ): array
89
89
{
@@ -118,12 +118,12 @@ protected function makeRequestBodyItem(string $contentType): array
118
118
119
119
protected function makeRequestBodyContentPropertyItem (string $ rule ): array
120
120
{
121
- $ type = $ this ->getAttributeType ($ rule );
121
+ $ type = $ this ->getAttributeType ($ rule );
122
122
123
123
return [
124
124
'type ' => $ type ,
125
- 'nullable ' => str_contains ($ rule , 'nullable ' ),
126
- 'format ' => $ this ->attributeIsFile ($ rule ) ? 'binary ' : $ type ,
125
+ 'nullable ' => str_contains ($ rule , 'nullable ' ),
126
+ 'format ' => $ this ->attributeIsFile ($ rule ) ? 'binary ' : $ type ,
127
127
];
128
128
}
129
129
@@ -139,18 +139,18 @@ protected function getAttributeType(string $rule): string
139
139
if (str_contains ($ rule , 'integer ' )) {
140
140
return 'integer ' ;
141
141
}
142
- if (str_contains ($ rule , 'boolean ' )) {
142
+ if (str_contains ($ rule , 'boolean ' )) {
143
143
return 'boolean ' ;
144
144
}
145
145
return "object " ;
146
146
}
147
147
148
- public function toJson () : string
148
+ public function toJson (): string
149
149
{
150
150
return collect ($ this ->openApi )->toJson (JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
151
151
}
152
152
153
- public function toArray () : array
153
+ public function toArray (): array
154
154
{
155
155
return $ this ->openApi ;
156
156
}
0 commit comments