Skip to content

Required.AllowNull does not mark property as required #402

@basilfx

Description

@basilfx

Describe the issue
According to the documentation, only Required.Always and Required.DisallowNull in a JsonProperty attribute will mark a property as required in the schema.

Required.AllowNull should also mark it as required. The documentation states: "The property must be defined in JSON but can be a null value." It must be present in the JSON, therefore it must be marked as required.

Required.DisallowNull should not mark it as required. The documentation states: "The property is not required but it cannot be a null value." It may be present in the JSON, therefore it should not be marked as required.

To Reproduce
See this demonstration project: https://github.com/basilfx/azure-functions-openapi-function-timespan (yes, same project as #401).

Note how MyInstance.MyNullableTimeSpan has Required = Required.AllowNull, yet it is not marked as required in the schema. As a work-around, add the Required attribute.

Expected behavior
The property is marked as required in the inferred schema.

Screenshots
Schermafbeelding 2022-03-23 om 22 38 54

Environment (please complete the following information, if applicable):

  • OS: macOS
  • Azure Functions v4
  • .NET SDK 6.0.102
  • OpenAPI Extension 1.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions