Skip to content

Commit 2127d62

Browse files
authored
Feature/add title (#871)
* Added title/description for 2-way-sync
1 parent 91e6708 commit 2127d62

File tree

3 files changed

+642
-6
lines changed

3 files changed

+642
-6
lines changed

libV2/schemaUtils.js

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,19 @@ let QUERYPARAM = 'query',
510510
a combination of multiple schemas
511511
*/
512512
if (resolveFor === TYPES_GENERATION) {
513-
return {
513+
const result = {
514514
allOf: _.map(schema.allOf, (schema) => {
515515
// eslint-disable-next-line no-use-before-define
516516
return _resolveSchema(context, schema, stack, resolveFor, _.cloneDeep(seenRef), currentPath);
517517
})
518518
};
519+
if (schema.title !== undefined) {
520+
result.title = schema.title;
521+
}
522+
if (schema.description !== undefined) {
523+
result.description = schema.description;
524+
}
525+
return result;
519526
}
520527

521528
try {
@@ -594,10 +601,21 @@ let QUERYPARAM = 'query',
594601
return _resolveSchema(context, compositeSchema[0], stack, resolveFor, _.cloneDeep(seenRef), currentPath);
595602
}
596603

597-
return { [compositeKeyword]: _.map(compositeSchema, (schemaElement, index) => {
598-
return _resolveSchema(context, schemaElement, stack, resolveFor, _.cloneDeep(seenRef),
599-
utils.addToJsonPath(currentPath, [compositeKeyword, index]));
600-
}) };
604+
const result = {
605+
[compositeKeyword]: _.map(compositeSchema, (schemaElement, index) => {
606+
return _resolveSchema(context, schemaElement, stack, resolveFor, _.cloneDeep(seenRef),
607+
utils.addToJsonPath(currentPath, [compositeKeyword, index]));
608+
})
609+
};
610+
611+
if (schema.title !== undefined) {
612+
result.title = schema.title;
613+
}
614+
if (schema.description !== undefined) {
615+
result.description = schema.description;
616+
}
617+
618+
return result;
601619
}
602620

603621
if (schema.allOf) {
@@ -768,6 +786,8 @@ let QUERYPARAM = 'query',
768786
processSchema = (resolvedSchema) => {
769787
if (resolvedSchema.anyOf) {
770788
return {
789+
title: resolvedSchema.title,
790+
description: resolvedSchema.description,
771791
anyOf: resolvedSchema.anyOf.map((schema) => {
772792
return processSchema(schema);
773793
})
@@ -776,6 +796,8 @@ let QUERYPARAM = 'query',
776796

777797
if (resolvedSchema.oneOf) {
778798
return {
799+
title: resolvedSchema.title,
800+
description: resolvedSchema.description,
779801
oneOf: resolvedSchema.oneOf.map((schema) => {
780802
return processSchema(schema);
781803
})
@@ -784,6 +806,8 @@ let QUERYPARAM = 'query',
784806

785807
if (resolvedSchema.allOf) {
786808
return {
809+
title: resolvedSchema.title,
810+
description: resolvedSchema.description,
787811
allOf: resolvedSchema.allOf.map((schema) => {
788812
return processSchema(schema);
789813
})
@@ -814,6 +838,7 @@ let QUERYPARAM = 'query',
814838
maximum: propValue.maximum,
815839
pattern: propValue.pattern,
816840
example: propValue.example,
841+
title: propValue.title,
817842
description: propValue.description,
818843
format: propValue.format
819844
};
@@ -865,7 +890,9 @@ let QUERYPARAM = 'query',
865890
return arrayDetails;
866891
}
867892
return {
868-
type: resolvedSchema.type
893+
type: resolvedSchema.type,
894+
description: resolvedSchema.description,
895+
title: resolvedSchema.title
869896
};
870897
},
871898

@@ -2106,6 +2133,8 @@ let QUERYPARAM = 'query',
21062133
createProperties = (param) => {
21072134
const { schema } = param;
21082135
return {
2136+
description: schema.description,
2137+
title: schema.title,
21092138
type: schema.type,
21102139
format: schema.format,
21112140
default: schema.default,
@@ -2450,6 +2479,8 @@ let QUERYPARAM = 'query',
24502479

24512480
properties = {
24522481
type: schema.type,
2482+
description: schema.description,
2483+
title: schema.title,
24532484
format: schema.format,
24542485
default: schema.default,
24552486
required: schema.required,

0 commit comments

Comments
 (0)