Browse Source

added some docstring

pull/1/head
Cerys Lewis 1 week ago
parent
commit
fbbddcb1d3
  1. 5
      Examples/ExampleScripts/generateMessageSchema.php
  2. 7
      src/SchemaBuilder/SchemaBuilder.php

5
Examples/ExampleScripts/generateMessageSchema.php

@ -9,7 +9,4 @@ require_once __DIR__ . "/../../Examples/Schemas/Message.php";
use Darksparrow\Deegraph\Examples\SchemaBuilder\Schemas\Message; use Darksparrow\Deegraph\Examples\SchemaBuilder\Schemas\Message;
use Darksparrow\AuxiliumSchemaBuilder\SchemaBuilder\SchemaBuilder; use Darksparrow\AuxiliumSchemaBuilder\SchemaBuilder\SchemaBuilder;
$example = new Message(); SchemaBuilder::RenderSchema(new Message());
$result = SchemaBuilder::GenerateSchema($example);
echo json_encode($result, JSON_PRETTY_PRINT);

7
src/SchemaBuilder/SchemaBuilder.php

@ -116,6 +116,13 @@ class SchemaBuilder
return $schema; 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 #[NoReturn] public static function RenderSchema(object $targetSchema): void
{ {
$result = self::GenerateSchema(new $targetSchema()); $result = self::GenerateSchema(new $targetSchema());

Loading…
Cancel
Save