Skip to content

Conversation

@DerManoMann
Copy link
Collaborator

Related to #1668

@bfanger
Copy link
Collaborator

bfanger commented Dec 30, 2025

imo: If you document it inside PHP as empty string, the swagger-php output should be an empty string.

@DerManoMann
Copy link
Collaborator Author

It's a tricky one IMO. The attribute should be the authority, so explicitly passing in null should override the docblock.

The original issue was explicitly about hiding the docblock description - which works for annotations. Maybe it's time to give up feature parity and move on and require an empty string in the attribute, so it can be distinguished from the default of null which does allow fallback to the docblock.

@bfanger
Copy link
Collaborator

bfanger commented Dec 31, 2025

I agree that the attribute should be the authority and that we need a way to say "don't use the text from the docblock"

But the change in AbstractAnnotation.php affects all properties, not just the description.

When defining

#[OAT\Schema(
  schema: "emptystring",
  default: '',
)

I'd like the "default": "", to be in the generated json output.

Wouldn't updating the description in the attribute classes to:

?string $description = Generator::UNDEFINED,

solve the issue?

@DerManoMann
Copy link
Collaborator Author

I know that the PR is not that great. Also, just using Generator::UNDEFINED would work in this case, but I feel either it should be used everywhere as default (instead of the current null) or not at all.

I'd love to avoid having to use it as it stops using proper type-hints, whereas something like ?bool seems reasonable (as opposed to bool|string).

Still looking for a solution that would work with null as a default value for all constructor arguments but I think PHP just cannot do that.

@DerManoMann
Copy link
Collaborator Author

Maybe I am overthinking this. Also this is really just an issue for string values that may fallback to phpdoc strings if not provided, so in reality it is limited to title/description/summary, iirc. Since those are string anyway, maybe special handling could be limited to those 3 parameters in attributes.

@bfanger
Copy link
Collaborator

bfanger commented Jan 1, 2026

Agree, we want proper type hints, adding the string type would cause confusion.
Special-casing the title/description/summary would work, i'd prefer using the Generator::UNDEFINED default-value hack and setting the value to null to mean omit, but adding a "" case for these properties is also fine. or both.

@DerManoMann
Copy link
Collaborator Author

Closing in favour of #1886

@DerManoMann DerManoMann closed this Jan 1, 2026
@DerManoMann DerManoMann deleted the string-empty-string-ommit branch January 1, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants