Skip to content

Commit

Permalink
api_documentation: Display null data type if potential value.
Browse files Browse the repository at this point in the history
If null is a potential value of data type for a return value or
parameter in the API endpoint, then it is rendered as an option.

This currently relies on the 'nullable' setting in the OpenAPI spec
that was removed in the 3.1.0 release. If/when the OpenAPI version
is updated, then how the `data_type` for parameters and return values
is rendered will need to be reworked.

Fixes #20264.
  • Loading branch information
laurynmm authored and timabbott committed Nov 17, 2021
1 parent e7b9173 commit 5300ad8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zerver/lib/markdown/api_arguments_table_generator.py
Expand Up @@ -191,4 +191,6 @@ def generate_data_type(schema: Mapping[str, Any]) -> str:
data_type = "(" + generate_data_type(schema["items"]) + ")[]"
else:
data_type = schema["type"]
if "nullable" in schema and schema["nullable"]:
data_type = data_type + " | null"
return data_type

0 comments on commit 5300ad8

Please sign in to comment.