@azure/schema-registry-json 1.0.0-alpha.20230809.1 → 1.0.0-alpha.20230831.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -29
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -65,39 +65,46 @@ const { createEventDataAdapter } = require("@azure/event-hubs");
|
|
|
65
65
|
const { SchemaRegistryClient } = require("@azure/schema-registry");
|
|
66
66
|
const { JsonSerializer } = require("@azure/schema-registry-json");
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
68
|
+
async function main(){
|
|
69
|
+
const client = new SchemaRegistryClient(
|
|
70
|
+
"<fully qualified namespace>",
|
|
71
|
+
new DefaultAzureCredential()
|
|
72
|
+
);
|
|
73
|
+
const serializer = new JsonSerializer(client, {
|
|
74
|
+
groupName: "<group>",
|
|
75
|
+
messageAdapter: createEventDataAdapter(),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Example Json schema
|
|
79
|
+
const schema = JSON.stringify({
|
|
80
|
+
$schema: "http://json-schema.org/draft-04/schema#",
|
|
81
|
+
$id: "person",
|
|
82
|
+
title: "Student",
|
|
83
|
+
description: "A student in the class",
|
|
84
|
+
type: "object",
|
|
85
|
+
properties: {
|
|
86
|
+
name: {
|
|
87
|
+
type: "string",
|
|
88
|
+
description: "The name of the student",
|
|
89
|
+
},
|
|
88
90
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
91
|
+
required: ["name"]
|
|
92
|
+
});
|
|
92
93
|
|
|
93
|
-
// Example value that matches the Json schema above
|
|
94
|
-
const value = { name: "Bob" };
|
|
94
|
+
// Example value that matches the Json schema above
|
|
95
|
+
const value = { name: "Bob" };
|
|
95
96
|
|
|
96
|
-
// Serialize value to a message
|
|
97
|
-
const message = await serializer.serialize(value, schema);
|
|
97
|
+
// Serialize value to a message
|
|
98
|
+
const message = await serializer.serialize(value, schema);
|
|
99
|
+
|
|
100
|
+
// Deserialize a message to value
|
|
101
|
+
const deserializedValue = await serializer.deserialize(message);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
main().catch((err) => {
|
|
105
|
+
console.error("The sample encountered an error:", err);
|
|
106
|
+
});
|
|
98
107
|
|
|
99
|
-
// Deserialize a message to value
|
|
100
|
-
const deserializedValue = await serializer.deserialize(message);
|
|
101
108
|
```
|
|
102
109
|
|
|
103
110
|
The serializer doesn't check whether the deserialized value matches the schema
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/schema-registry-json",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.20230831.2",
|
|
4
4
|
"description": "Schema Registry JSON Serializer Library with typescript type definitions for node.js and browser.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"@microsoft/api-extractor": "^7.31.1",
|
|
85
85
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
86
86
|
"@rollup/plugin-inject": "^5.0.0",
|
|
87
|
-
"@types/ajv": "^1.0.0",
|
|
88
87
|
"@types/mocha": "^7.0.2",
|
|
89
88
|
"@types/node": "^16.0.0",
|
|
90
89
|
"ajv": "^8.12.0",
|
|
@@ -110,6 +109,7 @@
|
|
|
110
109
|
"rimraf": "^3.0.0",
|
|
111
110
|
"rollup": "^2.0.0",
|
|
112
111
|
"source-map-support": "^0.5.9",
|
|
113
|
-
"typescript": "~5.0.0"
|
|
112
|
+
"typescript": "~5.0.0",
|
|
113
|
+
"ts-node": "^10.0.0"
|
|
114
114
|
}
|
|
115
115
|
}
|