Browse Source

use bracket notation on decriptors for invalid keys

pull/8015/head
Arman Ozak 6 years ago
parent
commit
5080d94c72
  1. 9
      npm/ng-packs/packages/schematics/src/models/method.ts

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

@ -1,5 +1,6 @@
import { eBindingSourceId, eMethodModifier } from '../enums'; import { eBindingSourceId, eMethodModifier } from '../enums';
import { camel } from '../utils'; import { isValidProp } from '../utils/prop';
import { camel } from '../utils/text';
import { ParameterInBody } from './api-definition'; import { ParameterInBody } from './api-definition';
import { Property } from './model'; import { Property } from './model';
import { Omissible } from './util'; import { Omissible } from './util';
@ -44,7 +45,11 @@ export class Body {
const { bindingSourceId, descriptorName, jsonName, name, nameOnMethod } = param; const { bindingSourceId, descriptorName, jsonName, name, nameOnMethod } = param;
const camelName = camel(name); const camelName = camel(name);
const paramName = jsonName || camelName; const paramName = jsonName || camelName;
const value = descriptorName ? `${descriptorName}.${paramName}` : nameOnMethod; const value = descriptorName
? isValidProp(paramName)
? `${descriptorName}.${paramName}`
: `${descriptorName}['${paramName}']`
: nameOnMethod;
switch (bindingSourceId) { switch (bindingSourceId) {
case eBindingSourceId.Model: case eBindingSourceId.Model:

Loading…
Cancel
Save