How to specify a "year" field in openapi v3 / swagger?

Viewed 70

I want to define an API using openAPI v3. One of an object's properties will be a year. My current definition looks like this:

"fieldname": {
    "type": "string",
    "format": "date",
    "pattern": "\d\d\d\d"
}

Is this a valid description? Or is there a predefined or better fitting description of such fields?

What is the most precise and semantically valuable, yet correct way to specify such properties?

0 Answers
Related