Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
It's possible this is a Microsoft.OpenApi issue, but I figured I'd start here.
Upgrading an application with an OpenAPI document from ASP.NET Core 9 to ASP.NET Core 10 preview 1, the examples in the returned JSON (or YAML) document are being rendered with string properties that happen to parse as a DateTimeOffset
being rendered as such, rather than the original string representation.
It seems that something somewhere sees the string will parse as a DateTimeOffset
, converts it, and then subsequently it is formatted as such, changing the string's value.
As far as I can tell, my OpenAPI extensions are rendering the examples as strings correctly when assigned to the Example
property on the relevant OpenAPI primitive.
The relevant snippet from the OpenAPI schema is:
"TimeResponse": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"description": "The timestamp for the response for which the times are generated.",
"format": "date-time"
},
"rfc1123": {
"type": "string",
"description": "The current UTC date and time in RFC1123 format."
},
"unix": {
"type": "integer",
"description": "The number of seconds since the UNIX epoch.",
"format": "int64"
},
"universalSortable": {
"type": "string",
"description": "The current UTC date and time in universal sortable format."
},
"universalFull": {
"type": "string",
"description": "The current UTC date and time in universal full format."
}
},
"description": "Represents the response from the /time API resource.",
"example": {
"timestamp": "2016-06-03T18:44:14.0000000+00:00",
"rfc1123": "2016-06-03T18:44:14.0000000+00:00",
"unix": 1464979454,
"universalSortable": "2016-06-03T18:44:14.0000000+00:00",
"universalFull": "2016-06-03T18:44:14.0000000+01:00"
}
}
rfc1123
, universalSortable
and universalFull
are all being rendered the same as timestamp
when they should be rendered in different string formats.
Expected Behavior
String properties that are not explicitly typed as the format: date-time
are not coerced to a different type.
Steps To Reproduce
- Clone martincostello/api@a5135f4
- Run
build.ps1
from the root of the repository.
Exceptions (if any)
The Json_Schema_Is_Correct
and Yaml_Schema_Is_Correct
tests fail.
.NET Version
10.0.100-preview.1.25120.13
Anything else?
No.