Skip to content

Commit dea7bd9

Browse files
committed
test types and other fixes
1 parent 64b312c commit dea7bd9

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

packages/core/src/submodules/cbor/SmithyRpcV2CborProtocol.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ describe(SmithyRpcV2CborProtocol.name, () => {
153153
const protocol = new SmithyRpcV2CborProtocol({ defaultNamespace: "" });
154154
const httpRequest = await protocol.serializeRequest(
155155
{
156+
namespace: "ns",
156157
name: "dummy",
157158
input: testCase.schema,
158159
output: "unit",
@@ -256,6 +257,7 @@ describe(SmithyRpcV2CborProtocol.name, () => {
256257
});
257258
const output = await protocol.deserializeResponse(
258259
{
260+
namespace: "ns",
259261
name: "dummy",
260262
input: "unit",
261263
output: testCase.schema,

packages/core/src/submodules/cbor/SmithyRpcV2CborProtocol.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { RpcProtocol } from "@smithy/core/protocols";
2-
import type { ErrorSchema, OperationSchema } from "@smithy/core/schema";
2+
import type { ErrorSchema } from "@smithy/core/schema";
33
import { deref, NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
44
import type {
55
EndpointBearer,
66
HandlerExecutionContext,
77
HttpRequest as IHttpRequest,
88
HttpResponse as IHttpResponse,
99
MetadataBearer,
10+
OperationSchema,
1011
ResponseMetadata,
1112
SerdeFunctions,
1213
} from "@smithy/types";

packages/core/src/submodules/schema/schemas/NormalizedSchema.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,18 @@ export class NormalizedSchema implements INormalizedSchema {
9595
* Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
9696
*/
9797
public static of(ref: SchemaRef): NormalizedSchema {
98+
if (ref instanceof NormalizedSchema) {
99+
return ref;
100+
}
98101
if (Array.isArray(ref)) {
102+
const [ns, traits] = ref;
103+
if (ns instanceof NormalizedSchema) {
104+
Object.assign(ns.getMergedTraits(), NormalizedSchema.translateTraits(traits));
105+
return ns;
106+
}
99107
// An aggregate schema must be initialized with members and the member retrieved through the aggregate
100108
// container.
101-
throw new Error("@smithy/core/schema - may not init member schema.");
102-
}
103-
if (ref instanceof NormalizedSchema) {
104-
return ref;
109+
throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(ref, null, 2)}.`);
105110
}
106111
return new NormalizedSchema(ref);
107112
}
@@ -386,15 +391,17 @@ export class NormalizedSchema implements INormalizedSchema {
386391
*
387392
* This does NOT return list and map members, it is only for structures.
388393
*
389-
* @deprecated use structIterator instead.
394+
* @deprecated use (checked) structIterator instead.
390395
*
391396
* @returns a map of member names to member schemas (normalized).
392397
*/
393398
public getMemberSchemas(): Record<string, NormalizedSchema> {
394399
const buffer = {} as any;
395-
for (const [k, v] of this.structIterator()) {
396-
buffer[k] = v;
397-
}
400+
try {
401+
for (const [k, v] of this.structIterator()) {
402+
buffer[k] = v;
403+
}
404+
} catch (ignored) {}
398405
return buffer;
399406
}
400407

packages/types/src/schema/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export type SchemaTraits = TraitBitVector | SchemaTraitsObject;
5050
* @public
5151
*/
5252
export interface TraitsSchema {
53+
namespace: string;
5354
name: string;
5455
traits: SchemaTraits;
5556
}

0 commit comments

Comments
 (0)