Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default async function runExecutor(
options.globalProperties,
options.typeMappings,
options.silent,
options.templateDir,
outputDir,
);

Expand All @@ -41,6 +42,7 @@ async function generateSources(
globalProperties: string,
typeMappings: string,
silent: boolean,
templateDir: string,
outputDir: string,
): Promise<number> {
mkdirSync(outputDir, { recursive: true });
Expand Down Expand Up @@ -71,6 +73,10 @@ async function generateSources(
args.push('--global-property', globalProperties);
}

if (templateDir) {
args.push('--template-dir', templateDir);
}

logger.info(`[command]: ${command} ${args.join(' ')}`);

const child = spawn(command, args, { stdio: silent ? 'ignore' : 'pipe' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface GenerateApiLibSourcesExecutorSchema {
globalProperties?: string;
typeMappings?: string;
silent?: boolean;
templateDir?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
"type": "boolean",
"description": "Whether or not to suppress generator output",
"default": false
},
"templateDir": {
"type": "string",
"description": "The path (relative to the workspace root) to folder containing the template files"
}
},
"required": []
Expand Down
16 changes: 10 additions & 6 deletions packages/nx-plugin-openapi/src/generators/api-lib/generator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// Nrwl
import {
addProjectConfiguration, formatFiles, generateFiles, GeneratorCallback,
addProjectConfiguration,
formatFiles,
generateFiles,
GeneratorCallback,
getWorkspaceLayout,
joinPathFragments, names,
joinPathFragments,
names,
offsetFromRoot,
ProjectType,
readWorkspaceConfiguration, Tree, updateJson
readWorkspaceConfiguration,
Tree,
updateJson,
} from '@nrwl/devkit';
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
// Third Parties
Expand All @@ -16,9 +22,6 @@ import init from '../init/generator';
// Schemas
import { ApiLibGeneratorSchema } from './schema';




const projectType: ProjectType = 'library';

interface NormalizedSchema extends ApiLibGeneratorSchema {
Expand Down Expand Up @@ -88,6 +91,7 @@ const getExecutorOptions = (options: NormalizedSchema): GenerateApiLibSourcesExe
: [options.projectRootApiSpecLib, options.sourceSpecFileRelativePath].join('/'),
additionalProperties: options.additionalProperties,
globalProperties: options.globalProperties,
templateDir: options.templateDir,
};

if (options.isRemoteSpec && options.sourceSpecUrlAuthorizationHeaders) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export interface ApiLibGeneratorSchema {
sourceSpecFileRelativePath?: string;
additionalProperties?: string;
globalProperties?: string;
templateDir?: string;
skipFormat?: boolean;
}
6 changes: 6 additions & 0 deletions packages/nx-plugin-openapi/src/generators/api-lib/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
"x-prompt": "Do you want to specify any global properties for the generator? key1=value1,key2=value2 (https://openapi-generator.tech/docs/globals)",
"default": ""
},
"templateDir": {
"type": "string",
"description": "The path (relative to the workspace root) to the folder containing your custom templates",
"x-prompt": "If you want to use custom templates, what's the path of the folder that contains these files?",
"default": ""
},
"skipFormat": {
"description": "Skip formatting files.",
"type": "boolean",
Expand Down