File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -322,6 +322,27 @@ This is what the underlying JSON-Schema looks like:
322322
323323
324324
325+ Optional slots and null
326+ ^^^^^^^^^^^^^^^^^^^^^^^
327+
328+ By default, optional (non-required) slots accept an explicit JSON ``null `` in
329+ addition to their base type — the generator emits ``"type": ["string", "null"] ``
330+ for an optional string slot. This is convenient for producers that serialise
331+ missing values as ``null ``.
332+
333+ Some target schemas forbid explicit ``null `` on optional properties (a property
334+ must either be present with a typed value or absent). Use
335+ ``--no-include-null `` to restrict optional slots to their base type:
336+
337+ .. code :: bash
338+
339+ gen-json-schema --no-include-null personinfo.yaml
340+
341+ With ``--no-include-null `` the optional string slot above is emitted as
342+ ``"type": "string" ``, so instance documents carrying ``"slot": null `` fail
343+ validation. The default (``--include-null ``) preserves the previous behaviour.
344+
345+
325346Patterns
326347^^^^^^^^
327348
You can’t perform that action at this time.
0 commit comments