diff --git a/Examples/ExampleScripts/generateMessageSchema.php b/Examples/ExampleScripts/generateMessageSchema.php index 7d54e7b..c3287f2 100644 --- a/Examples/ExampleScripts/generateMessageSchema.php +++ b/Examples/ExampleScripts/generateMessageSchema.php @@ -9,7 +9,4 @@ require_once __DIR__ . "/../../Examples/Schemas/Message.php"; use Darksparrow\Deegraph\Examples\SchemaBuilder\Schemas\Message; use Darksparrow\AuxiliumSchemaBuilder\SchemaBuilder\SchemaBuilder; -$example = new Message(); -$result = SchemaBuilder::GenerateSchema($example); - -echo json_encode($result, JSON_PRETTY_PRINT); +SchemaBuilder::RenderSchema(new Message()); diff --git a/src/SchemaBuilder/SchemaBuilder.php b/src/SchemaBuilder/SchemaBuilder.php index fdb66f5..dac19d8 100644 --- a/src/SchemaBuilder/SchemaBuilder.php +++ b/src/SchemaBuilder/SchemaBuilder.php @@ -116,6 +116,13 @@ class SchemaBuilder return $schema; } + /** + * Generates the Schema using the SchemaBuilder::GenerateSchema() function, sets the http header to application/json, echos the schema as JSON, then dies. + * + * @param object $targetSchema The Schema class object to generate from. + * @return void + * @throws SchemaDocumentFieldNameUnsetException + */ #[NoReturn] public static function RenderSchema(object $targetSchema): void { $result = self::GenerateSchema(new $targetSchema());