Base solution for your next web application
Open Closed

How to show Data Annotations (Required) in Swagger UI Doc #4385

banksearch created

Normally, swagger reads the Data Annotations and shows whether the property is required or not in the documentation as below:

"definitions": {
    "TodoItem": {
        "required": [
        "type": "object",
        "properties": {
            "id": {
                "format": "int64",
                "type": "integer"
            "name": {
                "type": "string"
            "isComplete": {
                "default": false,
                "type": "boolean"

But as the web apis are generated dynamically this does not seem to be working.

Even I have the [Required] attribute in some properties, swagger document seems to totally ignores those.

Any idea why?

No answer yet!