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

chore(clients): parse numbers more strictly #2662

Merged
merged 3 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions clients/client-accessanalyzer/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ import {
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import {
expectBoolean as __expectBoolean,
expectNumber as __expectNumber,
expectInt as __expectInt,
expectString as __expectString,
extendedEncodeURIComponent as __extendedEncodeURIComponent,
strictParseInt as __strictParseInt,
} from "@aws-sdk/smithy-client";
import {
Endpoint as __Endpoint,
Expand Down Expand Up @@ -887,7 +888,7 @@ export const serializeAws_restJson1UntagResourceCommand = async (
throw new Error("No value provided for input HTTP label: resourceArn.");
}
const query: any = {
...(input.tagKeys !== undefined && { tagKeys: (input.tagKeys || []).map((_entry) => _entry) }),
...(input.tagKeys !== undefined && { tagKeys: (input.tagKeys || []).map((_entry) => _entry as any) }),
};
let body: any;
return new __HttpRequest({
Expand Down Expand Up @@ -3504,7 +3505,7 @@ const deserializeAws_restJson1InternalServerExceptionResponse = async (
retryAfterSeconds: undefined,
};
if (parsedOutput.headers["retry-after"] !== undefined) {
contents.retryAfterSeconds = parseInt(parsedOutput.headers["retry-after"], 10);
contents.retryAfterSeconds = __strictParseInt(parsedOutput.headers["retry-after"]);
}
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
Expand Down Expand Up @@ -3578,7 +3579,7 @@ const deserializeAws_restJson1ThrottlingExceptionResponse = async (
retryAfterSeconds: undefined,
};
if (parsedOutput.headers["retry-after"] !== undefined) {
contents.retryAfterSeconds = parseInt(parsedOutput.headers["retry-after"], 10);
contents.retryAfterSeconds = __strictParseInt(parsedOutput.headers["retry-after"]);
}
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
Expand Down Expand Up @@ -4646,8 +4647,8 @@ const deserializeAws_restJson1NetworkOriginConfiguration = (
};

const deserializeAws_restJson1PathElement = (output: any, context: __SerdeContext): PathElement => {
if (__expectNumber(output.index) !== undefined) {
return { index: __expectNumber(output.index) as any };
if (__expectInt(output.index) !== undefined) {
return { index: __expectInt(output.index) as any };
}
if (__expectString(output.key) !== undefined) {
return { key: __expectString(output.key) as any };
Expand Down Expand Up @@ -4698,9 +4699,9 @@ const deserializeAws_restJson1PolicyGenerationList = (output: any, context: __Se

const deserializeAws_restJson1Position = (output: any, context: __SerdeContext): Position => {
return {
column: __expectNumber(output.column),
line: __expectNumber(output.line),
offset: __expectNumber(output.offset),
column: __expectInt(output.column),
line: __expectInt(output.line),
offset: __expectInt(output.offset),
} as any;
};

Expand Down Expand Up @@ -4865,8 +4866,8 @@ const deserializeAws_restJson1StatusReason = (output: any, context: __SerdeConte

const deserializeAws_restJson1Substring = (output: any, context: __SerdeContext): Substring => {
return {
length: __expectNumber(output.length),
start: __expectNumber(output.start),
length: __expectInt(output.length),
start: __expectInt(output.start),
} as any;
};

Expand Down
4 changes: 2 additions & 2 deletions clients/client-acm-pca/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ import {
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import {
expectBoolean as __expectBoolean,
expectNumber as __expectNumber,
expectInt as __expectInt,
expectString as __expectString,
} from "@aws-sdk/smithy-client";
import {
Expand Down Expand Up @@ -3374,7 +3374,7 @@ const deserializeAws_json1_1CrlConfiguration = (output: any, context: __SerdeCon
return {
CustomCname: __expectString(output.CustomCname),
Enabled: __expectBoolean(output.Enabled),
ExpirationInDays: __expectNumber(output.ExpirationInDays),
ExpirationInDays: __expectInt(output.ExpirationInDays),
S3BucketName: __expectString(output.S3BucketName),
S3ObjectAcl: __expectString(output.S3ObjectAcl),
} as any;
Expand Down
4 changes: 2 additions & 2 deletions clients/client-acm/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import {
ValidationException,
} from "../models/models_0";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { expectNumber as __expectNumber, expectString as __expectString } from "@aws-sdk/smithy-client";
import { expectInt as __expectInt, expectString as __expectString } from "@aws-sdk/smithy-client";
import {
Endpoint as __Endpoint,
HeaderBag as __HeaderBag,
Expand Down Expand Up @@ -2131,7 +2131,7 @@ const deserializeAws_json1_1ExpiryEventsConfiguration = (
context: __SerdeContext
): ExpiryEventsConfiguration => {
return {
DaysBeforeExpiry: __expectNumber(output.DaysBeforeExpiry),
DaysBeforeExpiry: __expectInt(output.DaysBeforeExpiry),
} as any;
};

Expand Down
28 changes: 14 additions & 14 deletions clients/client-alexa-for-business/protocols/Aws_json1_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ import {
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import {
expectBoolean as __expectBoolean,
expectNumber as __expectNumber,
expectInt as __expectInt,
expectString as __expectString,
} from "@aws-sdk/smithy-client";
import {
Expand Down Expand Up @@ -8947,7 +8947,7 @@ const deserializeAws_json1_1BusinessReportScheduleList = (

const deserializeAws_json1_1Category = (output: any, context: __SerdeContext): Category => {
return {
CategoryId: __expectNumber(output.CategoryId),
CategoryId: __expectInt(output.CategoryId),
CategoryName: __expectString(output.CategoryName),
} as any;
};
Expand Down Expand Up @@ -9412,7 +9412,7 @@ const deserializeAws_json1_1EndOfMeetingReminderMinutesList = (output: any, cont
if (entry === null) {
return null as any;
}
return __expectNumber(entry) as any;
return __expectInt(entry) as any;
});
};

Expand Down Expand Up @@ -9629,7 +9629,7 @@ const deserializeAws_json1_1GetSkillGroupResponse = (output: any, context: __Ser

const deserializeAws_json1_1InstantBooking = (output: any, context: __SerdeContext): InstantBooking => {
return {
DurationInMinutes: __expectNumber(output.DurationInMinutes),
DurationInMinutes: __expectInt(output.DurationInMinutes),
Enabled: __expectBoolean(output.Enabled),
} as any;
};
Expand Down Expand Up @@ -9927,7 +9927,7 @@ const deserializeAws_json1_1Profile = (output: any, context: __SerdeContext): Pr
DistanceUnit: __expectString(output.DistanceUnit),
IsDefault: __expectBoolean(output.IsDefault),
Locale: __expectString(output.Locale),
MaxVolumeLimit: __expectNumber(output.MaxVolumeLimit),
MaxVolumeLimit: __expectInt(output.MaxVolumeLimit),
MeetingRoomConfiguration:
output.MeetingRoomConfiguration !== undefined && output.MeetingRoomConfiguration !== null
? deserializeAws_json1_1MeetingRoomConfiguration(output.MeetingRoomConfiguration, context)
Expand Down Expand Up @@ -10020,7 +10020,7 @@ const deserializeAws_json1_1RejectSkillResponse = (output: any, context: __Serde
const deserializeAws_json1_1RequireCheckIn = (output: any, context: __SerdeContext): RequireCheckIn => {
return {
Enabled: __expectBoolean(output.Enabled),
ReleaseAfterMinutes: __expectNumber(output.ReleaseAfterMinutes),
ReleaseAfterMinutes: __expectInt(output.ReleaseAfterMinutes),
} as any;
};

Expand Down Expand Up @@ -10141,7 +10141,7 @@ const deserializeAws_json1_1SearchAddressBooksResponse = (
? deserializeAws_json1_1AddressBookDataList(output.AddressBooks, context)
: undefined,
NextToken: __expectString(output.NextToken),
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
} as any;
};

Expand All @@ -10152,7 +10152,7 @@ const deserializeAws_json1_1SearchContactsResponse = (output: any, context: __Se
? deserializeAws_json1_1ContactDataList(output.Contacts, context)
: undefined,
NextToken: __expectString(output.NextToken),
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
} as any;
};

Expand All @@ -10163,7 +10163,7 @@ const deserializeAws_json1_1SearchDevicesResponse = (output: any, context: __Ser
? deserializeAws_json1_1DeviceDataList(output.Devices, context)
: undefined,
NextToken: __expectString(output.NextToken),
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
} as any;
};

Expand All @@ -10177,7 +10177,7 @@ const deserializeAws_json1_1SearchNetworkProfilesResponse = (
? deserializeAws_json1_1NetworkProfileDataList(output.NetworkProfiles, context)
: undefined,
NextToken: __expectString(output.NextToken),
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
} as any;
};

Expand All @@ -10188,7 +10188,7 @@ const deserializeAws_json1_1SearchProfilesResponse = (output: any, context: __Se
output.Profiles !== undefined && output.Profiles !== null
? deserializeAws_json1_1ProfileDataList(output.Profiles, context)
: undefined,
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
} as any;
};

Expand All @@ -10199,7 +10199,7 @@ const deserializeAws_json1_1SearchRoomsResponse = (output: any, context: __Serde
output.Rooms !== undefined && output.Rooms !== null
? deserializeAws_json1_1RoomDataList(output.Rooms, context)
: undefined,
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
} as any;
};

Expand All @@ -10213,14 +10213,14 @@ const deserializeAws_json1_1SearchSkillGroupsResponse = (
output.SkillGroups !== undefined && output.SkillGroups !== null
? deserializeAws_json1_1SkillGroupDataList(output.SkillGroups, context)
: undefined,
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
} as any;
};

const deserializeAws_json1_1SearchUsersResponse = (output: any, context: __SerdeContext): SearchUsersResponse => {
return {
NextToken: __expectString(output.NextToken),
TotalCount: __expectNumber(output.TotalCount),
TotalCount: __expectInt(output.TotalCount),
Users:
output.Users !== undefined && output.Users !== null
? deserializeAws_json1_1UserDataList(output.Users, context)
Expand Down
5 changes: 3 additions & 2 deletions clients/client-amp/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@a
import {
expectString as __expectString,
extendedEncodeURIComponent as __extendedEncodeURIComponent,
strictParseInt as __strictParseInt,
} from "@aws-sdk/smithy-client";
import {
Endpoint as __Endpoint,
Expand Down Expand Up @@ -690,7 +691,7 @@ const deserializeAws_restJson1InternalServerExceptionResponse = async (
retryAfterSeconds: undefined,
};
if (parsedOutput.headers["retry-after"] !== undefined) {
contents.retryAfterSeconds = parseInt(parsedOutput.headers["retry-after"], 10);
contents.retryAfterSeconds = __strictParseInt(parsedOutput.headers["retry-after"]);
}
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
Expand Down Expand Up @@ -772,7 +773,7 @@ const deserializeAws_restJson1ThrottlingExceptionResponse = async (
serviceCode: undefined,
};
if (parsedOutput.headers["retry-after"] !== undefined) {
contents.retryAfterSeconds = parseInt(parsedOutput.headers["retry-after"], 10);
contents.retryAfterSeconds = __strictParseInt(parsedOutput.headers["retry-after"]);
}
const data: any = parsedOutput.body;
if (data.message !== undefined && data.message !== null) {
Expand Down
2 changes: 1 addition & 1 deletion clients/client-amplify/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ export const serializeAws_restJson1UntagResourceCommand = async (
throw new Error("No value provided for input HTTP label: resourceArn.");
}
const query: any = {
...(input.tagKeys !== undefined && { tagKeys: (input.tagKeys || []).map((_entry) => _entry) }),
...(input.tagKeys !== undefined && { tagKeys: (input.tagKeys || []).map((_entry) => _entry as any) }),
};
let body: any;
return new __HttpRequest({
Expand Down
6 changes: 3 additions & 3 deletions clients/client-amplifybackend/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import {
expectBoolean as __expectBoolean,
expectString as __expectString,
extendedEncodeURIComponent as __extendedEncodeURIComponent,
handleFloat as __handleFloat,
limitedParseFloat as __limitedParseFloat,
serializeFloat as __serializeFloat,
} from "@aws-sdk/smithy-client";
import {
Expand Down Expand Up @@ -4063,7 +4063,7 @@ const deserializeAws_restJson1BackendAPIAppSyncAuthSettings = (
return {
CognitoUserPoolId: __expectString(output.cognitoUserPoolId),
Description: __expectString(output.description),
ExpirationTime: __handleFloat(output.expirationTime),
ExpirationTime: __limitedParseFloat(output.expirationTime),
OpenIDAuthTTL: __expectString(output.openIDAuthTTL),
OpenIDClientId: __expectString(output.openIDClientId),
OpenIDIatTTL: __expectString(output.openIDIatTTL),
Expand Down Expand Up @@ -4224,7 +4224,7 @@ const deserializeAws_restJson1CreateBackendAuthPasswordPolicyConfig = (
output.additionalConstraints !== undefined && output.additionalConstraints !== null
? deserializeAws_restJson1ListOfAdditionalConstraintsElement(output.additionalConstraints, context)
: undefined,
MinimumLength: __handleFloat(output.minimumLength),
MinimumLength: __limitedParseFloat(output.minimumLength),
} as any;
};

Expand Down
Loading