diff --git a/src/Generator.php b/src/Generator.php index bfb55e4..d639740 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -24,7 +24,7 @@ public function generate(string $namespace, string $destinationPath) { $namespace = $this->cleanUpNamespace($namespace); $codePrinter = new Standard(); - if (count($this->spec->components->schemas) > 0) { + if (count($this->spec->components->schemas ?? []) > 0) { $schemaClassNameMap = []; foreach ($this->spec->components->schemas as $name => $schema) { $schemaClassName = $this->className($name); @@ -51,7 +51,7 @@ public function generate(string $namespace, string $destinationPath) } } - if (count($this->spec->paths) > 0) { + if (count($this->spec->paths ?? []) > 0) { foreach ($this->spec->paths as $path => $pathItem) { $pathClassName = $this->className($path); if (strlen($pathClassName) === 0) {