@@ -83,7 +83,7 @@ public function testReadPetStore()
8383
8484 public function assertAllInstanceOf ($ className , $ array )
8585 {
86- foreach ($ array as $ k => $ v ) {
86+ foreach ($ array as $ k => $ v ) {
8787 $ this ->assertInstanceOf ($ className , $ v , "Asserting that item with key ' $ k' is instance of $ className " );
8888 }
8989 }
@@ -147,7 +147,7 @@ public function specProvider()
147147 /** @var $it RecursiveDirectoryIterator|RecursiveIteratorIterator */
148148 $ it = new RecursiveIteratorIterator (new RecursiveDirectoryIterator (__DIR__ . '/../../vendor/apis-guru/openapi-directory/APIs ' ));
149149 $ it ->rewind ();
150- while ($ it ->valid ()) {
150+ while ($ it ->valid ()) {
151151 if ($ it ->getBasename () === 'openapi.yaml ' ) {
152152 $ apisGuruExamples [] = $ it ->key ();
153153 }
@@ -159,10 +159,10 @@ public function specProvider()
159159 /** @var $it RecursiveDirectoryIterator|RecursiveIteratorIterator */
160160 $ it = new RecursiveIteratorIterator (new RecursiveDirectoryIterator (__DIR__ . '/../../vendor/nexmo/api-specification/definitions ' ));
161161 $ it ->rewind ();
162- while ($ it ->valid ()) {
162+ while ($ it ->valid ()) {
163163 if ($ it ->getExtension () === 'yml '
164- && strpos ($ it ->getSubPath (), 'common ' ) === false
165- && $ it ->getBasename () !== 'voice.v2.yml ' // contains invalid references
164+ && strpos ($ it ->getSubPath (), 'common ' ) === false
165+ && $ it ->getBasename () !== 'voice.v2.yml ' // contains invalid references
166166 ) {
167167 $ nexmoExamples [] = $ it ->key ();
168168 }
@@ -175,7 +175,7 @@ public function specProvider()
175175 $ apisGuruExamples ,
176176 $ nexmoExamples
177177 );
178- foreach ($ all as $ path ) {
178+ foreach ($ all as $ path ) {
179179 yield [
180180 substr ($ path , strlen (__DIR__ . '/../../vendor/ ' )),
181181 basename (dirname ($ path , 2 )) . DIRECTORY_SEPARATOR . basename (dirname ($ path , 1 )) . DIRECTORY_SEPARATOR . basename ($ path )
@@ -233,4 +233,26 @@ public function testSpecs($openApiFile)
233233 }
234234
235235 }
236+
237+ public function testJsonSerialize ()
238+ {
239+ $ spec = <<<YML
240+ openapi: 3.0.0
241+ info:
242+ title: Minimal API
243+ version: 1.0.0
244+ paths:
245+ /:
246+ get:
247+ summary: Retrieves a minimal response
248+ responses:
249+ '200':
250+ description: OK
251+
252+ YML ;
253+ $ yaml = Yaml::parse ($ spec );
254+ $ openapi = new OpenApi ($ yaml );
255+
256+ $ this ->assertSame (json_encode ($ openapi ), '{"openapi":"3.0.0","info":{"title":"Minimal API","version":"1.0.0"},"paths":{"\/":{"get":{"summary":"Retrieves a minimal response","responses":{"200":{"description":"OK"}}}}}} ' );
257+ }
236258}
0 commit comments