Tag: jsonschema

将JSON模式转换为CQL(Cassandra)模式

我想将一个JSON对象,如下所示,转换成一个Cassandra模式/表。 举个例子,像这样的东西: { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } } } 像这样的东西: CREATE TABLE IF NOT EXISTS people ( name text PRIMARY KEY, age int); 在Node.js中,使用Datastax Cassandra驱动程序 。 所以本质上:使用Node.js我想创build基于JSON模式的Cassandra表(不必手动创build表,但有节点parsingJSON对象并构build用于创buildCassandra表的脚本)。

AJVvalidation:数据path不一致

我有一个像这样的AJV模式: // schema.js module.exports = { title: 'task', description: 'A Task Schema', type: 'object', properties: { object_city: { title: 'City', type:'string' }, object_zip: { title: 'Zip Code', type: 'string', maxLength: 5, minLength: 5 } }, required: ['object_zip', 'object_city'], additionalProperties: false }; 当我对这个模式运行我的validationtesting时,丢失object_city的结果是: { keyword: 'required', dataPath: '', schemaPath: '#/required', params: { missingProperty: 'object_city' }, message: […]

在Node.js中基于xml架构构buildxml

在Node.js中有没有简单的方法来创build基于XML模式的XML? 目前我看到像xmlbuilder这样的模块,它帮助从头创buildXML(不遵循模式)。 我想要高水平的,基于XML模式/ XSD这将有助于创buildXML。 就像POJO是基于XSD创build的,现在很容易填充POJO,然后创buildXML。 感谢任何提示…

如何创buildtypes为string或null的JSON模式属性

我的模式看起来像这样: schema: { type: 'object', properties: { id: { type: 'string' } } } 我想被允许设置string或null,我该怎么做?

NodeJS JSON模式validation不起作用

我是JSON Schema Validator的完全新手,但我认为它非常强大。 但是,我只是无法validation一个JSON。 这是我的模式 { title: "Example Schema", type: "object", properties: { original_image:{ type: "object", properties: { temp_id: {type: "string"}, url: {type: "string"}, scale:{ type: "object", properties:{ new_width: {type: "number"}, new_height: {type: "number"} }, required:["new_width","new_height"] } }, required:["url","temp_id","scale"] } }, required:["image"] } 这是实际的JSON: { "original_image": { "temp_id": "this is my id", "scale": { "new_width": […]

Json Schema:validation数组

我试图validation包含两个键, tags和parameters的模式,这些键是用于任意键值对的数组。 出于某种原因,但我无法得到任何我指定这两个键validation失败(我使用nodejs库ajv )。 这是模式定义: var cfStackSchema = { name: { type: "string" }, application: { type: "string" }, account: { type: "string" }, environment: { type: "string" }, tags: { type: "array", items: { type: "object", patternProperties: { "^[a-zA-z0-9]$": { type: "string" } }, additionalProperties: false }, additionalItems: false }, parameters: { type: "array", […]

与邮差的jsonschema

我用node.js和express.js做了一个简单的web api,我想validation将json数据input到我的应用程序的模式。 我有这个非常确切的模式: var schema = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Student", "description": "Schema for student", "type": "object", "properties": { "first_name": { "description": "Firts name of the student", "type": "string" }, "last_name": { "description": "Last name of the student", "type": "string" } }, "additionalProperties": false, "required": ["first_name", "last_name"] }; 我只想validation(现在)的名字和姓氏。 所以我添加了“additionalProperties”,所以只有名字和姓氏的json才是有效的。 当我用POSTMANtesting我的应用程序与以下数据时,我得到了很多错误。 (这应该是有效的) {"first_name":"Test", "last_name":"Test"} 这应该是无效的: […]

JSON模式:引用本地子模式

我想引用父JSON模式中的子模式。 这是名为child.json的子模式 { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Child", "description": "Child schema", "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "integer"} }} 这里是名为parent.json的父模式,并且所有这两个文件都在同一个文件夹中。 我想引用子模式,我这样做: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Parent", "description": "Parent schema", "type": "object", "properties": { "allOf": [ { "$ref": "file://child.json" } ], "adresse": {"type": "string"} }} 我有一个错误,说没有find文件child.json。 我已经testing了很多,但是任何人都在工作。 谢谢你的帮助

JSON模式:date大于其他

我有这样的JSON模式: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Operation", "description": "The schema of an operation", "type": "object", "properties": { "id":{ "description": "Unique identifier of the service", "type": "string" }, "description":{ "type": "string" }, "dateDebut":{ "type": "string", "format": "date-time" }, "dateFin":{ "type": "string", "format": "date-time" } } } 我怎样才能在我的模式中说dateFin必须大于dateDebut ?

如何将JSON模式转换为mongoose模式

有没有办法像下面那样采用有效的JSON模式,并把它变成mongoose模式? { "$schema": "http://json-schema.org/draft-04/schema#", "description": "some desc", "title": "Product", "type": "object", "properties": { "endpoints": { "type": "array", "items": { "type": "string" } }, "poi": { "type": "array", "items": { "type": "object", "properties": { "location_name": { "type": "string" }, "distance": { "type": "string" } } } } } } 这对我来说似乎是如此基本和简单,但我还没有在网上find任何东西。 有很多关于如何获取JSON模式的例子,并且有大量的例子来说明如何从这样的对象中创buildmongoose模式: const newSchema = new mongoose.Schema({ […]