common-date-fields-semantics
Requires date-like properties in component schemas to use a string date or date-time format.
| Attribute | Value |
|---|---|
| Category | Schema |
| Maturity | Gold |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter | Off |
| Lenient–Strict | Warning |
| Complete | Error |
Intent
Explicit standard formats make date values unambiguous and usable by generators and validators.
Flags
A property under components.schemas when its lowercase name contains date, ends in _at, or is one of these common names: createdAt, modifiedAt, or updatedAt. It is reported unless it has type: string and format: date or date-time.
Does not flag
Correctly formatted date-like properties, unrelated property names, or schemas outside components.schemas.
See it fail
components:
schemas:
Payment:
type: object
properties:
createdAt:
type: string
Diagnostic: Date-like properties should use string format `date` or `date-time`.
Fix it
components:
schemas:
Payment:
type: object
properties:
createdAt:
type: string
format: date-time
Use date for calendar dates and date-time when time is part of the value.
Configure
profiles:
default:
rules:
extends: [recommended]
override:
common-date-fields-semantics: error
Nearby: string-schema-format-required.