Skip to content

Provide an option for a field to be hidden from the documentation while still being validated #747

Open
@sherzinger

Description

@sherzinger

Hi,

Let's say we have a field description like this:

fieldWithPath("foo")
          .type(JsonFieldType.STRING)
          .description("some description")

If the returned value is "foo": null, then an exception is being thrown because null is not considered a STRING.
In such cases, we can mark the field as .optional(), signalling that a String may be provided, but can also be null.

The problem I noticed is that .ignored() also gets rid of this exception. IMHO that shouldn't happen, because the returned value (null) still violates the field description. In other words: the value is still optional, and hiding it from the docs does not change that fact.

In short, for a nullable field "foo", which should not be included in the docs, I'd expect this syntax:

fieldWithPath("foo")
          .ignored()
          .optional()
          .type(JsonFieldType.STRING)
          .description("some description")

Of course all of the above is a matter of how we interpret what it means for a description to be ignored.
If the above is expected behavior, maybe it would make sense to split "hiding from docs" and "ignoring type" into separate fields, so we can do this fieldWithPath("foo").hide().optional() (hide, but still validate) ?

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