Skip to content

Commit

Permalink
fix(generation): Fix naming issues with EC2 inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
danopia committed Dec 21, 2021
1 parent 7b163b5 commit efd6d33
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions generation/protocol-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,23 @@ export default class ProtocolQueryCodegen extends ProtocolXmlCodegen {
for (const [field, spec] of Object.entries(inputStruct.members)) {
const shape = this.shapes.get(spec);
const defaultName = this.ucfirst(field, false);
const locationName = this.ucfirst(spec.queryName, true) ?? this.ucfirst(spec.locationName, false) ?? shape.spec.locationName ?? defaultName;
const baseNamePlaces = this.ucfirst(spec.queryName, true) ?? this.ucfirst(spec.locationName, false);
const locationName = baseNamePlaces ?? this.ucfirst(shape.spec.locationName, false) ?? defaultName;
const isRequired = (inputStruct.required ?? []).map(x => x.toLowerCase()).includes(field.toLowerCase());
const paramRef = `${paramsRef}[${JSON.stringify(field)}]`;

switch (shape.spec.type) {
// case 'boolean':
// chunks.push(` ${isRequired ? '' : `if (${paramRef} != null) `}body.append(${JSON.stringify(locationName)}, ${paramRef});`);
case 'list': {
const isFlattened = spec.flattened || shape.spec.flattened || this.ec2Mode;
const isFlattened = spec.flattened || shape.spec.flattened;
const listConfig: any = {};
// if (shape.spec.member.locationName) listConfig.entName = '.'+shape.spec.member.locationName;
// console.log(shape.name, [spec.queryName, spec.locationName, shape.spec.locationName, defaultName])
const listPrefix = isFlattened
? spec.queryName ?? spec.locationName ?? shape.spec.locationName ?? shape.spec.member.locationName ?? defaultName
: spec.queryName ?? spec.locationName ?? defaultName;
listConfig.entryPrefix = isFlattened
? baseNamePlaces ?? shape.spec.locationName ?? shape.spec.member.locationName ?? defaultName
: baseNamePlaces ?? defaultName;
listConfig.entryPrefix = (isFlattened || this.ec2Mode)
? '.'
: `.${shape.spec.locationName ?? shape.spec.member.locationName ?? 'member'}.`;
const innerShape = this.shapes.get(shape.spec.member);
Expand All @@ -92,8 +93,8 @@ export default class ProtocolQueryCodegen extends ProtocolXmlCodegen {
if (shape.spec.key.locationName) mapConfig.keyName = '.'+shape.spec.key.locationName;
if (shape.spec.value.locationName) mapConfig.valName = '.'+shape.spec.value.locationName;
const mapPrefix = isFlattened
? spec.queryName ?? spec.locationName ?? shape.spec.locationName ?? defaultName
: spec.queryName ?? spec.locationName ?? defaultName;
? locationName
: baseNamePlaces ?? defaultName;
mapConfig.entryPrefix = isFlattened
? '.'
: `.${shape.spec.locationName ?? 'entry'}.`;
Expand Down

0 comments on commit efd6d33

Please sign in to comment.