@@ -117,7 +117,8 @@ public static function createFromData($data): OpenApiModelInterface
117117 public function setData ($ data ): void
118118 {
119119 $ schema = (array ) static ::getOpenApiSchema ();
120- switch ($ schema ['type ' ]) {
120+ $ modelType = (array_key_exists ('type ' , $ schema )) ? $ schema ['type ' ] : null ;
121+ switch ($ modelType ) {
121122 case IMocker::DATA_TYPE_ARRAY :
122123 // data for array OAS type should be straight indexed array
123124 if (is_array ($ data )) {
@@ -163,7 +164,8 @@ public function getData()
163164 {
164165 $ data = null ;
165166 $ schema = (array ) static ::getOpenApiSchema ();
166- switch ($ schema ['type ' ]) {
167+ $ modelType = (array_key_exists ('type ' , $ schema )) ? $ schema ['type ' ] : null ;
168+ switch ($ modelType ) {
167169 case IMocker::DATA_TYPE_OBJECT :
168170 // need to convert data container to object
169171 $ data = new StdClass ();
@@ -289,7 +291,7 @@ public function jsonSerialize()
289291 protected function validateModelType (?string $ type = null , bool $ throwException = true ): bool
290292 {
291293 $ isValid = in_array ($ type , static ::VALID_OAS_DATA_TYPES );
292- if ($ isValid === false && $ throwException ) {
294+ if ($ type !== null && $ isValid === false && $ throwException ) {
293295 throw new InvalidArgumentException (
294296 sprintf (
295297 'Invalid OAS schema of %s model, "type" must be one of %s ' ,
0 commit comments