Skip to content

Commit

Permalink
fix: refactor description
Browse files Browse the repository at this point in the history
  • Loading branch information
v8tenko authored and moki committed Apr 18, 2023
1 parent c0c8759 commit 656a182
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/services/includers/batteries/openapi/generators/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,7 @@ function merge(value: OpenJSONSchemaDefinition, allRefs?: Refs): OpenJSONSchema
const description = (value.oneOf
// coz ts 3.9 can't recognize (OpenJSONSchema | false)[].filter(Boolean) as OpenJSONSchema[]
.filter(Boolean) as OpenJSONSchema[])
.map((item) => {
const ref = allRefs && findRef(allRefs, item);
return ref ? anchor(ref) : item.description;
})
.map((item) => createOneOfDescription(allRefs, item))
.filter(Boolean)
.join('\nor ');

Expand All @@ -290,6 +287,12 @@ function merge(value: OpenJSONSchemaDefinition, allRefs?: Refs): OpenJSONSchema
return {type: 'object', description, properties, allOf: value.allOf, oneOf: value.oneOf};
}


function createOneOfDescription(allRefs: Refs | undefined, item: OpenJSONSchema): string | undefined {
const ref = allRefs && findRef(allRefs, item);
return ref ? anchor(ref) : item.description;
}

function isRequired(key: string, value: JSONSchema6): boolean {
return value.required?.includes(key) ?? false;
}
Expand Down

0 comments on commit 656a182

Please sign in to comment.