in libs/logic-apps-shared/src/parsers/lib/common/schemaprocessor.ts [143:219]
private _getArrayProperties(schema: SchemaObject, skipParent = false): SchemaProperty[] {
const itemsSchema = (this._dereferenceRefSchema(schema.items as OpenApiSchema) || {}) as SchemaObject;
const itemsType = itemsSchema.type;
const arrayOutputs = skipParent ? [] : this._getScalarProperties(schema);
const isReadOnlyInputParameter = this.options.isInputSchema && this._isReadOnlyParameter(schema);
if (this.options.expandArrayOutputs && !this._isInternalParameter(schema) && !isReadOnlyInputParameter) {
if (
this.options.expandArrayOutputsDepth === undefined ||
(this.options.arrayOutputDepth as number) > this.options.expandArrayOutputsDepth
) {
return arrayOutputs;
}
if (this.options.parentProperty) {
this.options.parentProperty.arrayName = this.options.prefix;
this.options.parentProperty.isArray = true;
this.options.parentProperty.visibility = this._getVisibility(schema);
this.options.parentProperty.groupName = this._getGroupName(schema);
} else {
this.options.parentProperty = {
arrayName: this._getName(),
isArray: true,
visibility: this._getVisibility(schema),
groupName: this._getGroupName(schema),
};
}
// Note: Reset the prefix only while expanding array properties for outputs.
if (!this.options.isInputSchema) {
this.options.prefix = undefined;
}
const summary = schema[SwaggerConstants.ExtensionProperties.Summary];
const intl = getIntl();
// Note: always apply array name as prefix for input schema
const title = this.options.isInputSchema
? schema.title ||
(this.options.currentKey === ParameterKeyUtility.WildIndexSegment
? intl.formatMessage({ defaultMessage: 'Item', id: 'QbJDi7', description: 'Label for single item inside an array.' })
: this.options.currentKey)
: schema.title;
const originalTitlePrefix = this.options.titlePrefix;
const originalSummaryPrefix = this.options.summaryPrefix;
const itemSummary = itemsSchema[SwaggerConstants.ExtensionProperties.Summary];
this.options.titlePrefix = this._concatenateString(originalTitlePrefix, itemsSchema.title ? undefined : title);
this.options.summaryPrefix = this._concatenateString(originalSummaryPrefix, itemSummary ? undefined : summary);
this.options.currentKey = ParameterKeyUtility.WildIndexSegment;
(this.options.arrayOutputDepth as number)++;
const itemParameter = this._getPropertyDetails(itemsSchema, /* schema */ undefined, /* isArrayItems */ true) as SchemaProperty;
arrayOutputs.push(itemParameter);
if (itemsType === SwaggerConstants.Types.Object) {
if (itemsSchema[SwaggerConstants.ExtensionProperties.DynamicSchema]) {
return this._getScalarProperties(itemsSchema).concat(arrayOutputs);
}
const keyPrefix = this.options.keyPrefix
? `${this.options.keyPrefix}.${ParameterKeyUtility.WildIndexSegment}`
: `$.${ParameterKeyUtility.WildIndexSegment}`;
const itemsOutputs = this._getObjectPropertyOutputs(itemsSchema, keyPrefix, this.options.titlePrefix, this.options.summaryPrefix);
if (itemsOutputs.length) {
return itemsOutputs.concat(arrayOutputs);
}
} else if (itemsType === SwaggerConstants.Types.Array) {
this.options.keyPrefix = itemParameter.key;
this.options.prefix = itemParameter.name;
const nestArrayOutputs = this._getArrayProperties(itemsSchema, /* skipParent */ true);
if (nestArrayOutputs.length) {
return nestArrayOutputs.concat(arrayOutputs);
}
}
}
return arrayOutputs;
}