File tree Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Expand file tree Collapse file tree 2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "openapi" : " 3.0.0" ,
3+ "info" : {
4+ "title" : " My API" ,
5+ "version" : " 1, 2"
6+ },
7+ "paths" : {
8+ "/v1/users/profile" : {
9+ "get" : {
10+ "operationId" : " V1GetUserProfile" ,
11+ "summary" : " Returns the user profile" ,
12+ "responses" : {
13+ "200" : {
14+ "description" : " dummy"
15+ }
16+ },
17+ "security" : [
18+ {
19+ "test_test" : [" test:scope:foo" ]
20+ }
21+ ]
22+ }
23+ }
24+ },
25+ "components" : {
26+ "securitySchemes" : {
27+ "test_test" : {
28+ "type" : " oauth2" ,
29+ "flows" : {
30+ "authorizationCode" : {
31+ "authorizationUrl" : " https://example.com/openid-connect/auth" ,
32+ "tokenUrl" : " https://example.com/openid-connect/token" ,
33+ "scopes" : {
34+ "test:scope:foo" : " test_scope"
35+ }
36+ }
37+ }
38+ }
39+ }
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use cebe \openapi \Reader ;
4+ use cebe \openapi \spec \OpenApi ;
5+ use cebe \openapi \spec \SecurityRequirements ;
6+ use cebe \openapi \Writer ;
7+
8+ // https://github.com/cebe/php-openapi/issues/242
9+ class Issue242Test extends \PHPUnit \Framework \TestCase
10+ {
11+ public function test242CliCallToOpenapiSpecWithSecurityInPathFails ()
12+ {
13+ $ openapi = Reader::readFromJsonFile (dirname (__DIR__ , 2 ) . '/data/issue/242/spec.json ' );
14+ $ this ->assertInstanceOf (\cebe \openapi \SpecObjectInterface::class, $ openapi );
15+
16+ $ file = dirname (__DIR__ , 2 ) . '/data/issue/242/spec.json ' ;
17+ $ dirSep = DIRECTORY_SEPARATOR ;
18+ $ cmd = 'php ' . dirname (__DIR__ , 3 ) . "{$ dirSep }bin {$ dirSep }php-openapi validate " . $ file . " 2>&1 " ;
19+ exec ($ cmd , $ op , $ ec );
20+ $ this ->assertSame ($ this ->removeCliFormatting ($ op [0 ]), 'The supplied API Description validates against the OpenAPI v3.0 schema. ' );
21+ $ this ->assertSame (0 , $ ec );
22+ }
23+
24+ private function removeCliFormatting ($ string )
25+ {
26+ // Regex to remove ANSI escape codes
27+ return preg_replace ('/\e\[[0-9;]*m/ ' , '' , $ string );
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments