knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.7k stars 303 forks source link

How to send NULL values? #857

Open mcpicoli opened 3 months ago

mcpicoli commented 3 months ago

Scribe version

4.34.0

Your question

How do I specify and send a NULL value as a possible input for a field?

For example, one of the parameters of my API accepts an integer or NULL for some user operation:

...something else...
     * @bodyParam user_id_for_verification int User ID for Verification. No-example
...something else...

Content-Type and Accept are both application/json. That is important since if data was sent using URLEncoded values, there wouldn't be this possibility unless (controversially) encoding NULL as %00 as a missing value for an existing parameter would mean "empty string" not NULL.

Sending a NULL value is completely different from omitting the value for the API being documented. A NULL value means "no user_id for verification" (maybe changing it from some previous integer value), omitting it means "do not change the user for verification".

How do I specify that this parameter accepts a valid integer or NULL as valid input?

When the documentation is generated...

Maybe I am missing something obvious?

P.S.: The same question may be extended to "How do I specify and send an empty string value for a field?"

Docs

shalvah commented 3 months ago

There's a PR to add a nullable feature. Does this meet your concerns? https://github.com/knuckleswtf/scribe/pull/834

mcpicoli commented 3 months ago

There's a PR to add a nullable feature. Does this meet your concerns? #834

Only if it is implemented into the HTML docs and Postman collection as well.