Skip to content

Commit

Permalink
feat: add x-origin property
Browse files Browse the repository at this point in the history
  • Loading branch information
aeworxet committed Feb 16, 2024
1 parent 30a0f3c commit e41e46c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function addXOrigins(asyncapiDocument: AsyncAPIObject) {
// VALUE from 'asyncapiDocument' becomes KEY for the
// underlying and recursive functions
Object.values(asyncapiDocument).forEach(async (key: any) => {

Check warning on line 110 in src/util.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed

Check warning on line 110 in src/util.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - macos-latest

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed
if (typeof key === 'object' && key !== '$ref') {
if (key && typeof key === 'object' && key !== '$ref') {
if (Object.keys(key).indexOf('$ref') !== -1) {
if (isExternalReference(key['$ref'])) {
key['x-origin'] = key['$ref'];
Expand All @@ -122,9 +122,9 @@ export function addXOrigins(asyncapiDocument: AsyncAPIObject) {
// contains no external `$ref`s at all.
// Then it exits all the way up in the opposite direction.

let inlineAsyncapiDocumentURI = key['$ref'].split('#/');
let inlineAsyncapiDocumentPath = inlineAsyncapiDocumentURI[0];
let inlineAsyncapiDocumentPointer = inlineAsyncapiDocumentURI[1];
const inlineAsyncapiDocumentURI = key['$ref'].split('#/');
const inlineAsyncapiDocumentPath = inlineAsyncapiDocumentURI[0];
const inlineAsyncapiDocumentPointer = inlineAsyncapiDocumentURI[1];

let inlineAsyncapiDocument = inlineAsyncapiDocumentPath.startsWith(
'http'
Expand Down
1 change: 1 addition & 0 deletions src/v3/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export async function parse(JSONSchema: any) {
!!/#\/operations\/[a-zA-Z0-9]*\/messages/.exec(path) ||

Check failure on line 91 in src/v3/parser.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Wrap the regexp literal in parens to disambiguate the slash

Check failure on line 91 in src/v3/parser.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - macos-latest

Wrap the regexp literal in parens to disambiguate the slash
!!/#\/operations\/[a-zA-Z0-9]*\/reply\/channel/.exec(path) ||
!!/#\/operations\/[a-zA-Z0-9]*\/reply\/messages/.exec(path) ||
!!/#\/components\/channels\/[a-zA-Z0-9]*\/servers/.exec(path) ||
!!/#\/components\/operations\/[a-zA-Z0-9]*\/channel/.exec(path) ||
!!/#\/components\/operations\/[a-zA-Z0-9]*\/messages/.exec(path) ||
!!/#\/components\/operations\/[a-zA-Z0-9]*\/reply\/channel/.exec(
Expand Down

0 comments on commit e41e46c

Please sign in to comment.