Skip to content

Commit 37f2e0d

Browse files
authored
Merge pull request #201 from jr3cermak/master
A little bugfix.
2 parents 88b7bdb + cefe7b4 commit 37f2e0d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

api.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,10 @@ protected function swagger($settings) {
24292429
echo '"required":true,';
24302430
echo '"schema":{';
24312431
echo '"type": "object",';
2432-
echo '"required":'.json_encode(array_keys(array_filter($action['fields'],function($f){ return $f->required; }))).',';
2432+
$required_fields = array_keys(array_filter($action['fields'],function($f){ return $f->required; }));
2433+
if (count($required_fields) > 0) {
2434+
echo '"required":'.json_encode($required_fields).',';
2435+
}
24332436
echo '"properties": {';
24342437
foreach (array_keys($action['fields']) as $k=>$field) {
24352438
if ($k>0) echo ',';
@@ -2497,7 +2500,10 @@ protected function swagger($settings) {
24972500
echo '"required":true,';
24982501
echo '"schema":{';
24992502
echo '"type": "object",';
2500-
echo '"required":'.json_encode(array_keys(array_filter($action['fields'],function($f){ return $f->required; }))).',';
2503+
$required_fields = array_keys(array_filter($action['fields'],function($f){ return $f->required; }));
2504+
if (count($required_fields) > 0) {
2505+
echo '"required":'.json_encode($required_fields).',';
2506+
}
25012507
echo '"properties": {';
25022508
foreach (array_keys($action['fields']) as $k=>$field) {
25032509
if ($k>0) echo ',';

tests/tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public function testOptionsRequest()
450450
{
451451
$test = new API($this);
452452
$test->options('/posts/2');
453-
$test->expect('["Access-Control-Allow-Headers: Content-Type, X-XSRF-Token","Access-Control-Allow-Methods: OPTIONS, GET, PUT, POST, DELETE, PATCH","Access-Control-Allow-Credentials: true","Access-Control-Max-Age: 1728000"]',false);
453+
$test->expect('["Access-Control-Allow-Headers: Content-Type, X-XSRF-TOKEN","Access-Control-Allow-Methods: OPTIONS, GET, PUT, POST, DELETE, PATCH","Access-Control-Allow-Credentials: true","Access-Control-Max-Age: 1728000"]',false);
454454
}
455455

456456
public function testHidingPasswordColumn()

0 commit comments

Comments
 (0)