Browse Source

Merge pull request #8013 from abpframework/feat/7852

Handled jsonName property on Angular proxy generation
pull/8022/head
Mehmet Erim 6 years ago
committed by GitHub
parent
commit
e4bf25c583
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13156
      npm/ng-packs/packages/schematics/src/mocks/api-definition.json
  2. 2
      npm/ng-packs/packages/schematics/src/models/api-definition.ts
  3. 9
      npm/ng-packs/packages/schematics/src/models/method.ts
  4. 2
      npm/ng-packs/packages/schematics/src/utils/model.ts

13156
npm/ng-packs/packages/schematics/src/mocks/api-definition.json

File diff suppressed because it is too large

2
npm/ng-packs/packages/schematics/src/models/api-definition.ts

@ -16,6 +16,7 @@ export interface Type {
export interface PropertyDef {
name: string;
jsonName: string | null;
type: string;
typeSimple: string;
isRequired: boolean;
@ -61,6 +62,7 @@ export interface ParameterInSignature {
export interface ParameterInBody {
nameOnMethod: string;
name: string;
jsonName: string | null;
type: string;
typeSimple: string;
isOptional: boolean;

9
npm/ng-packs/packages/schematics/src/models/method.ts

@ -41,20 +41,21 @@ export class Body {
url: string;
registerActionParameter = (param: ParameterInBody) => {
const { bindingSourceId, descriptorName, name, nameOnMethod } = param;
const { bindingSourceId, descriptorName, jsonName, name, nameOnMethod } = param;
const camelName = camel(name);
const value = descriptorName ? `${descriptorName}.${camelName}` : nameOnMethod;
const paramName = jsonName || camelName;
const value = descriptorName ? `${descriptorName}.${paramName}` : nameOnMethod;
switch (bindingSourceId) {
case eBindingSourceId.Model:
case eBindingSourceId.Query:
this.params.push(`${camelName}: ${value}`);
this.params.push(`${paramName}: ${value}`);
break;
case eBindingSourceId.Body:
this.body = value;
break;
case eBindingSourceId.Path:
const regex = new RegExp('{(' + camelName + '|' + name + ')}', 'g');
const regex = new RegExp('{(' + paramName + '|' + camelName + '|' + name + ')}', 'g');
this.url = this.url.replace(regex, '${' + value + '}');
break;
default:

2
npm/ng-packs/packages/schematics/src/utils/model.ts

@ -134,7 +134,7 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP
genericsCollector.reset();
typeDef.properties?.forEach(prop => {
const name = camel(prop.name);
const name = prop.jsonName || camel(prop.name);
const type = simplifyType(prop.typeSimple);
const refs = parseType(prop.type).reduce(
(acc: string[], r) => acc.concat(parseGenerics(r).toGenerics()),

Loading…
Cancel
Save