File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88namespace cebe \openapi \spec ;
99
10- use cebe \openapi \exceptions \TypeErrorException ;
1110use cebe \openapi \SpecBaseObject ;
1211
1312/**
@@ -79,11 +78,11 @@ public function performValidation()
7978 $ this ->addError ('Unsupported openapi version: ' . $ this ->openapi );
8079 }
8180
82- $ providedFields = array_keys (json_decode ( json_encode ( $ this ->getSerializableData ()), true )); # TODO this getSerializableData() can be eliminated if
81+ $ providedFields = array_keys ($ this ->getRawSpecData ());
8382 $ allowedFields = array_keys ($ this ->attributes ());
8483 foreach ($ providedFields as $ field ) {
8584 if (!in_array ($ field , $ allowedFields )) {
86- $ this ->addError ('Invalid top level fields: ' . $ field );
85+ $ this ->addError ('Invalid top level field: " ' . $ field . ' ". More information can be obtained at https://spec.openapis.org/oas/v3.0.3.html#fixed-fields ' );
8786 }
8887 }
8988 }
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ public function testSpecs($openApiFile)
236236 public function testInvalidTopLevelField ()
237237 {
238238 $ openapi = new OpenApi ([
239- 'AAcomponents ' => [
239+ 'AAAAAcomponents ' => [
240240 'User ' => [
241241 'type ' => 'object ' ,
242242 'properties ' => [
@@ -247,12 +247,12 @@ public function testInvalidTopLevelField()
247247 ]
248248 ]
249249 ]);
250- $ isValid = $ openapi ->validate ();
251- // $this->assertTrue($openapi->validate());
250+ $ this ->assertFalse ($ openapi ->validate ());
252251 $ this ->assertEquals ([
253252 'OpenApi is missing required property: openapi ' ,
254253 'OpenApi is missing required property: info ' ,
255254 'OpenApi is missing required property: paths ' ,
255+ 'Invalid top level field: "AAAAAcomponents". More information can be obtained at https://spec.openapis.org/oas/v3.0.3.html#fixed-fields ' ,
256256 ], $ openapi ->getErrors ());
257257
258258// // check default value of servers
You can’t perform that action at this time.
0 commit comments