Skip to content

Commit d92441a

Browse files
authored
Merge pull request #17 from php-api-clients/dont-write-empty-file-names
Don't try to create empty file names
2 parents 788e06d + 9b1ec46 commit d92441a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Generator.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function generate(string $namespace, string $destinationPath)
3434
}
3535
foreach ($this->spec->components->schemas as $name => $schema) {
3636
$schemaClassName = $schemaClassNameMap[spl_object_hash($schema)];
37+
if (strlen($schemaClassName) === 0) {
38+
continue;
39+
}
3740
@mkdir(dirname($destinationPath . '/Schema/' . $schemaClassName), 0777, true);
3841
file_put_contents($destinationPath . '/Schema/' . $schemaClassName . '.php', $codePrinter->prettyPrintFile([
3942
Schema::generate(
@@ -48,6 +51,9 @@ public function generate(string $namespace, string $destinationPath)
4851

4952
foreach ($this->spec->paths as $path => $pathItem) {
5053
$pathClassName = $this->className($path);
54+
if (strlen($pathClassName) === 0) {
55+
continue;
56+
}
5157
@mkdir(dirname($destinationPath . '/Path/' . $pathClassName), 0777, true);
5258
file_put_contents($destinationPath . '/Path/' . $pathClassName . '.php', $codePrinter->prettyPrintFile([
5359
Path::generate(
@@ -61,7 +67,9 @@ public function generate(string $namespace, string $destinationPath)
6167
foreach ($pathItem->getOperations() as $method => $operation) {
6268
$operationClassName = $this->className((new Convert($operation->operationId))->fromTrain()->toPascal());
6369
$operations[$method] = $operationClassName;
64-
70+
if (strlen($operationClassName) === 0) {
71+
continue;
72+
}
6573
@mkdir(dirname($destinationPath . '/Operation/' . $operationClassName), 0777, true);
6674
file_put_contents($destinationPath . '/Operation/' . $operationClassName . '.php', $codePrinter->prettyPrintFile([
6775
Operation::generate(

0 commit comments

Comments
 (0)