Browse Source

Merge pull request #5204 from abpframework/feat/5203

Accept __default as placeholder for default parameters in proxy generator
pull/5209/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
f1efb61a1e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      npm/ng-packs/packages/schematics/src/commands/api/index.ts
  2. 6
      npm/ng-packs/packages/schematics/src/commands/proxy/index.ts
  3. 10
      npm/ng-packs/packages/schematics/src/utils/common.ts

4
npm/ng-packs/packages/schematics/src/commands/api/index.ts

@ -23,13 +23,15 @@ import {
getRootNamespace,
interpolate,
ModelGeneratorParams,
removeDefaultPlaceholders,
resolveProject,
serializeParameters,
} from '../../utils';
import * as cases from '../../utils/text';
import { Schema as GenerateProxySchema } from './schema';
export default function(params: GenerateProxySchema) {
export default function(schema: GenerateProxySchema) {
const params = removeDefaultPlaceholders(schema);
const moduleName = strings.camelize(params.module || 'app');
return chain([

6
npm/ng-packs/packages/schematics/src/commands/proxy/index.ts

@ -13,11 +13,13 @@ import {
createApiDefinitionSaver,
getApiDefinition,
getSourceUrl,
removeDefaultPlaceholders,
resolveProject,
} from '../../utils';
import { Schema as GenerateProxySchema } from './schema';
export default function(params: GenerateProxySchema) {
export default function(schema: GenerateProxySchema) {
const params = removeDefaultPlaceholders(schema);
const moduleName = strings.camelize(params.module || 'app');
return chain([
@ -32,7 +34,7 @@ export default function(params: GenerateProxySchema) {
data,
`${targetPath}/shared/api-definition.json`,
);
const createApi = schematic('api', params);
const createApi = schematic('api', schema);
return branchAndMerge(chain([saveApiDefinition, createApi]));
},

10
npm/ng-packs/packages/schematics/src/utils/common.ts

@ -23,3 +23,13 @@ export function readFileInTree(tree: Tree, filePath: string): ts.SourceFile {
const text = buffer.toString('utf-8');
return ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true);
}
export function removeDefaultPlaceholders<T>(oldParams: T) {
const newParams: Record<string, any> = {};
Object.entries(oldParams).forEach(([key, value]) => {
newParams[key] = value === '__default' ? undefined : value;
});
return newParams as T;
}

Loading…
Cancel
Save