Skip to content

Commit e5751c2

Browse files
committed
Implementation in progress
1 parent e33b410 commit e5751c2

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ fix-style: php-cs-fixer.phar
3737
$(DOCKER_PHP) vendor/bin/indent --spaces .php_cs.dist
3838
$(DOCKER_PHP) ./php-cs-fixer.phar fix src/ --diff
3939

40+
cli:
41+
docker-compose run --rm php bash
42+
43+
#cli_root:
44+
# docker-compose exec --user="root" php bash
45+
4046
install:
4147
$(DOCKER_PHP) composer install --prefer-dist --no-interaction --no-progress --ansi
4248
$(DOCKER_NODE) yarn install

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,3 @@ Professional support, consulting as well as software development services are av
298298
https://www.cebe.cc/en/contact
299299

300300
Development of this library is sponsored by [cebe.:cloud: "Your Professional Deployment Platform"](https://cebe.cloud).
301-

src/spec/OpenApi.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace cebe\openapi\spec;
99

10-
use cebe\openapi\exceptions\TypeErrorException;
1110
use cebe\openapi\SpecBaseObject;
1211

1312
/**
@@ -38,7 +37,7 @@ protected function attributes(): array
3837
'servers' => [Server::class],
3938
'paths' => Paths::class,
4039
'components' => Components::class,
41-
'security' => [SecurityRequirement::class],
40+
'security' => [Type::STRING, SecurityRequirement::class],
4241
'tags' => [Tag::class],
4342
'externalDocs' => ExternalDocumentation::class,
4443
];

src/spec/Operation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function attributes(): array
4646
'responses' => Responses::class,
4747
'callbacks' => [Type::STRING, Callback::class],
4848
'deprecated' => Type::BOOLEAN,
49-
'security' => [SecurityRequirement::class],
49+
'security' => [Type::STRING, SecurityRequirement::class],
5050
'servers' => [Server::class],
5151
];
5252
}

tests/WriterTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

3+
use cebe\openapi\spec\Components;
4+
use cebe\openapi\spec\OpenApi;
5+
use cebe\openapi\spec\Operation;
6+
use cebe\openapi\spec\PathItem;
37
use cebe\openapi\spec\SecurityRequirement;
8+
use cebe\openapi\spec\SecurityScheme;
49

510
class WriterTest extends \PHPUnit\Framework\TestCase
611
{
@@ -187,4 +192,31 @@ public function testWriteEmptySecurityPartYaml()
187192
$yaml
188193
);
189194
}
195+
196+
public function testSecurity()
197+
{
198+
$openapi = new OpenApi([
199+
'components' => new Components([
200+
'securitySchemes' => [
201+
'BearerAuth' => new SecurityScheme([
202+
'type' => 'http',
203+
'scheme' => 'bearer',
204+
'bearerFormat' => 'AuthToken and JWT Format' # optional, arbitrary value for documentation purposes
205+
])
206+
],
207+
]),
208+
'paths' => [
209+
'/test' => new PathItem([
210+
'get' => new Operation([
211+
'security' => [
212+
'BearerAuth' => new SecurityRequirement([])
213+
],
214+
])
215+
])
216+
]
217+
]);
218+
219+
$result = json_decode(json_encode($openapi->getSerializableData()), true);
220+
$this->assertTrue($result);
221+
}
190222
}

0 commit comments

Comments
 (0)