Skip to content

Commit

Permalink
feat(OpenAPISpecWriter): add description to schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna.yu committed Oct 1, 2024
1 parent e6e014c commit db0d315
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Writing/OpenAPISpecWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,13 @@ public function generateSchemaForValue(mixed $value, OutputEndpointData $endpoin
$properties[$subField] = $this->generateSchemaForValue($subValue, $endpoint, $subFieldPath);
}

return [
$schema = [
'type' => 'object',
'properties' => $this->objectIfEmpty($properties),
];
$this->setDescription($schema, $endpoint, $path);

return $schema;
}

$schema = [
Expand All @@ -615,6 +618,9 @@ public function generateSchemaForValue(mixed $value, OutputEndpointData $endpoin
return $schema;
}

/**
* Set the description for the schema. If the field has a description, it is set in the schema.
*/
private function setDescription(array &$schema, OutputEndpointData $endpoint, string $path): void
{
if (isset($endpoint->responseFields[$path]->description)) {
Expand Down

0 comments on commit db0d315

Please sign in to comment.