Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asyncapi/avro-schema-parser

Package Overview
Dependencies
Maintainers
3
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asyncapi/avro-schema-parser - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

tests/asyncapi-avro-1.9.0-bindings.yaml

14

index.js

@@ -10,2 +10,16 @@ const { avroToJsonSchema } = require('./to-json-schema.js');

delete message.schemaFormat;
// remove that function when https://github.com/asyncapi/spec/issues/622 will be introduced in AsyncAPI spec
async function handleKafkaProtocolKey() {
if (message.bindings && message.bindings.kafka) {
const key = message.bindings.kafka.key;
if (key) {
const bindingsTransformed = await avroToJsonSchema(key);
message['x-parser-original-bindings-kafka-key'] = key;
message.bindings.kafka.key = bindingsTransformed;
}
}
}
await handleKafkaProtocolKey();
};

@@ -12,0 +26,0 @@

4

package.json
{
"name": "@asyncapi/avro-schema-parser",
"version": "0.4.0",
"version": "0.5.0",
"description": "An AsyncAPI schema parser for Avro 1.x schemas.",

@@ -33,3 +33,3 @@ "main": "index.js",

"devDependencies": {
"@asyncapi/parser": "^1.8.1",
"@asyncapi/parser": "^1.9.0",
"@semantic-release/commit-analyzer": "^8.0.1",

@@ -36,0 +36,0 @@ "@semantic-release/github": "^7.0.4",

@@ -15,2 +15,5 @@ const fs = require('fs');

const inputWithAvro190WithBindings = fs.readFileSync(path.resolve(__dirname, './asyncapi-avro-1.9.0-bindings.yaml'), 'utf8');
const outputWithAvro190WithBindings = '{"asyncapi":"2.0.0","info":{"title":"My API","version":"1.0.0"},"channels":{"mychannel":{"publish":{"message":{"payload":{"type":"object","properties":{"name":{"type":"string","examples":["Donkey"],"x-parser-schema-id":"<anonymous-schema-1>"},"age":{"oneOf":[{"type":"integer","minimum":-2147483648,"maximum":2147483647,"examples":[123],"x-parser-schema-id":"<anonymous-schema-3>"},{"type":"null","x-parser-schema-id":"<anonymous-schema-4>"}],"default":null,"x-parser-schema-id":"<anonymous-schema-2>"},"favoriteProgrammingLanguage":{"type":"string","enum":["JS","Java","Go","Rust","C"],"default":"JS","x-parser-schema-id":"<anonymous-schema-5>"},"address":{"type":"object","properties":{"zipcode":{"type":"integer","minimum":-2147483648,"maximum":2147483647,"examples":[53003],"x-parser-schema-id":"<anonymous-schema-7>"}},"x-parser-schema-id":"<anonymous-schema-6>"},"someid":{"type":"string","x-parser-schema-id":"<anonymous-schema-8>"}},"x-parser-schema-id":"com.company.Person"},"bindings":{"kafka":{"key":{"type":"object","properties":{"name":{"type":"string","examples":["Donkey"]},"age":{"oneOf":[{"type":"integer","minimum":-2147483648,"maximum":2147483647,"examples":[123]},{"type":"null"}],"default":null},"favoriteProgrammingLanguage":{"type":"string","enum":["JS","Java","Go","Rust","C"],"default":"JS"},"address":{"type":"object","properties":{"zipcode":{"type":"integer","minimum":-2147483648,"maximum":2147483647,"examples":[53003]}}},"someid":{"type":"string"}},"x-parser-schema-id":"com.company.Person"}},"mqtt":{"x-test":{"type":"string"}}},"x-parser-original-schema-format":"application/vnd.apache.avro;version=1.9.0","x-parser-original-payload":{"name":"Person","namespace":"com.company","type":"record","fields":[{"name":"name","type":"string","example":"Donkey"},{"name":"age","type":["null","int"],"default":null,"example":"123"},{"name":"favoriteProgrammingLanguage","type":{"name":"ProgrammingLanguage","type":"enum","symbols":["JS","Java","Go","Rust","C"],"default":"JS"}},{"name":"address","type":{"name":"Address","type":"record","fields":[{"name":"zipcode","type":"int","example":"53003"}]}},{"name":"someid","type":"uuid"}]},"x-parser-original-bindings-kafka-key":{"name":"Person","namespace":"com.company","type":"record","fields":[{"name":"name","type":"string","example":"Donkey"},{"name":"age","type":["null","int"],"default":null,"example":"123"},{"name":"favoriteProgrammingLanguage","type":{"name":"ProgrammingLanguage","type":"enum","symbols":["JS","Java","Go","Rust","C"],"default":"JS"}},{"name":"address","type":{"name":"Address","type":"record","fields":[{"name":"zipcode","type":"int","example":"53003"}]}},{"name":"someid","type":"uuid"}]},"schemaFormat":"application/vnd.aai.asyncapi;version=2.0.0","x-parser-message-parsed":true,"x-parser-message-name":"<anonymous-message-1>"}}}},"x-parser-spec-parsed":true}';
parser.registerSchemaParser(avroSchemaParser);

@@ -31,2 +34,6 @@

});
it('should parse Avro schema in kafka bindings', async function() {
const result = await parser.parse(inputWithAvro190WithBindings, { path: __filename });
expect(JSON.stringify(result.json())).toEqual(outputWithAvro190WithBindings);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc