@openapi-codegen/typescript
Advanced tools
Comparing version 11.0.0 to 11.0.1
@@ -134,7 +134,9 @@ "use strict"; | ||
} | ||
if (!schema.properties /* free form object */ && | ||
!schema.additionalProperties) { | ||
if (!schema.properties && !schema.additionalProperties) { | ||
return withNullable(typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier("Record"), [ | ||
typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.StringKeyword), | ||
typescript_1.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.AnyKeyword), | ||
typescript_1.factory.createKeywordTypeNode(schema.additionalProperties === false | ||
? typescript_1.default.SyntaxKind.NeverKeyword // empty object | ||
: typescript_1.default.SyntaxKind.AnyKeyword // free form object | ||
), | ||
]), schema.nullable); | ||
@@ -141,0 +143,0 @@ } |
@@ -181,3 +181,5 @@ "use strict"; | ||
}); | ||
await context.writeFile(`${utilsFilename}.ts`, (0, utils_1.getUtils)()); | ||
if (!context.existsFile(`${utilsFilename}.ts`)) { | ||
await context.writeFile(`${utilsFilename}.ts`, (0, utils_1.getUtils)()); | ||
} | ||
await context.writeFile(filename + ".ts", printNodes([ | ||
@@ -260,6 +262,11 @@ (0, createWatermark_1.createWatermark)(context.openAPIDocument.info), | ||
typescript_1.factory.createSpreadAssignment(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier(operationQueryFnName), undefined, [ | ||
typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier("deepMerge"), undefined, [ | ||
typescript_1.factory.createIdentifier("fetcherOptions"), | ||
typescript_1.factory.createIdentifier("variables"), | ||
]), | ||
useQueryIdentifier === "useQuery" | ||
? typescript_1.factory.createConditionalExpression(typescript_1.factory.createBinaryExpression(typescript_1.factory.createIdentifier("variables"), typescript_1.default.SyntaxKind.EqualsEqualsEqualsToken, typescript_1.factory.createPropertyAccessExpression(typescript_1.factory.createIdentifier("reactQuery"), typescript_1.factory.createIdentifier("skipToken"))), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), typescript_1.factory.createIdentifier("variables"), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.ColonToken), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier("deepMerge"), undefined, [ | ||
typescript_1.factory.createIdentifier("fetcherOptions"), | ||
typescript_1.factory.createIdentifier("variables"), | ||
])) | ||
: typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier("deepMerge"), undefined, [ | ||
typescript_1.factory.createIdentifier("fetcherOptions"), | ||
typescript_1.factory.createIdentifier("variables"), | ||
]), | ||
])), | ||
@@ -266,0 +273,0 @@ typescript_1.factory.createSpreadAssignment(typescript_1.factory.createIdentifier("options")), |
@@ -15,14 +15,10 @@ "use strict"; | ||
export function deepMerge<Target, Source>( | ||
target: Target, | ||
source: Source | ||
): Source { | ||
export function deepMerge<T, U extends T>(target: T, source: U): U { | ||
const returnType = (target || {}) as U; | ||
for (const key in source) { | ||
if (source[key] instanceof Object) | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
Object.assign(source[key], deepMerge((target as any)[key], source[key])); | ||
Object.assign(source[key], deepMerge(returnType[key], source[key])); | ||
} | ||
Object.assign(target || {}, source); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return target as any; | ||
Object.assign(returnType || {}, source); | ||
return returnType; | ||
} | ||
@@ -29,0 +25,0 @@ `; |
{ | ||
"name": "@openapi-codegen/typescript", | ||
"version": "11.0.0", | ||
"version": "11.0.1", | ||
"description": "OpenAPI Codegen typescript generators", | ||
@@ -44,3 +44,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "1528978a2546602ee652121324a44f947e41054c" | ||
"gitHead": "934de555052ad1ecf926ac332912e9b484b10f7b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
233986
2880