Skip to content

Support the required keyword in the same way as RequiredAttribute #2764

@AntiGuideAkquinet

Description

@AntiGuideAkquinet

When using .NETs required keyword, the properties that it is used on do not get marked as required in SwaggerGen. I set up a project to reproduce the issue. When adding the RequiredAttribute to the property, the result changes to the expected behavior.

I assume that this line could fix the problem if it checked for RequiredMemberAttribute too.

Thank you for investigating!

Version: 6.5.0
C# 11/.NET 7 and up
SwashbuckleReproduction.zip

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