Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol codegen fixes via protocol tests #141

Merged
merged 6 commits into from
Mar 4, 2020
Merged

Conversation

kstich
Copy link
Contributor

@kstich kstich commented Mar 4, 2020

Contains the following fixes, each in their own commit for ease of review:

  • Fix timestamp serde around TS string types
const labelValue: string = Math.round(input.memberEpochSeconds.getTime() / 1000).toString();
  • Update parseFloat call to remove second param
contents.headerDouble = parseFloat(output.headers['x-double']);
  • Add metadata to modeled error outputs
response = {
    ...await deserializeAws_restJson1_1ComplexErrorResponse(output, context),
    $metadata: deserializeMetadata(output),
}
  • Update output shapes being MetadataBearers
    This commit removes the MetadataBearer type for non-error output
    shapes in the model. This makes them not require having a metadata
    property when being reused as non-response shapes (batches, etc.)
    Output shapes instead become MetadataBearers as part of compound
    types in the Command and Client codegen.
// Command specific alias shape is also the MetadataBearer
export type RecursiveShapesCommandOutput = RecursiveShapesInputOutput & __MetadataBearer;

// Client output union uses output MetadataBearers as well
export type ServiceOutputTypes =
  | __MetadataBearer
//  ...
  | RecursiveShapesInputOutput & __MetadataBearer;
  • Fix handling for query collection deserialization
    This commit updates query collection serialization to properly create
    Set types. It also fixes an issue where query collections of non-string
    simple types were not deserializing to their proper primitive type.
// Handle query collections of non-strings
contents.headerBooleanList = (output.headers['x-booleanlist'] || "").split(',').map(_entry => _entry === 'true');

// And handle sets
contents.headerStringSet = new Set((output.headers['x-stringset'] || "").split(',').map(_entry => _entry));
  • Fix header handling in pre-parsed errors
if (parsedOutput.headers["x-header"] !== undefined) {
    contents.Header = parsedOutput.headers['x-header'];
  }

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

kstich added 6 commits March 3, 2020 14:25
This commit removes the MetadataBearer type for non-error output
shapes in the model. This makes them not require having a metadata
property when being reused as non-response shapes (batches, etc.)
Output shapes instead become MetadataBearers as part of compound
types in the Command and Client codegen.
This commit updates query collection serialization to properly create
Set types. It also fixes an issue where query collections of non-string
simple types were not deserializing to their proper primitive type.
@kstich kstich requested a review from srchase March 4, 2020 17:08
@kstich kstich merged commit 3a73fba into master Mar 4, 2020
@kstich kstich deleted the protocol_fixes_3 branch March 4, 2020 17:42
srchase pushed a commit to srchase/smithy-typescript that referenced this pull request Mar 17, 2023
* Fix timestamp serde around TS string types

* Update parseFloat call to remove second param

* Add metadata to modeled error outputs

* Update output shapes being MetadataBearers

This commit removes the MetadataBearer type for non-error output
shapes in the model. This makes them not require having a metadata
property when being reused as non-response shapes (batches, etc.)
Output shapes instead become MetadataBearers as part of compound
types in the Command and Client codegen.

* Fix handling for query collection deserialization

This commit updates query collection serialization to properly create
Set types. It also fixes an issue where query collections of non-string
simple types were not deserializing to their proper primitive type.

* Fix header handling in pre-parsed errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants