Skip to content

How to send NULL values? #857

@mcpicoli

Description

@mcpicoli

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...

  • If I omit the value, it is not sent;
  • If I send an integer, it is sent correctly;
  • If I send "null" (without quotes) it is not accepted, "Please enter a number." is shown;
  • If I send "null" (without quotes and changing the type of the field to string), it is sent as the "null" string.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions