@@ -29,6 +29,7 @@ protected function configure(): void
29
29
->setDescription ('Convert avsc schema to json schema ' )
30
30
->addArgument ('avscSchema ' , InputArgument::REQUIRED , 'Avsc schema file path ' )
31
31
->addArgument ('jsonSchema ' , InputArgument::REQUIRED , 'Json schema file path ' )
32
+ ->addArgument ('title ' , InputArgument::OPTIONAL , 'Set a specific title for the json schema ' )
32
33
->addOption (
33
34
'noDefaultAsRequired ' ,
34
35
null ,
@@ -40,6 +41,9 @@ protected function configure(): void
40
41
41
42
public function execute (InputInterface $ input , OutputInterface $ output ): ?int
42
43
{
44
+ /** @var string|null $title */
45
+ $ title = $ input ->getArgument ('title ' );
46
+
43
47
/** @var string $avscSchema */
44
48
$ avscSchema = $ input ->getArgument ('avscSchema ' );
45
49
@@ -58,6 +62,12 @@ public function execute(InputInterface $input, OutputInterface $output): ?int
58
62
$ avsc = file_get_contents ($ avscSchema );
59
63
$ json = $ this ->converter ->convert ($ avsc , ['markNoDefaultAsRequired ' => $ noDefaultAsRequired ]);
60
64
65
+ if (null !== $ title ) {
66
+ $ data = json_decode ($ json , true , 512 , JSON_THROW_ON_ERROR );
67
+ $ data ['title ' ] = $ title ;
68
+ $ json = json_encode ($ data , JSON_THROW_ON_ERROR );
69
+ }
70
+
61
71
if (false === file_exists ($ outputDirectory )) {
62
72
mkdir ($ outputDirectory , 0755 , true );
63
73
}
0 commit comments