Skip to content

Commit

Permalink
[Schema Registry] Update JsonSchemaSerializer Class Name (#29978)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR


### Issues associated with this PR


### Describe the problem that is addressed by this PR
Prepare GA release for schema registry & schema registry Json schema
serializer. Change class name from `JsonSerializer` to
`JsonSchemaSerializer`

Co-authored-by: Maor Leger <maorleger@users.noreply.github.com>
  • Loading branch information
minhanh-phan and maorleger authored Jun 17, 2024
1 parent c16dc86 commit 74b40a2
Show file tree
Hide file tree
Showing 52 changed files with 1,551 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@azure/schema-registry": "1.3.0-beta.2",
"@azure/schema-registry": "1.3.0",
"@azure/schema-registry-avro": "^1.0.0",
"@azure/identity": "^4.0.1",
"@azure-tools/test-perf": "^1.0.0",
Expand Down
10 changes: 3 additions & 7 deletions sdk/schemaregistry/schema-registry-json/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# Release History

## 1.0.0-beta.2 (Unreleased)

### Features Added

### Breaking Changes

### Bugs Fixed
## 1.0.0 (2024-07-09)

### Other Changes

- Update `JsonSerializer` class name to `JsonSchemaSerializer`

## 1.0.0-beta.1 (2023-08-08)

- Initial preview release
6 changes: 3 additions & 3 deletions sdk/schemaregistry/schema-registry-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm install @azure/schema-registry-json

## Key concepts

### JsonSerializer
### JsonSchemaSerializer

Provides API to serialize to and deserialize from JSON wrapped in a message
with a content type field containing the schema ID. Uses
Expand Down Expand Up @@ -63,14 +63,14 @@ adapters for their message types.
const { DefaultAzureCredential } = require("@azure/identity");
const { createEventDataAdapter } = require("@azure/event-hubs");
const { SchemaRegistryClient } = require("@azure/schema-registry");
const { JsonSerializer } = require("@azure/schema-registry-json");
const { JsonSchemaSerializer } = require("@azure/schema-registry-json");

async function main(){
const client = new SchemaRegistryClient(
"<fully qualified namespace>",
new DefaultAzureCredential()
);
const serializer = new JsonSerializer(client, {
const serializer = new JsonSchemaSerializer(client, {
groupName: "<group>",
messageAdapter: createEventDataAdapter(),
});
Expand Down
4 changes: 2 additions & 2 deletions sdk/schemaregistry/schema-registry-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/schema-registry-json",
"version": "1.0.0-beta.2",
"version": "1.0.0",
"description": "Schema Registry JSON Serializer Library with typescript type definitions for node.js and browser.",
"sdk-type": "client",
"main": "dist/index.js",
Expand Down Expand Up @@ -69,7 +69,7 @@
},
"dependencies": {
"@azure/logger": "^1.0.0",
"@azure/schema-registry": "1.3.0-beta.2",
"@azure/schema-registry": "^1.3.0",
"lru-cache": "^10.2.0",
"tslib": "^2.2.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export interface DeserializeOptions {
}

// @public
export class JsonSerializer<MessageT = MessageContent> {
constructor(client: SchemaRegistry, options?: JsonSerializerOptions<MessageT>);
export class JsonSchemaSerializer<MessageT = MessageContent> {
constructor(client: SchemaRegistry, options?: JsonSchemaSerializerOptions<MessageT>);
deserialize(message: MessageT, options?: DeserializeOptions): Promise<unknown>;
serialize(value: unknown, schema: string): Promise<MessageT>;
}

// @public
export interface JsonSerializerOptions<MessageT> {
export interface JsonSchemaSerializerOptions<MessageT> {
groupName?: string;
messageAdapter?: MessageAdapter<MessageT>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry.
* @summary Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry.
*/

import { DefaultAzureCredential } from "@azure/identity";
Expand All @@ -11,7 +11,7 @@ import {
SchemaDescription,
KnownSchemaFormats,
} from "@azure/schema-registry";
import { JsonSerializer } from "@azure/schema-registry-json";
import { JsonSchemaSerializer } from "@azure/schema-registry-json";

// Load the .env file if it exists
import * as dotenv from "dotenv";
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function main() {
await client.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(client, { groupName });
const serializer = new JsonSchemaSerializer(client, { groupName });

// serialize an object that matches the schema and put it in a message
const value: User = { firstName: "Jane", lastName: "Doe" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry with validation using a third party library.
* @summary Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry with validation using a third party library.
*/

import { DefaultAzureCredential } from "@azure/identity";
Expand All @@ -11,7 +11,7 @@ import {
SchemaDescription,
KnownSchemaFormats,
} from "@azure/schema-registry";
import { DeserializeOptions, JsonSerializer } from "@azure/schema-registry-json";
import { DeserializeOptions, JsonSchemaSerializer } from "@azure/schema-registry-json";

import Ajv, { ValidateFunction } from "ajv";
// Load the .env file if it exists
Expand Down Expand Up @@ -69,7 +69,7 @@ export async function main() {
await client.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(client, { groupName });
const serializer = new JsonSchemaSerializer(client, { groupName });

// serialize an object that matches the schema and put it in a message
const value: User = { firstName: "Jane", lastName: "Doe" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Buffered Producer Client.
* @summary Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Buffered Producer Client.
*/

import { DefaultAzureCredential } from "@azure/identity";
import { SchemaRegistryClient, SchemaDescription } from "@azure/schema-registry";
import { JsonSerializer } from "@azure/schema-registry-json";
import { JsonSchemaSerializer } from "@azure/schema-registry-json";
import { EventHubBufferedProducerClient, createEventDataAdapter } from "@azure/event-hubs";

// Load the .env file if it exists
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function main() {
await schemaRegistryClient.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(schemaRegistryClient, {
const serializer = new JsonSchemaSerializer(schemaRegistryClient, {
groupName,
messageAdapter: createEventDataAdapter(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to deserialize messages with json-serialized payload received from the Event Hub Consumer Client.
* @summary Demonstrates the use of JsonSchemaSerializer to deserialize messages with json-serialized payload received from the Event Hub Consumer Client.
*/

import { DefaultAzureCredential } from "@azure/identity";
import { SchemaRegistryClient, SchemaDescription } from "@azure/schema-registry";
import { JsonSerializer } from "@azure/schema-registry-json";
import { JsonSchemaSerializer } from "@azure/schema-registry-json";
import {
EventHubConsumerClient,
earliestEventPosition,
Expand Down Expand Up @@ -71,7 +71,7 @@ export async function main() {
await schemaRegistryClient.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(schemaRegistryClient, {
const serializer = new JsonSchemaSerializer(schemaRegistryClient, {
groupName,
messageAdapter: createEventDataAdapter(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Producer Client.
* @summary Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Producer Client.
*/

import { DefaultAzureCredential } from "@azure/identity";
import { SchemaRegistryClient, SchemaDescription } from "@azure/schema-registry";
import { JsonSerializer } from "@azure/schema-registry-json";
import { JsonSchemaSerializer } from "@azure/schema-registry-json";
import { EventHubProducerClient, createEventDataAdapter } from "@azure/event-hubs";

// Load the .env file if it exists
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function main() {
await schemaRegistryClient.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(schemaRegistryClient, {
const serializer = new JsonSchemaSerializer(schemaRegistryClient, {
groupName,
messageAdapter: createEventDataAdapter(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

These sample programs show how to use the JavaScript client libraries for Azure Schema Registry in some common scenarios.

| **File Name** | **Description** |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [schemaRegistryJsonSample.js][schemaregistryjsonsample] | Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry. |
| [schemaRegistryJsonWithValidation.js][schemaregistryjsonwithvalidation] | Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry with validation using a third party library. |
| [withEventHubsBufferedProducerClient.js][witheventhubsbufferedproducerclient] | Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Buffered Producer Client. |
| [withEventHubsConsumerClient.js][witheventhubsconsumerclient] | Demonstrates the use of JsonSerializer to deserialize messages with json-serialized payload received from the Event Hub Consumer Client. |
| [withEventHubsProducerClient.js][witheventhubsproducerclient] | Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Producer Client. |
| **File Name** | **Description** |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [schemaRegistryJsonSample.js][schemaregistryjsonsample] | Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry. |
| [schemaRegistryJsonWithValidation.js][schemaregistryjsonwithvalidation] | Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry with validation using a third party library. |
| [withEventHubsBufferedProducerClient.js][witheventhubsbufferedproducerclient] | Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Buffered Producer Client. |
| [withEventHubsConsumerClient.js][witheventhubsconsumerclient] | Demonstrates the use of JsonSchemaSerializer to deserialize messages with json-serialized payload received from the Event Hub Consumer Client. |
| [withEventHubsProducerClient.js][witheventhubsproducerclient] | Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Producer Client. |

## Prerequisites

Expand Down Expand Up @@ -55,7 +55,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP
[witheventhubsbufferedproducerclient]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/schemaregistry/schema-registry-json/samples/v1-beta/javascript/withEventHubsBufferedProducerClient.js
[witheventhubsconsumerclient]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/schemaregistry/schema-registry-json/samples/v1-beta/javascript/withEventHubsConsumerClient.js
[witheventhubsproducerclient]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/schemaregistry/schema-registry-json/samples/v1-beta/javascript/withEventHubsProducerClient.js
[apiref]: https://aka.ms/schemaregistryjson-js-api
[apiref]: https://docs.microsoft.com/javascript/api/@azure/schema-registry-json
[freesub]: https://azure.microsoft.com/free/
[createinstance_azureschemaregistryresource]: https://aka.ms/schemaregistry
[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/schemaregistry/schema-registry-json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry.
* @summary Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry.
*/

const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient, KnownSchemaFormats } = require("@azure/schema-registry");
const { JsonSerializer } = require("@azure/schema-registry-json");
const { JsonSchemaSerializer } = require("@azure/schema-registry-json");

// Load the .env file if it exists
require("dotenv").config();
Expand Down Expand Up @@ -52,14 +52,14 @@ async function main() {
// Create a new client
const client = new SchemaRegistryClient(
schemaRegistryFullyQualifiedNamespace,
new DefaultAzureCredential()
new DefaultAzureCredential(),
);

// Register the schema. This would generally have been done somewhere else.
await client.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(client, { groupName });
const serializer = new JsonSchemaSerializer(client, { groupName });

// serialize an object that matches the schema and put it in a message
const value = { firstName: "Jane", lastName: "Doe" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry with validation using a third party library.
* @summary Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry with validation using a third party library.
*/

const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient, KnownSchemaFormats } = require("@azure/schema-registry");
const { JsonSerializer } = require("@azure/schema-registry-json");
const { JsonSchemaSerializer } = require("@azure/schema-registry-json");

const Ajv = require("ajv").default;
// Load the .env file if it exists
Expand Down Expand Up @@ -51,14 +51,14 @@ async function main() {
// Create a new client
const client = new SchemaRegistryClient(
schemaRegistryFullyQualifiedNamespace,
new DefaultAzureCredential()
new DefaultAzureCredential(),
);

// Register the schema. This would generally have been done somewhere else.
await client.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(client, { groupName });
const serializer = new JsonSchemaSerializer(client, { groupName });

// serialize an object that matches the schema and put it in a message
const value = { firstName: "Jane", lastName: "Doe" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT License.

/**
* @summary Demonstrates the use of JsonSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Buffered Producer Client.
* @summary Demonstrates the use of JsonSchemaSerializer to create messages with json-serialized payload using schema from Schema Registry and send them to an Event Hub using the EventHub Buffered Producer Client.
*/

const { DefaultAzureCredential } = require("@azure/identity");
const { SchemaRegistryClient } = require("@azure/schema-registry");
const { JsonSerializer } = require("@azure/schema-registry-json");
const { JsonSchemaSerializer } = require("@azure/schema-registry-json");
const { EventHubBufferedProducerClient, createEventDataAdapter } = require("@azure/event-hubs");

// Load the .env file if it exists
Expand Down Expand Up @@ -60,14 +60,14 @@ async function main() {
// Create a new client
const schemaRegistryClient = new SchemaRegistryClient(
schemaRegistryFullyQualifiedNamespace,
new DefaultAzureCredential()
new DefaultAzureCredential(),
);

// Register the schema. This would generally have been done somewhere else.
await schemaRegistryClient.registerSchema(schemaDescription);

// Create a new serializer backed by the client
const serializer = new JsonSerializer(schemaRegistryClient, {
const serializer = new JsonSchemaSerializer(schemaRegistryClient, {
groupName,
messageAdapter: createEventDataAdapter(),
});
Expand All @@ -77,7 +77,7 @@ async function main() {
eventHubName,
{
onSendEventsErrorHandler: handleError,
}
},
);

// serialize an object that matches the schema
Expand Down
Loading

0 comments on commit 74b40a2

Please sign in to comment.