Skip to content

Commit

Permalink
fix: oneof find nearest merge
Browse files Browse the repository at this point in the history
  • Loading branch information
v8tenko committed Nov 24, 2023
1 parent 85f327c commit 4a6b8e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@diplodoc/openapi-extension",
"version": "1.4.1",
"version": "1.4.3",
"description": "OpenAPI extension for Diplodoc transformer and builder",
"main": "plugin/cjs/index.min.js",
"types": "plugin/index.d.ts",
Expand Down
20 changes: 13 additions & 7 deletions src/includer/traverse/tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,22 @@ function prepareComplexDescription(baseDescription: string, value: OpenJSONSchem
function findNonNullOneOfElement(schema: OpenJSONSchema): OpenJSONSchema {
const isValid = (v: OpenJSONSchema) => {
if (typeof inferType(v) === 'string') {
return true;
return v;
}

if (Object.keys(v.properties || {}).length) {
return true;
const merged = RefsService.merge(v);

if (Object.keys(merged.properties || {}).length) {
return v;
}

return false;
};

if (isValid(schema)) {
return RefsService.merge(schema);
const result = isValid(schema);

if (result) {
return result;
}

const stack = [...(schema.oneOf || [])];
Expand All @@ -227,8 +231,10 @@ function findNonNullOneOfElement(schema: OpenJSONSchema): OpenJSONSchema {
continue;
}

if (isValid(v)) {
return RefsService.merge(v);
const status = isValid(v);

if (status) {
return status;
}

stack.push(...(v.oneOf || []));
Expand Down

0 comments on commit 4a6b8e1

Please sign in to comment.