Skip to content

Commit 29bfa28

Browse files
committed
No Ghost classes
Signed-off-by: Cees-Jan Kiewiet <[email protected]>
1 parent 1ba68c0 commit 29bfa28

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Generator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ public function generate(string $namespace, string $destinationPath)
2525
$codePrinter = new Standard();
2626
$schemaClassNameMap = [];
2727
foreach ($this->spec->components->schemas as $name => $schema) {
28-
$schemaClassNameMap[spl_object_hash($schema)] = str_replace(['{', '}'], ['Cb', 'Rcb'], (new Convert($name))->toPascal());
28+
$schemaClassName = trim(str_replace(['{', '}'], ['Cb', 'Rcb'], (new Convert($name))->toPascal()));
29+
if (strlen($schemaClassName) === 0) {
30+
continue;
31+
}
32+
$schemaClassNameMap[spl_object_hash($schema)] = $schemaClassName;
2933
}
3034
foreach ($this->spec->components->schemas as $name => $schema) {
31-
$schemaClassName = str_replace(['{', '}'], ['Cb', 'Rcb'], (new Convert($name))->toPascal());
35+
$schemaClassName = $schemaClassNameMap[spl_object_hash($schema)];
3236
@mkdir(dirname($destinationPath . '/Schema/' . $schemaClassName), 0777, true);
3337
file_put_contents($destinationPath . '/Schema/' . $schemaClassName . '.php', $codePrinter->prettyPrintFile([
3438
Schema::generate(

0 commit comments

Comments
 (0)