Skip to content

Commit 31c02f2

Browse files
David-Mulderbajtos
authored andcommitted
feat(repository-json-schema): add property description to JSON schema
Description was already supported in the loopback internal property specification, but was lost in the transformation to JSON schema. Change to include description from @Property.
1 parent 69c9ac4 commit 31c02f2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/repository-json-schema/src/build-schema.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ export function metaToJsonProperty(meta: PropertyDefinition): JSONSchema {
121121
Object.assign(propDef, {$ref: `#/definitions/${resolvedType.name}`});
122122
}
123123

124+
if (meta.description) {
125+
Object.assign(propDef, {
126+
description: meta.description,
127+
});
128+
}
129+
124130
return result;
125131
}
126132

packages/repository-json-schema/test/unit/build-schema.unit.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,12 @@ describe('build-schema', () => {
162162
items: {$ref: '#/definitions/CustomType'},
163163
});
164164
});
165+
166+
it('keeps description on property', () => {
167+
expect(metaToJsonProperty({type: String, description: 'test'})).to.eql({
168+
type: 'string',
169+
description: 'test',
170+
});
171+
});
165172
});
166173
});

0 commit comments

Comments
 (0)