From a5b6c789141974b931b54bd072a6dce11bef59c1 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 28 Sep 2021 00:06:10 +0000 Subject: [PATCH 1/7] [Schema Registry] Rename definition to schemaDefinition --- .../samples-dev/schemaRegistryAvroSample.ts | 2 +- .../samples/v1/javascript/package.json | 4 ++-- .../v1/javascript/schemaRegistryAvroSample.js | 10 +++++----- .../samples/v1/typescript/package.json | 4 ++-- .../typescript/src/schemaRegistryAvroSample.ts | 12 ++++++------ .../src/schemaRegistryAvroSerializer.ts | 10 +++++----- .../test/schemaRegistryAvroSerializer.spec.ts | 2 +- .../test/utils/mockedRegistryClient.ts | 8 ++++---- .../test/utils/mockedSerializer.ts | 2 +- sdk/schemaregistry/schema-registry/CHANGELOG.md | 2 +- .../review/schema-registry.api.md | 4 ++-- .../samples-dev/schemaRegistrySample.ts | 4 ++-- .../v1/javascript/schemaRegistrySample.js | 4 ++-- .../v1/typescript/src/schemaRegistrySample.ts | 4 ++-- .../schema-registry/src/conversions.ts | 2 +- .../schema-registry/src/models.ts | 4 ++-- .../schema-registry/src/schemaRegistryClient.ts | 10 ++++++++-- .../test/public/schemaRegistry.spec.ts | 17 ++++++++++------- 18 files changed, 57 insertions(+), 48 deletions(-) diff --git a/sdk/schemaregistry/schema-registry-avro/samples-dev/schemaRegistryAvroSample.ts b/sdk/schemaregistry/schema-registry-avro/samples-dev/schemaRegistryAvroSample.ts index 98ad0d934251..3dafe4dd173f 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples-dev/schemaRegistryAvroSample.ts +++ b/sdk/schemaregistry/schema-registry-avro/samples-dev/schemaRegistryAvroSample.ts @@ -47,7 +47,7 @@ const schemaDescription: SchemaDescription = { name: `${schemaObject.namespace}.${schemaObject.name}`, groupName, format: "avro", - definition: schema + schemaDefinition: schema }; export async function main() { diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json index 33194b261075..992dd5421d08 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json @@ -25,7 +25,7 @@ "dependencies": { "@azure/schema-registry-avro": "next", "dotenv": "latest", - "@azure/identity": "2.0.0-beta.5", - "@azure/schema-registry": "1.0.0-beta.2" + "@azure/identity": "2.0.0-beta.6", + "@azure/schema-registry": "1.0.0-beta.3" } } diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js index 5722310b5a1d..c7187d44c60b 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js @@ -15,7 +15,7 @@ dotenv.config(); // Set these environment variables or edit the following values const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; -const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; +const groupName = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names const schemaObject = { @@ -39,9 +39,9 @@ const schema = JSON.stringify(schemaObject); // Description of the schema for registration const schemaDescription = { name: `${schemaObject.namespace}.${schemaObject.name}`, - group, - serializationType: "avro", - content: schema + groupName, + format: "avro", + schemaDefinition: schema }; async function main() { @@ -54,7 +54,7 @@ async function main() { await client.registerSchema(schemaDescription); // Create a new serializer backed by the client - const serializer = new SchemaRegistryAvroSerializer(client, group); + const serializer = new SchemaRegistryAvroSerializer(client, groupName); // serialize an object that matches the schema const value = { firstName: "Jane", lastName: "Doe" }; diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json index 68e0b8118c99..6e3c83a8bac8 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json @@ -29,8 +29,8 @@ "dependencies": { "@azure/schema-registry-avro": "next", "dotenv": "latest", - "@azure/identity": "2.0.0-beta.5", - "@azure/schema-registry": "1.0.0-beta.2" + "@azure/identity": "2.0.0-beta.6", + "@azure/schema-registry": "1.0.0-beta.3" }, "devDependencies": { "typescript": "~4.2.0", diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts index 6a0f9eeb49a3..3dafe4dd173f 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts @@ -15,7 +15,7 @@ dotenv.config(); // Set these environment variables or edit the following values const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; -const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; +const groupName = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names const schemaObject = { @@ -45,9 +45,9 @@ const schema = JSON.stringify(schemaObject); // Description of the schema for registration const schemaDescription: SchemaDescription = { name: `${schemaObject.namespace}.${schemaObject.name}`, - group, - serializationType: "avro", - content: schema + groupName, + format: "avro", + schemaDefinition: schema }; export async function main() { @@ -60,7 +60,7 @@ export async function main() { await client.registerSchema(schemaDescription); // Create a new serializer backed by the client - const serializer = new SchemaRegistryAvroSerializer(client, group); + const serializer = new SchemaRegistryAvroSerializer(client, groupName); // serialize an object that matches the schema const value: User = { firstName: "Jane", lastName: "Doe" }; @@ -69,7 +69,7 @@ export async function main() { console.log(buffer); // deserialize the result back to an object - const deserializedValue = await serializer.deserialize(buffer); + const deserializedValue = (await serializer.deserialize(buffer)) as User; console.log("Deserialized:"); console.log(`${deserializedValue.firstName} ${deserializedValue.lastName}`); } diff --git a/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts b/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts index 831930f1634d..9090573f34d1 100644 --- a/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts +++ b/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { SchemaRegistry } from "@azure/schema-registry"; +import { SchemaDescription, SchemaRegistry } from "@azure/schema-registry"; import * as avro from "avsc"; import { toUint8Array } from "./utils/buffer"; @@ -175,8 +175,8 @@ export class SchemaRegistryAvroSerializer { ); } - const avroType = this.getAvroTypeForSchema(schemaResponse.definition); - return this.cache(schemaId, schemaResponse.definition, avroType); + const avroType = this.getAvroTypeForSchema(schemaResponse.schemaDefinition); + return this.cache(schemaId, schemaResponse.schemaDefinition, avroType); } private async getSchemaByContent(schema: string): Promise { @@ -190,11 +190,11 @@ export class SchemaRegistryAvroSerializer { throw new Error("Schema must have a name."); } - const description = { + const description: SchemaDescription = { groupName: this.schemaGroup, name: avroType.name, format: "avro", - definition: schema + schemaDefinition: schema }; let id: string; diff --git a/sdk/schemaregistry/schema-registry-avro/test/schemaRegistryAvroSerializer.spec.ts b/sdk/schemaregistry/schema-registry-avro/test/schemaRegistryAvroSerializer.spec.ts index 5212248e97b8..65b03eb6db60 100644 --- a/sdk/schemaregistry/schema-registry-avro/test/schemaRegistryAvroSerializer.spec.ts +++ b/sdk/schemaregistry/schema-registry-avro/test/schemaRegistryAvroSerializer.spec.ts @@ -33,7 +33,7 @@ describe("SchemaRegistryAvroSerializer", function() { const serializer = await createTestSerializer(false, registry); const schema = await registry.registerSchema({ name: "_", - definition: "_", + schemaDefinition: "_", format: "NotAvro", groupName: testGroup }); diff --git a/sdk/schemaregistry/schema-registry-avro/test/utils/mockedRegistryClient.ts b/sdk/schemaregistry/schema-registry-avro/test/utils/mockedRegistryClient.ts index 813447bb4c3b..c5d29066d9a9 100644 --- a/sdk/schemaregistry/schema-registry-avro/test/utils/mockedRegistryClient.ts +++ b/sdk/schemaregistry/schema-registry-avro/test/utils/mockedRegistryClient.ts @@ -35,15 +35,15 @@ export function createTestRegistry(neverLive = false): SchemaRegistry { schema: SchemaDescription, _options?: RegisterSchemaOptions ): Promise { - let result = mapByContent.get(schema.definition); + let result = mapByContent.get(schema.schemaDefinition); if (!result) { result = { id: newId(), - definition: schema.definition, + schemaDefinition: schema.schemaDefinition, version: 1, format: schema.format }; - mapByContent.set(result.definition, result); + mapByContent.set(result.schemaDefinition, result); mapById.set(result.id, result); } return result; @@ -62,7 +62,7 @@ export function createTestRegistry(neverLive = false): SchemaRegistry { schema: SchemaDescription, _options?: GetSchemaPropertiesOptions ): Promise { - return mapByContent.get(schema.definition); + return mapByContent.get(schema.schemaDefinition); } async function getSchema(id: string, _options?: GetSchemaOptions): Promise { diff --git a/sdk/schemaregistry/schema-registry-avro/test/utils/mockedSerializer.ts b/sdk/schemaregistry/schema-registry-avro/test/utils/mockedSerializer.ts index 03ae167ba015..0882d8704238 100644 --- a/sdk/schemaregistry/schema-registry-avro/test/utils/mockedSerializer.ts +++ b/sdk/schemaregistry/schema-registry-avro/test/utils/mockedSerializer.ts @@ -20,7 +20,7 @@ export async function registerTestSchema(registry: SchemaRegistry): Promise { return this.client.schema - .register(schema.groupName, schema.name, schema.format, schema.definition, options) + .register(schema.groupName, schema.name, schema.format, schema.schemaDefinition, options) .then(convertSchemaIdResponse); } @@ -97,7 +97,13 @@ export class SchemaRegistryClient implements SchemaRegistry { options?: GetSchemaPropertiesOptions ): Promise { return this.client.schema - .queryIdByContent(schema.groupName, schema.name, schema.format, schema.definition, options) + .queryIdByContent( + schema.groupName, + schema.name, + schema.format, + schema.schemaDefinition, + options + ) .then(convertSchemaIdResponse); } diff --git a/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts b/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts index b0cca118d3a1..54023a7cb098 100644 --- a/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts +++ b/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts @@ -47,7 +47,7 @@ describe("SchemaRegistryClient", function() { name: "azsdk_js_test", groupName: env.SCHEMA_REGISTRY_GROUP, format: "avro", - definition: JSON.stringify({ + schemaDefinition: JSON.stringify({ type: "record", name: "User", namespace: "com.azure.schemaregistry.samples", @@ -80,7 +80,7 @@ describe("SchemaRegistryClient", function() { it("rejects schema registration with invalid args", async () => { await assert.isRejected(client.registerSchema({ ...schema, name: null! }), /null/); await assert.isRejected(client.registerSchema({ ...schema, groupName: null! }), /null/); - await assert.isRejected(client.registerSchema({ ...schema, definition: null! }), /null/); + await assert.isRejected(client.registerSchema({ ...schema, schemaDefinition: null! }), /null/); await assert.isRejected(client.registerSchema({ ...schema, format: null! }), /null/); await assert.isRejected(client.registerSchema({ ...schema, format: "not-valid" }), /not-valid/); }); @@ -93,7 +93,10 @@ describe("SchemaRegistryClient", function() { it("fails to get schema ID when given invalid args", async () => { await assert.isRejected(client.getSchemaProperties({ ...schema, name: null! }), /null/); await assert.isRejected(client.getSchemaProperties({ ...schema, groupName: null! }), /null/); - await assert.isRejected(client.getSchemaProperties({ ...schema, definition: null! }), /null/); + await assert.isRejected( + client.getSchemaProperties({ ...schema, schemaDefinition: null! }), + /null/ + ); await assert.isRejected(client.getSchemaProperties({ ...schema, format: null! }), /null/); await assert.isRejected( client.getSchemaProperties({ ...schema, format: "not-valid" }), @@ -129,7 +132,7 @@ describe("SchemaRegistryClient", function() { const found = await client.getSchema(registered.id, options); assertIsValidSchemaId(found); - assert.equal(found.definition, schema.definition); + assert.equal(found.schemaDefinition, schema.schemaDefinition); }); it("schema with whitespace", async () => { @@ -137,7 +140,7 @@ describe("SchemaRegistryClient", function() { name: "azsdk_js_test2", groupName: env.SCHEMA_REGISTRY_GROUP, format: "avro", - definition: + schemaDefinition: "{\n" + ' "type": "record",\n' + ' "name": "Test",\n' + @@ -151,11 +154,11 @@ describe("SchemaRegistryClient", function() { const foundSchema = await client.getSchema(registered.id); assertIsValidSchemaId(foundSchema); // the schema comes from the service normalized - assert.equal(foundSchema.definition, schema2.definition.replace(/\s/g, "")); + assert.equal(foundSchema.schemaDefinition, schema2.schemaDefinition.replace(/\s/g, "")); const foundId = await client.getSchemaProperties({ // content that comes from the service does not have whitespaces - definition: foundSchema.definition, + schemaDefinition: foundSchema.schemaDefinition, groupName: schema2.groupName, name: schema2.name, format: foundSchema.format From ef483dfaf6e0b0e13a33d1f601077fc4f1582201 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 28 Sep 2021 22:44:33 +0000 Subject: [PATCH 2/7] rename endpoint to fullyQualifiedNamespace --- .../schema-registry/review/schema-registry.api.md | 2 +- .../schema-registry/src/schemaRegistryClient.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/schemaregistry/schema-registry/review/schema-registry.api.md b/sdk/schemaregistry/schema-registry/review/schema-registry.api.md index 1e38d33b51a0..0b2cd614a9f1 100644 --- a/sdk/schemaregistry/schema-registry/review/schema-registry.api.md +++ b/sdk/schemaregistry/schema-registry/review/schema-registry.api.md @@ -54,7 +54,7 @@ export interface SchemaRegistry { // @public export class SchemaRegistryClient implements SchemaRegistry { - constructor(endpoint: string, credential: TokenCredential, options?: SchemaRegistryClientOptions); + constructor(fullyQualifiedNamespace: string, credential: TokenCredential, options?: SchemaRegistryClientOptions); readonly endpoint: string; getSchema(id: string, options?: GetSchemaOptions): Promise; getSchemaProperties(schema: SchemaDescription, options?: GetSchemaPropertiesOptions): Promise; diff --git a/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts b/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts index 21b64c1a437f..b85db84aa8a5 100644 --- a/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts +++ b/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts @@ -36,17 +36,17 @@ export class SchemaRegistryClient implements SchemaRegistry { /** * Creates a new client for Azure Schema Registry service. * - * @param endpoint - The Schema Registry service endpoint URL, for example - * https://mynamespace.servicebus.windows.net. + * @param fullyQualifiedNamespace - The Schema Registry service qualified namespace URL, for example + * https://mynamespace.servicebus.windows.net. * @param credential - Credential to authenticate requests to the service. * @param options - Options to configure API requests to the service. */ constructor( - endpoint: string, + fullyQualifiedNamespace: string, credential: TokenCredential, options: SchemaRegistryClientOptions = {} ) { - this.endpoint = endpoint; + this.endpoint = fullyQualifiedNamespace; const internalPipelineOptions: InternalPipelineOptions = { ...options, From 5e3cf67565b112ed95eebf67271c2d7cf27c6dbe Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 28 Sep 2021 22:54:43 +0000 Subject: [PATCH 3/7] rename endpoint everywhere --- sdk/schemaregistry/schema-registry/README.md | 10 +++++----- ...ets_fully_qualified_name_space_in_constructor.json} | 2 +- ..._sets_fully_qualified_name_space_in_constructor.js} | 2 +- .../samples-dev/schemaRegistrySample.ts | 4 ++-- .../samples/v1/javascript/schemaRegistrySample.js | 5 +++-- .../samples/v1/typescript/src/schemaRegistrySample.ts | 4 ++-- .../schema-registry/src/schemaRegistryClient.ts | 10 +++++----- .../schema-registry/test/public/schemaRegistry.spec.ts | 8 ++++---- 8 files changed, 23 insertions(+), 22 deletions(-) rename sdk/schemaregistry/schema-registry/recordings/browsers/schemaregistryclient/{recording_sets_endpoint_in_constructor.json => recording_sets_fully_qualified_name_space_in_constructor.json} (65%) rename sdk/schemaregistry/schema-registry/recordings/node/schemaregistryclient/{recording_sets_endpoint_in_constructor.js => recording_sets_fully_qualified_name_space_in_constructor.js} (60%) diff --git a/sdk/schemaregistry/schema-registry/README.md b/sdk/schemaregistry/schema-registry/README.md index 3eaa13cf8520..698cd24fc68e 100644 --- a/sdk/schemaregistry/schema-registry/README.md +++ b/sdk/schemaregistry/schema-registry/README.md @@ -32,7 +32,7 @@ npm install @azure/schema-registry ### Create and authenticate a `SchemaRegistryClient` To create a client object to access the Schema Registry API, you will need the -`endpoint` of your Schema Registry resource and a `credential`. The Schema +fully qualified namespace of your Schema Registry resource and a `credential`. The Schema Registry client uses Azure Active Directory credentials to authenticate. You can authenticate with Azure Active Directory using the [Azure Identity @@ -53,7 +53,7 @@ application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, const { DefaultAzureCredential } = require("@azure/identity"); const { SchemaRegistryClient } = require("@azure/schema-registry"); -const client = new SchemaRegistryClient("", new DefaultAzureCredential()); +const client = new SchemaRegistryClient("", new DefaultAzureCredential()); ``` ## Key concepts @@ -77,7 +77,7 @@ schema registry. const { DefaultAzureCredential } = require("@azure/identity"); const { SchemaRegistryClient } = require("@azure/schema-registry"); -const client = new SchemaRegistryClient("", new DefaultAzureCredential()); +const client = new SchemaRegistryClient("", new DefaultAzureCredential()); const description = { name: "", @@ -96,7 +96,7 @@ console.log(registered.id); const { DefaultAzureCredential } = require("@azure/identity"); const { SchemaRegistryClient } = require("@azure/schema-registry"); -const client = new SchemaRegistryClient("", new DefaultAzureCredential()); +const client = new SchemaRegistryClient("", new DefaultAzureCredential()); const description = { name: "", @@ -117,7 +117,7 @@ if (found) { const { DefaultAzureCredential } = require("@azure/identity"); const { SchemaRegistryClient } = require("@azure/schema-registry"); -const client = new SchemaRegistryClient("", new DefaultAzureCredential()); +const client = new SchemaRegistryClient("", new DefaultAzureCredential()); const foundSchema = await client.getSchema(""); if (foundSchema) { console.log(`Got schema content=${foundSchema.content}`); diff --git a/sdk/schemaregistry/schema-registry/recordings/browsers/schemaregistryclient/recording_sets_endpoint_in_constructor.json b/sdk/schemaregistry/schema-registry/recordings/browsers/schemaregistryclient/recording_sets_fully_qualified_name_space_in_constructor.json similarity index 65% rename from sdk/schemaregistry/schema-registry/recordings/browsers/schemaregistryclient/recording_sets_endpoint_in_constructor.json rename to sdk/schemaregistry/schema-registry/recordings/browsers/schemaregistryclient/recording_sets_fully_qualified_name_space_in_constructor.json index fce1b8571f31..6ae6b35679fc 100644 --- a/sdk/schemaregistry/schema-registry/recordings/browsers/schemaregistryclient/recording_sets_endpoint_in_constructor.json +++ b/sdk/schemaregistry/schema-registry/recordings/browsers/schemaregistryclient/recording_sets_fully_qualified_name_space_in_constructor.json @@ -4,5 +4,5 @@ "uniqueName": {}, "newDate": {} }, - "hash": "83dc1ff00845f199c7eb4bc9c91c3cf9" + "hash": "7915ecf70c0ddb88a6144f25578be8ec" } \ No newline at end of file diff --git a/sdk/schemaregistry/schema-registry/recordings/node/schemaregistryclient/recording_sets_endpoint_in_constructor.js b/sdk/schemaregistry/schema-registry/recordings/node/schemaregistryclient/recording_sets_fully_qualified_name_space_in_constructor.js similarity index 60% rename from sdk/schemaregistry/schema-registry/recordings/node/schemaregistryclient/recording_sets_endpoint_in_constructor.js rename to sdk/schemaregistry/schema-registry/recordings/node/schemaregistryclient/recording_sets_fully_qualified_name_space_in_constructor.js index e20ce3df5f2d..83a3e5755621 100644 --- a/sdk/schemaregistry/schema-registry/recordings/node/schemaregistryclient/recording_sets_endpoint_in_constructor.js +++ b/sdk/schemaregistry/schema-registry/recordings/node/schemaregistryclient/recording_sets_fully_qualified_name_space_in_constructor.js @@ -1,5 +1,5 @@ let nock = require('nock'); -module.exports.hash = "46c11a0b5cbacff73a981772862a4d39"; +module.exports.hash = "fd64a414b3181fffa22063279cd52e54"; module.exports.testInfo = {"uniqueName":{},"newDate":{}} diff --git a/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts b/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts index f02bfc22508f..68b88ce45a15 100644 --- a/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts +++ b/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts @@ -13,7 +13,7 @@ import * as dotenv from "dotenv"; dotenv.config(); // Set these environment variables or edit the following values -const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; +const fullyQualifiedNamespace = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names @@ -43,7 +43,7 @@ const schemaDescription: SchemaDescription = { export async function main() { // Create a new client - const client = new SchemaRegistryClient(endpoint, new DefaultAzureCredential()); + const client = new SchemaRegistryClient(fullyQualifiedNamespace, new DefaultAzureCredential()); // Register a schema and get back its ID. const registered = await client.registerSchema(schemaDescription); diff --git a/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js b/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js index 9ddb6027a2ad..738044bbf64f 100644 --- a/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js +++ b/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js @@ -13,7 +13,8 @@ const dotenv = require("dotenv"); dotenv.config(); // Set these environment variables or edit the following values -const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; +const fullyQualifiedNamespace = + process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names @@ -43,7 +44,7 @@ const schemaDescription = { async function main() { // Create a new client - const client = new SchemaRegistryClient(endpoint, new DefaultAzureCredential()); + const client = new SchemaRegistryClient(fullyQualifiedNamespace, new DefaultAzureCredential()); // Register a schema and get back its ID. const registered = await client.registerSchema(schemaDescription); diff --git a/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts b/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts index f02bfc22508f..68b88ce45a15 100644 --- a/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts +++ b/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts @@ -13,7 +13,7 @@ import * as dotenv from "dotenv"; dotenv.config(); // Set these environment variables or edit the following values -const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; +const fullyQualifiedNamespace = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names @@ -43,7 +43,7 @@ const schemaDescription: SchemaDescription = { export async function main() { // Create a new client - const client = new SchemaRegistryClient(endpoint, new DefaultAzureCredential()); + const client = new SchemaRegistryClient(fullyQualifiedNamespace, new DefaultAzureCredential()); // Register a schema and get back its ID. const registered = await client.registerSchema(schemaDescription); diff --git a/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts b/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts index b85db84aa8a5..8093a11dee8d 100644 --- a/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts +++ b/sdk/schemaregistry/schema-registry/src/schemaRegistryClient.ts @@ -27,8 +27,8 @@ import { getRawResponse } from "./utils"; * Client for Azure Schema Registry service. */ export class SchemaRegistryClient implements SchemaRegistry { - /** The Schema Registry service endpoint URL. */ - readonly endpoint: string; + /** The Schema Registry service fully qualified namespace URL. */ + readonly fullyQualifiedNamespace: string; /** Underlying autorest generated client. */ private readonly client: GeneratedSchemaRegistryClient; @@ -46,7 +46,7 @@ export class SchemaRegistryClient implements SchemaRegistry { credential: TokenCredential, options: SchemaRegistryClientOptions = {} ) { - this.endpoint = fullyQualifiedNamespace; + this.fullyQualifiedNamespace = fullyQualifiedNamespace; const internalPipelineOptions: InternalPipelineOptions = { ...options, @@ -57,8 +57,8 @@ export class SchemaRegistryClient implements SchemaRegistry { } }; - this.client = new GeneratedSchemaRegistryClient(this.endpoint, { - endpoint: this.endpoint, + this.client = new GeneratedSchemaRegistryClient(this.fullyQualifiedNamespace, { + endpoint: this.fullyQualifiedNamespace, ...internalPipelineOptions }); diff --git a/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts b/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts index 54023a7cb098..88ea63eaf7c9 100644 --- a/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts +++ b/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts @@ -69,12 +69,12 @@ describe("SchemaRegistryClient", function() { await recorder.stop(); }); - it("sets endpoint in constructor", () => { - const endpoint = "https://example.com/schemaregistry/"; + it("sets fully qualified name space in constructor", () => { + const fullyQualifiedNamespace = "https://example.com/schemaregistry/"; const credential = new ClientSecretCredential("x", "y", "z"); - const customClient = new SchemaRegistryClient(endpoint, credential); - assert.equal(customClient.endpoint, endpoint); + const customClient = new SchemaRegistryClient(fullyQualifiedNamespace, credential); + assert.equal(customClient.fullyQualifiedNamespace, fullyQualifiedNamespace); }); it("rejects schema registration with invalid args", async () => { From 7603d0e5a914018333aef6aed29e0ba89b039076 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 28 Sep 2021 22:59:09 +0000 Subject: [PATCH 4/7] more renamings --- sdk/schemaregistry/schema-registry/README.md | 12 ++++++------ .../schema-registry/review/schema-registry.api.md | 2 +- .../samples-dev/schemaRegistrySample.ts | 7 ++++--- .../samples/v1/javascript/schemaRegistrySample.js | 4 ++-- .../v1/typescript/src/schemaRegistrySample.ts | 4 ++-- sdk/schemaregistry/schema-registry/src/models.ts | 2 +- .../test/public/schemaRegistry.spec.ts | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/sdk/schemaregistry/schema-registry/README.md b/sdk/schemaregistry/schema-registry/README.md index 698cd24fc68e..00214eebb28b 100644 --- a/sdk/schemaregistry/schema-registry/README.md +++ b/sdk/schemaregistry/schema-registry/README.md @@ -82,8 +82,8 @@ const client = new SchemaRegistryClient("", new Default const description = { name: "", groupName: "", - serializationType: "" - content: "" + format: "" + schemaDefinition: "" } const registered = await client.registerSchema(description); @@ -101,8 +101,8 @@ const client = new SchemaRegistryClient("", new Default const description = { name: "", groupName: "", - serializationType: "" - content: "" + format: "" + schemaDefinition: "" } const found = await client.getSchemaId(description); @@ -111,7 +111,7 @@ if (found) { } ``` -### Get content of existing schema by ID +### Get definition of existing schema by ID ```javascript const { DefaultAzureCredential } = require("@azure/identity"); @@ -120,7 +120,7 @@ const { SchemaRegistryClient } = require("@azure/schema-registry"); const client = new SchemaRegistryClient("", new DefaultAzureCredential()); const foundSchema = await client.getSchema(""); if (foundSchema) { - console.log(`Got schema content=${foundSchema.content}`); + console.log(`Got schema definition=${foundSchema.schemaDefinition}`); } ``` diff --git a/sdk/schemaregistry/schema-registry/review/schema-registry.api.md b/sdk/schemaregistry/schema-registry/review/schema-registry.api.md index 0b2cd614a9f1..1e79bcebf0ca 100644 --- a/sdk/schemaregistry/schema-registry/review/schema-registry.api.md +++ b/sdk/schemaregistry/schema-registry/review/schema-registry.api.md @@ -55,7 +55,7 @@ export interface SchemaRegistry { // @public export class SchemaRegistryClient implements SchemaRegistry { constructor(fullyQualifiedNamespace: string, credential: TokenCredential, options?: SchemaRegistryClientOptions); - readonly endpoint: string; + readonly fullyQualifiedNamespace: string; getSchema(id: string, options?: GetSchemaOptions): Promise; getSchemaProperties(schema: SchemaDescription, options?: GetSchemaPropertiesOptions): Promise; registerSchema(schema: SchemaDescription, options?: RegisterSchemaOptions): Promise; diff --git a/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts b/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts index 68b88ce45a15..c0bfe8f7aacb 100644 --- a/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts +++ b/sdk/schemaregistry/schema-registry/samples-dev/schemaRegistrySample.ts @@ -13,7 +13,8 @@ import * as dotenv from "dotenv"; dotenv.config(); // Set these environment variables or edit the following values -const fullyQualifiedNamespace = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; +const fullyQualifiedNamespace = + process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names @@ -56,10 +57,10 @@ export async function main() { console.log(`Got schema ID=${found.id}`); } - // Get content of existing schema by its ID + // Get definition of existing schema by its ID const foundSchema = await client.getSchema(registered.id); if (foundSchema) { - console.log(`Got schema content=${foundSchema.schemaDefinition}`); + console.log(`Got schema definition=${foundSchema.schemaDefinition}`); } } diff --git a/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js b/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js index 738044bbf64f..946e7307c229 100644 --- a/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js +++ b/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js @@ -57,10 +57,10 @@ async function main() { console.log(`Got schema ID=${found.id}`); } - // Get content of existing schema by its ID + // Get definition of existing schema by its ID const foundSchema = await client.getSchema(registered.id); if (foundSchema) { - console.log(`Got schema content=${foundSchema.schemaDefinition}`); + console.log(`Got schema definition=${foundSchema.schemaDefinition}`); } } diff --git a/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts b/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts index 68b88ce45a15..ee29bf874424 100644 --- a/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts +++ b/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts @@ -56,10 +56,10 @@ export async function main() { console.log(`Got schema ID=${found.id}`); } - // Get content of existing schema by its ID + // Get definition of existing schema by its ID const foundSchema = await client.getSchema(registered.id); if (foundSchema) { - console.log(`Got schema content=${foundSchema.schemaDefinition}`); + console.log(`Got schema definition=${foundSchema.schemaDefinition}`); } } diff --git a/sdk/schemaregistry/schema-registry/src/models.ts b/sdk/schemaregistry/schema-registry/src/models.ts index dcbc3d4765f1..a8847c2abaf7 100644 --- a/sdk/schemaregistry/schema-registry/src/models.ts +++ b/sdk/schemaregistry/schema-registry/src/models.ts @@ -21,7 +21,7 @@ export interface SchemaProperties { } /** - * Schema definition with its group, name, and serialization type. + * Schema definition with its name, format, and group. */ export interface SchemaDescription { /** Schema group under which schema is or should be registered. */ diff --git a/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts b/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts index 88ea63eaf7c9..c35165ac44fd 100644 --- a/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts +++ b/sdk/schemaregistry/schema-registry/test/public/schemaRegistry.spec.ts @@ -157,7 +157,7 @@ describe("SchemaRegistryClient", function() { assert.equal(foundSchema.schemaDefinition, schema2.schemaDefinition.replace(/\s/g, "")); const foundId = await client.getSchemaProperties({ - // content that comes from the service does not have whitespaces + // definition that comes from the service does not have whitespaces schemaDefinition: foundSchema.schemaDefinition, groupName: schema2.groupName, name: schema2.name, From 8aa44bb867cbbc442e8c0971fe6e7ad7861081d4 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 28 Sep 2021 23:01:41 +0000 Subject: [PATCH 5/7] renames in the avro lib --- sdk/schemaregistry/schema-registry-avro/README.md | 2 +- .../src/schemaRegistryAvroSerializer.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/schemaregistry/schema-registry-avro/README.md b/sdk/schemaregistry/schema-registry-avro/README.md index e3b8ed474e11..43520a2fa295 100644 --- a/sdk/schemaregistry/schema-registry-avro/README.md +++ b/sdk/schemaregistry/schema-registry-avro/README.md @@ -36,7 +36,7 @@ npm install @azure/schema-registry-avro Provides API to serialize to and deserialize from Avro Binary Encoding plus a header with schema ID. Uses `SchemaRegistryClient` from the [@azure/schema-registry](https://www.npmjs.com/package/@azure/schema-registry) package -to get schema IDs from schema content or vice versa. The provided API has internal cache to avoid calling the schema registry service when possible. +to get schema IDs from schema definition or vice versa. The provided API has internal cache to avoid calling the schema registry service when possible. ### Message format diff --git a/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts b/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts index 9090573f34d1..ceb1bdc79e8d 100644 --- a/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts +++ b/sdk/schemaregistry/schema-registry-avro/src/schemaRegistryAvroSerializer.ts @@ -114,7 +114,7 @@ export class SchemaRegistryAvroSerializer { * @returns A new buffer with the serialized value */ async serialize(value: unknown, schema: string): Promise { - const entry = await this.getSchemaByContent(schema); + const entry = await this.getSchemaByDefinition(schema); const payload = entry.type.toBuffer(value); const buffer = Buffer.alloc(PAYLOAD_OFFSET + payload.length); @@ -155,7 +155,7 @@ export class SchemaRegistryAvroSerializer { return schema.type.fromBuffer(payloadBuffer); } - private readonly cacheByContent = new Map(); + private readonly cacheBySchemaDefinition = new Map(); private readonly cacheById = new Map(); private async getSchema(schemaId: string): Promise { @@ -179,8 +179,8 @@ export class SchemaRegistryAvroSerializer { return this.cache(schemaId, schemaResponse.schemaDefinition, avroType); } - private async getSchemaByContent(schema: string): Promise { - const cached = this.cacheByContent.get(schema); + private async getSchemaByDefinition(schema: string): Promise { + const cached = this.cacheBySchemaDefinition.get(schema); if (cached) { return cached; } @@ -204,7 +204,7 @@ export class SchemaRegistryAvroSerializer { const response = await this.registry.getSchemaProperties(description); if (!response) { throw new Error( - `Schema '${description.name}' not found in registry group '${description.groupName}', or not found to have matching content.` + `Schema '${description.name}' not found in registry group '${description.groupName}', or not found to have matching definition.` ); } id = response.id; @@ -215,7 +215,7 @@ export class SchemaRegistryAvroSerializer { private cache(id: string, schema: string, type: avro.Type): CacheEntry { const entry = { id, type }; - this.cacheByContent.set(schema, entry); + this.cacheBySchemaDefinition.set(schema, entry); this.cacheById.set(id, entry); return entry; } From 6a9d0cad816b604173d654361eba9a62d9f589b0 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 28 Sep 2021 23:03:44 +0000 Subject: [PATCH 6/7] unpublish samples --- .../samples/v1/javascript/package.json | 4 ++-- .../v1/javascript/schemaRegistryAvroSample.js | 10 +++++----- .../samples/v1/typescript/package.json | 4 ++-- .../v1/typescript/src/schemaRegistryAvroSample.ts | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json index 992dd5421d08..33194b261075 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/package.json @@ -25,7 +25,7 @@ "dependencies": { "@azure/schema-registry-avro": "next", "dotenv": "latest", - "@azure/identity": "2.0.0-beta.6", - "@azure/schema-registry": "1.0.0-beta.3" + "@azure/identity": "2.0.0-beta.5", + "@azure/schema-registry": "1.0.0-beta.2" } } diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js index c7187d44c60b..5722310b5a1d 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/javascript/schemaRegistryAvroSample.js @@ -15,7 +15,7 @@ dotenv.config(); // Set these environment variables or edit the following values const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; -const groupName = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; +const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names const schemaObject = { @@ -39,9 +39,9 @@ const schema = JSON.stringify(schemaObject); // Description of the schema for registration const schemaDescription = { name: `${schemaObject.namespace}.${schemaObject.name}`, - groupName, - format: "avro", - schemaDefinition: schema + group, + serializationType: "avro", + content: schema }; async function main() { @@ -54,7 +54,7 @@ async function main() { await client.registerSchema(schemaDescription); // Create a new serializer backed by the client - const serializer = new SchemaRegistryAvroSerializer(client, groupName); + const serializer = new SchemaRegistryAvroSerializer(client, group); // serialize an object that matches the schema const value = { firstName: "Jane", lastName: "Doe" }; diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json index 6e3c83a8bac8..68e0b8118c99 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/package.json @@ -29,8 +29,8 @@ "dependencies": { "@azure/schema-registry-avro": "next", "dotenv": "latest", - "@azure/identity": "2.0.0-beta.6", - "@azure/schema-registry": "1.0.0-beta.3" + "@azure/identity": "2.0.0-beta.5", + "@azure/schema-registry": "1.0.0-beta.2" }, "devDependencies": { "typescript": "~4.2.0", diff --git a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts index 3dafe4dd173f..6a0f9eeb49a3 100644 --- a/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts +++ b/sdk/schemaregistry/schema-registry-avro/samples/v1/typescript/src/schemaRegistryAvroSample.ts @@ -15,7 +15,7 @@ dotenv.config(); // Set these environment variables or edit the following values const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; -const groupName = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; +const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names const schemaObject = { @@ -45,9 +45,9 @@ const schema = JSON.stringify(schemaObject); // Description of the schema for registration const schemaDescription: SchemaDescription = { name: `${schemaObject.namespace}.${schemaObject.name}`, - groupName, - format: "avro", - schemaDefinition: schema + group, + serializationType: "avro", + content: schema }; export async function main() { @@ -60,7 +60,7 @@ export async function main() { await client.registerSchema(schemaDescription); // Create a new serializer backed by the client - const serializer = new SchemaRegistryAvroSerializer(client, groupName); + const serializer = new SchemaRegistryAvroSerializer(client, group); // serialize an object that matches the schema const value: User = { firstName: "Jane", lastName: "Doe" }; @@ -69,7 +69,7 @@ export async function main() { console.log(buffer); // deserialize the result back to an object - const deserializedValue = (await serializer.deserialize(buffer)) as User; + const deserializedValue = await serializer.deserialize(buffer); console.log("Deserialized:"); console.log(`${deserializedValue.firstName} ${deserializedValue.lastName}`); } From 133c444a9dc7899308d1f6d55fda552f9f12cb64 Mon Sep 17 00:00:00 2001 From: deyaaeldeen Date: Tue, 28 Sep 2021 23:06:03 +0000 Subject: [PATCH 7/7] unpublish samples --- .../samples/v1/javascript/schemaRegistrySample.js | 11 +++++------ .../samples/v1/typescript/src/schemaRegistrySample.ts | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js b/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js index 946e7307c229..209c4522cd95 100644 --- a/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js +++ b/sdk/schemaregistry/schema-registry/samples/v1/javascript/schemaRegistrySample.js @@ -13,8 +13,7 @@ const dotenv = require("dotenv"); dotenv.config(); // Set these environment variables or edit the following values -const fullyQualifiedNamespace = - process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; +const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names @@ -39,12 +38,12 @@ const schemaDescription = { name: `${schemaObject.namespace}.${schemaObject.name}`, groupName: group, format: "avro", - schemaDefinition: JSON.stringify(schemaObject) + definition: JSON.stringify(schemaObject) }; async function main() { // Create a new client - const client = new SchemaRegistryClient(fullyQualifiedNamespace, new DefaultAzureCredential()); + const client = new SchemaRegistryClient(endpoint, new DefaultAzureCredential()); // Register a schema and get back its ID. const registered = await client.registerSchema(schemaDescription); @@ -57,10 +56,10 @@ async function main() { console.log(`Got schema ID=${found.id}`); } - // Get definition of existing schema by its ID + // Get content of existing schema by its ID const foundSchema = await client.getSchema(registered.id); if (foundSchema) { - console.log(`Got schema definition=${foundSchema.schemaDefinition}`); + console.log(`Got schema content=${foundSchema.definition}`); } } diff --git a/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts b/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts index ee29bf874424..b24a54bd5247 100644 --- a/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts +++ b/sdk/schemaregistry/schema-registry/samples/v1/typescript/src/schemaRegistrySample.ts @@ -13,7 +13,7 @@ import * as dotenv from "dotenv"; dotenv.config(); // Set these environment variables or edit the following values -const fullyQualifiedNamespace = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; +const endpoint = process.env["SCHEMA_REGISTRY_ENDPOINT"] || ""; const group = process.env["SCHEMA_REGISTRY_GROUP"] || "AzureSdkSampleGroup"; // Sample Avro Schema for user with first and last names @@ -38,12 +38,12 @@ const schemaDescription: SchemaDescription = { name: `${schemaObject.namespace}.${schemaObject.name}`, groupName: group, format: "avro", - schemaDefinition: JSON.stringify(schemaObject) + definition: JSON.stringify(schemaObject) }; export async function main() { // Create a new client - const client = new SchemaRegistryClient(fullyQualifiedNamespace, new DefaultAzureCredential()); + const client = new SchemaRegistryClient(endpoint, new DefaultAzureCredential()); // Register a schema and get back its ID. const registered = await client.registerSchema(schemaDescription); @@ -56,10 +56,10 @@ export async function main() { console.log(`Got schema ID=${found.id}`); } - // Get definition of existing schema by its ID + // Get content of existing schema by its ID const foundSchema = await client.getSchema(registered.id); if (foundSchema) { - console.log(`Got schema definition=${foundSchema.schemaDefinition}`); + console.log(`Got schema content=${foundSchema.definition}`); } }