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 Jan 15, 2024
1 parent 0c08a4a commit 9888099
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"/lib"
],
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^9.0.9",
"@apidevtools/json-schema-ref-parser": "^9.1.2",
"@types/json-schema": "^7.0.11",
"js-yaml": "^4.1.0",
"jsonpath-plus": "^6.0.1",
Expand Down
26 changes: 23 additions & 3 deletions src/v3/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,29 @@ async function resolveExternalRefsForOperation(parsedJSON: any, $refs: $Refs) {
}

export async function parse(JSONSchema: any) {
const refs = await $RefParser.resolve(JSONSchema);
addXOrigins(JSONSchema);
await $RefParser.dereference(JSONSchema);
await $RefParser.dereference(JSONSchema, {
dereference: {
circular: false,
excludedPathMatcher: (path: string): boolean => {
return (
!!path.match(/#\/channels\/[a-zA-Z0-9]*\/servers/) ||
!!path.match(/#\/operations\/[a-zA-Z0-9]*\/channel/) ||
!!path.match(/#\/operations\/[a-zA-Z0-9]*\/messages/) ||
!!path.match(/#\/operations\/[a-zA-Z0-9]*\/reply\/channel/) ||
!!path.match(/#\/operations\/[a-zA-Z0-9]*\/reply\/messages/) ||
!!path.match(/#\/components\/operations\/[a-zA-Z0-9]*\/channel/) ||
!!path.match(/#\/components\/operations\/[a-zA-Z0-9]*\/messages/) ||
!!path.match(
/#\/components\/operations\/[a-zA-Z0-9]*\/reply\/channel/
) ||
!!path.match(
/#\/components\/operations\/[a-zA-Z0-9]*\/reply\/messages/
)
);
},
},
});
}

export async function resolveV3Document(asyncapiDocuments: AsyncAPIObject[]) {
Expand All @@ -93,4 +113,4 @@ export async function resolveV3Document(asyncapiDocuments: AsyncAPIObject[]) {
docs.push(asyncapiDocument);
}
return docs;
}
}

0 comments on commit 9888099

Please sign in to comment.