我有这样的架构:
"foo": {"type": "string", "format": "time"}
我试过new (new Date()).toISOString()
它有这种格式:
"2018-06-12T08:59:01.135Z"
错误:
jsonschema.exceptions.ValidationError: '2018-06-12T08:59:01.135Z' is not a 'time'
答案 0 :(得分:1)
{ "format": "time" }
使用RFC-3339第5.6节“Internet日期/时间格式”。
http://json-schema.org/latest/json-schema-validation.html#rfc.section.7.3.1 https://tools.ietf.org/html/rfc3339#section-5.6
答案 1 :(得分:0)
您可以转换日期"../../node_modules/@types"
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"typeRoots": [
"../../node_modules/@types"
],
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "server",
"baseUrl": "."
},
"include": [
"src/**/*"
]
}