refactor: normalize array type notation from Array<T> to T[] in generators and type mapper
This commit is contained in:
@@ -44,7 +44,7 @@ export function generateCleanArchitecture(
|
||||
if (rawProperties[k].$ref) {
|
||||
tsType = rawProperties[k].$ref.split('/').pop() || 'unknown';
|
||||
} else if (rawProperties[k].type === 'array' && rawProperties[k].items?.$ref) {
|
||||
tsType = `Array<${rawProperties[k].items.$ref.split('/').pop()}>`;
|
||||
tsType = `${rawProperties[k].items.$ref.split('/').pop()}[]`;
|
||||
}
|
||||
return {
|
||||
name: k,
|
||||
@@ -163,7 +163,7 @@ export function generateCleanArchitecture(
|
||||
returnBaseType = returnType;
|
||||
} else if (responseSchema.type === 'array' && responseSchema.items?.$ref) {
|
||||
returnBaseType = responseSchema.items.$ref.split('/').pop() || 'unknown';
|
||||
returnType = `Array<${returnBaseType}>`;
|
||||
returnType = `${returnBaseType}[]`;
|
||||
isListContainer = true;
|
||||
}
|
||||
}
|
||||
@@ -203,10 +203,10 @@ export function generateCleanArchitecture(
|
||||
const imports: { classname: string; classFilename: string; classVarName: string }[] = [];
|
||||
Object.keys(schemas).forEach((s) => {
|
||||
const usedAsReturn = tagsMap[tag].some(
|
||||
(op) => op.returnType === s || op.returnType === `Array<${s}>`
|
||||
(op) => op.returnType === s || op.returnType === `${s}[]`
|
||||
);
|
||||
const usedAsParam = tagsMap[tag].some((op) =>
|
||||
op.allParams.some((p) => p.dataType === s || p.dataType === `Array<${s}>`)
|
||||
op.allParams.some((p) => p.dataType === s || p.dataType === `${s}[]`)
|
||||
);
|
||||
if (usedAsReturn || usedAsParam) {
|
||||
imports.push({
|
||||
|
||||
Reference in New Issue
Block a user