From 7480f0c6aba137434afd491b067a6d613d6a65e9 Mon Sep 17 00:00:00 2001 From: Heiko Henning Date: Wed, 6 Sep 2023 14:33:09 +0000 Subject: [PATCH] Feat: re add protobuff parser --- library/package-lock.json | 81 +++++++++++++++++++++-------------- library/package.json | 2 +- library/src/helpers/parser.ts | 6 +-- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/library/package-lock.json b/library/package-lock.json index 226fa1135..938bba026 100644 --- a/library/package-lock.json +++ b/library/package-lock.json @@ -12,7 +12,7 @@ "@asyncapi/avro-schema-parser": "3.0.3", "@asyncapi/openapi-schema-parser": "3.0.4", "@asyncapi/parser": "^3.0.0-next-major-spec.1", - "@asyncapi/protobuf-schema-parser": "1.0.0", + "@asyncapi/protobuf-schema-parser": "3.0.0", "highlight.js": "^10.7.2", "isomorphic-dompurify": "^0.13.0", "marked": "^4.0.14", @@ -186,14 +186,47 @@ } }, "node_modules/@asyncapi/protobuf-schema-parser": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@asyncapi/protobuf-schema-parser/-/protobuf-schema-parser-1.0.0.tgz", - "integrity": "sha512-eLfFhV6L+idW83LUspD6pzVwp2Zz0t3oW7kZD+USynmKZMkXnLmY7ON0q82Y5k0KZ34itoyyKu7YBYe4JxIZsw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@asyncapi/protobuf-schema-parser/-/protobuf-schema-parser-3.0.0.tgz", + "integrity": "sha512-kjoLrll611K+xYC/iBUlSnZsCHbrhL999ItVHZhObUOjUB991XgonqbSAaihiiDXTYgceOLhJKAN5llkV/LOOA==", "dependencies": { - "conventional-changelog-conventionalcommits": "^5.0.0", + "@asyncapi/parser": "^2.1.0", + "@types/protocol-buffers-schema": "^3.4.1", "protocol-buffers-schema": "^3.6.0" } }, + "node_modules/@asyncapi/protobuf-schema-parser/node_modules/@asyncapi/parser": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.1.0.tgz", + "integrity": "sha512-78jjN3eW4ZmgJEa6Ap15lofzADCeItO4wHcAY2Jod3qLB1xf1zFDZQdtm3VSHYLeLhwoC1A33bAtzEf7M5P2bg==", + "dependencies": { + "@asyncapi/specs": "^5.1.0", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "node_modules/@asyncapi/protobuf-schema-parser/node_modules/@asyncapi/specs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", + "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "dependencies": { + "@types/json-schema": "^7.0.11" + } + }, "node_modules/@asyncapi/specs": { "version": "6.0.0-next-major-spec.6", "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.0.0-next-major-spec.6.tgz", @@ -3644,6 +3677,14 @@ "integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==", "dev": true }, + "node_modules/@types/protocol-buffers-schema": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@types/protocol-buffers-schema/-/protocol-buffers-schema-3.4.1.tgz", + "integrity": "sha512-CBpqIDa1+/F3Z5EL8Uz/t+1eygIinJiMS37KP8O9TN+n38OlckYQhU+t/vYpsF7XhSDuiZS0zAJyfRrAeDKDUw==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/q": { "version": "1.5.6", "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.6.tgz", @@ -4270,11 +4311,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/array-ify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==" - }, "node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -5656,15 +5692,6 @@ "node": ">=4.0.0" } }, - "node_modules/compare-func": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", - "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", - "dependencies": { - "array-ify": "^1.0.0", - "dot-prop": "^5.1.0" - } - }, "node_modules/component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -5688,19 +5715,6 @@ "integrity": "sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==", "dev": true }, - "node_modules/conventional-changelog-conventionalcommits": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-5.0.0.tgz", - "integrity": "sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==", - "dependencies": { - "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/convert-source-map": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", @@ -6688,6 +6702,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", + "dev": true, "dependencies": { "is-obj": "^2.0.0" }, @@ -8789,6 +8804,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", + "dev": true, "engines": { "node": ">=8" } @@ -14392,6 +14408,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", + "dev": true, "engines": { "node": ">=0.6.0", "teleport": ">=0.2.0" diff --git a/library/package.json b/library/package.json index db32c6994..0ba4420b3 100644 --- a/library/package.json +++ b/library/package.json @@ -70,8 +70,8 @@ "dependencies": { "@asyncapi/avro-schema-parser": "3.0.3", "@asyncapi/openapi-schema-parser": "3.0.4", + "@asyncapi/protobuf-schema-parser": "3.0.0", "@asyncapi/parser": "^3.0.0-next-major-spec.1", - "@asyncapi/protobuf-schema-parser": "1.0.0", "highlight.js": "^10.7.2", "isomorphic-dompurify": "^0.13.0", "marked": "^4.0.14", diff --git a/library/src/helpers/parser.ts b/library/src/helpers/parser.ts index a914e0a5b..a078bcef9 100644 --- a/library/src/helpers/parser.ts +++ b/library/src/helpers/parser.ts @@ -1,8 +1,7 @@ import { Parser as AsyncapiParser, fromURL } from '@asyncapi/parser'; import { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser'; +import { ProtoBuffSchemaParser } from '@asyncapi/protobuf-schema-parser'; import { AvroSchemaParser } from '@asyncapi/avro-schema-parser'; -// @ts-ignore -import protoSchemaParser from '@asyncapi/protobuf-schema-parser'; import { ErrorObject, ParserReturn, FetchingSchemaInterface } from '../types'; @@ -11,8 +10,7 @@ import { VALIDATION_ERRORS_TYPE } from '../constants'; const asyncapiParser = new AsyncapiParser(); asyncapiParser.registerSchemaParser(OpenAPISchemaParser()); asyncapiParser.registerSchemaParser(AvroSchemaParser()); -// Waiting for schema parser to be upgraded -// asyncapiParser.registerSchemaParser(protoSchemaParser); +asyncapiParser.registerSchemaParser(ProtoBuffSchemaParser()); export class Parser { static async parse(