Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute behaves differently than annotation in case of DocBlockDescriptions #1668

Open
kminek opened this issue Oct 27, 2024 · 6 comments
Open

Comments

@kminek
Copy link

kminek commented Oct 27, 2024

This works:

@OA\Schema(type="string", description=null)

this dont:

`#[OA\Schema(type: 'string', description:null)]`
@DerManoMann
Copy link
Collaborator

A bit more detail might be good. 'doesn't work's could be anything...

Best guess is you are facing this issue: https://zircote.github.io/swagger-php/guide/faq.html#warning-required-oa-info-not-found

@kminek
Copy link
Author

kminek commented Oct 28, 2024

@DerManoMann right. here is my use case. i have a enum class annotated with attribute:


/**
 * Some docblock that should not be exposed in API docs.
 */
#[OA\Schema(type: 'string')]
enum Language: string
{
...
}

When API docs are generated, also enum class docblock is parsed and included in generated docs. However as this docblock contains internal info which should not be exposed i tried to set description to null:

/**
 * Some docblock that should not be exposed in API docs.
 */
#[OA\Schema(type: 'string', description: null)]
enum Language: string
{
...
}

But still the docblock is included in API docs.

@DerManoMann
Copy link
Collaborator

Ah, yes, sorry. Was reading this on my phone and didn't scroll right :/

The attributes do not use Generator::UNDEFINED, so null is not really considered a valid value. Have you tried an empty string? Not sure of the top of my head how the code evaluates whether a string is set or not.
I suppose an ugly 'fix' would be to set the value to Generator::UNDEFINED, although that does not look very nice :{

@DerManoMann
Copy link
Collaborator

I wonder if for attributes all properties typed ?string could treat empty string the same as null... hmmm

@kminek
Copy link
Author

kminek commented Nov 19, 2024

I wonder if for attributes all properties typed ?string could treat empty string the same as null... hmmm

dont really know the internals of this library but as a library consumer i would expect same behavior no matter what "annotating interface" i am using

@DerManoMann
Copy link
Collaborator

Fair enough - will do some more digging then ;)

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

No branches or pull requests

2 participants