@easy-breezy/generator-api
Advanced tools
Comparing version 2.0.19 to 2.0.20
@@ -20,2 +20,8 @@ import ts from 'typescript'; | ||
parameters = ts.factory.createTypeReferenceNode(ts.factory.createQualifiedName(ts.factory.createIdentifier(options.importName), ts.factory.createIdentifier('IParameters')), undefined); | ||
if (!options.schemas.body?.required?.length && !options.schemas.query?.required?.length && !options.schemas.path?.required?.length && !options.schemas.header?.required?.length) { | ||
parameters = ts.factory.createUnionTypeNode([ | ||
parameters, | ||
ts.factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword) | ||
]); | ||
} | ||
args.push(ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier('params'), undefined, undefined, undefined)); | ||
@@ -50,6 +56,10 @@ } | ||
returnObject.push(ts.factory.createPropertyAssignment(ts.factory.createIdentifier(MAP[schemaKey]), ts.factory.createObjectLiteralExpression(keys.map((key) => { | ||
let access = ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('params'), ts.factory.createIdentifier(schemaKey)), ts.factory.createIdentifier(key)); | ||
if (!options.schemas.query?.required?.includes(key)) { | ||
access = ts.factory.createPropertyAccessChain(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('params'), ts.factory.createIdentifier(schemaKey)), ts.factory.createToken(ts.SyntaxKind.QuestionDotToken), ts.factory.createIdentifier(key)); | ||
let paramsAccess = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('params'), ts.factory.createIdentifier(schemaKey)); | ||
if (!options.schemas[schemaKey]?.required?.length) { | ||
paramsAccess = ts.factory.createPropertyAccessChain(ts.factory.createIdentifier('params'), ts.factory.createToken(ts.SyntaxKind.QuestionDotToken), ts.factory.createIdentifier(schemaKey)); | ||
} | ||
let access = ts.factory.createPropertyAccessExpression(paramsAccess, ts.factory.createIdentifier(key)); | ||
if (!options.schemas[schemaKey]?.required?.includes(key)) { | ||
access = ts.factory.createPropertyAccessChain(paramsAccess, ts.factory.createToken(ts.SyntaxKind.QuestionDotToken), ts.factory.createIdentifier(key)); | ||
} | ||
return ts.factory.createPropertyAssignment(ts.factory.createIdentifier(key), access); | ||
@@ -69,3 +79,3 @@ }), true))); | ||
])); | ||
const sourceFile = ts.createSourceFile('extension.ts', '', ts.ScriptTarget.Latest, true, ts.ScriptKind.TS); | ||
const sourceFile = ts.createSourceFile('endpoint.ts', '', ts.ScriptTarget.Latest, true, ts.ScriptKind.TS); | ||
const printer = ts.createPrinter(); | ||
@@ -72,0 +82,0 @@ return { |
{ | ||
"name": "@easy-breezy/generator-api", | ||
"version": "2.0.19", | ||
"version": "2.0.20", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65552
1088