Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/examples/specs/petstore/annotations/Models/Pet.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
class Pet
{
/**
* The description.
*
* @OA\Property(
* format="int64",
* description="ID",
* description="",
* title="ID",
* )
*
Expand Down
5 changes: 4 additions & 1 deletion docs/examples/specs/petstore/attributes/Models/Pet.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
)]
class Pet
{
/**
* The description.
*/
#[OAT\Property(
description: 'ID',
description: '',
title: 'ID',
format: 'int64'
)]
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/specs/petstore/petstore-3.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ components:
properties:
id:
title: ID
description: ID
description: ''
type: integer
format: int64
category:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/specs/petstore/petstore-3.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ components:
properties:
id:
title: ID
description: ID
description: ''
type: integer
format: int64
category:
Expand Down
11 changes: 11 additions & 0 deletions docs/guide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,14 @@ The reason for this is that `openapi` currently uses the [`error_log`](https://w
function for all output.

So if this is configured to write to a file, then it will seem like the command is broken.

## How to force overriding `swagger-php` augmentation

There are number of processors that will try to 'enhance' the generated spec by adding additional details.

This can be looking at PHP typehints, PHP docblocks for summary/description and other things. Usually this is fine; however,
there might be times, where this is not desirable.

For `string` based properties, the empty string `''` can be used to force ommission of a property, even if a `swagger-php` processor
would have found a way to add a default value to this property.
This can be useful, for example, for summary and description fields.
2 changes: 1 addition & 1 deletion src/Annotations/AbstractAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function jsonSerialize()

// Strip undefined values.
foreach (get_object_vars($this) as $property => $value) {
if (!Generator::isDefault($value)) {
if (!Generator::isDefault($value) || '' === $value) {
$data->{$property} = $value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Processors/DocBlockDescriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Checks if the annotation has a summary and/or description property
* and uses the text in the comment block (above the annotations) as summary and/or description.
*
* Use <code>null</code>, for example: <code>@Annotation(description=null)</code>, if you don't want the annotation to have a description.
* Use <code>''</code>, for example: <code>@Annotation(description="")</code>, if you don't want the annotation to have a description.
*/
class DocBlockDescriptions
{
Expand Down