Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

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


User avatar
0
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": [
            "name"
        ],
        "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!