Skip to content

Support STJ's JsonRequired attribute #5254

@markphillips100

Description

@markphillips100

Is your feature request related to a problem? Please describe.

Currently the System.ComponentModel.DataAnnotations.Required is generated for required properties. This is not recognized by the STJ deserializer and so no JsonException is thrown when a required property does not exist in json data.

Describe the solution you'd like

I'd like the JsonRequiredAttribute added to required properties so that an exception is thrown. That, or insert the required keyword in the property itself, either work the same for STJ during deserialization.

Describe alternatives you've considered

Hoped the standard data annotation would suffice but alas no.

Additional context

I'm using Refitter to generate the clients from an openapi v3 spec. This uses NSwag, but I have a feeling this requires a change to NJsonSchema at a template level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions