php-openapi icon indicating copy to clipboard operation
php-openapi copied to clipboard

validate() returns true with wrong top level elements

Open franksl opened this issue 5 years ago • 2 comments

Hi, I tried to run validate like this:

$spec   = cebe\openapi\Reader::readFromJson($jsonstring);
$spec->resolveReferences(new cebe\openapi\ReferenceContext($spec, "/"));
$spec->validate();

on a OpenAPI 3 schema that has, for example the property "AAAAAcomponents" instead of "components", and the call returns true. Is this correct? Thanks, Frank

franksl avatar Dec 04 '20 17:12 franksl

it is possible to extend the OpenAPI description. So adding properties is generally allowed. Strictly following the spec would mean that you need to prefix additional properties with x-.

cebe avatar Dec 14 '20 20:12 cebe

validation currently means to check if the existing elements are used correctly. It would be possible to add some kind of strict mode that would also complain about cases like yours.

cebe avatar Dec 14 '20 23:12 cebe