From edfd292c6905cbe1ea63535bcac04e85ce4849cf Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Wed, 25 Aug 2021 12:45:05 -0400 Subject: [PATCH] Use description from properties when building a property from schema, if one exists If a property has a description but references a schema make sure the property description is used if no description exists on the referenced schema --- src/lookup/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lookup/index.ts b/src/lookup/index.ts index a9fd490..644eee0 100644 --- a/src/lookup/index.ts +++ b/src/lookup/index.ts @@ -62,12 +62,16 @@ export class InternalLookup implements Lookup { return undefined; } - const result = pointerGet(this.schema, ref.slice(1)); + let result = pointerGet(this.schema, ref.slice(1)); if (result === undefined) { return undefined; } + // reference schema exists, add description from original schema if one exists + // fulfills scenario where schema property is a schema ref but also specifies a "top-level" description for the ref schema IE context description + result = {description: schema.description, ...result}; + // TODO add in a type check on the result to ensure that it is of the right type const subResult = this.getSchema(result); @@ -81,4 +85,4 @@ export class InternalLookup implements Lookup { baseReference: subResult.baseReference || ref }; } -} \ No newline at end of file +}