Skip to content

Commit ad86ee4

Browse files
committed
Use a constant for the metadata property definition instead of a function that returns a static string
1 parent 12f46d2 commit ad86ee4

File tree

5 files changed

+23
-25
lines changed

5 files changed

+23
-25
lines changed

packages/service-types-generator/__tests__/Components/Type/Exception.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {Exception} from "../../../lib/Components/Type/Exception";
22
import {IndentedSection} from "../../../lib/Components/IndentedSection";
33
import {
4-
getOutputMetadataPropertyDefinition,
5-
METADATA_PROPERTY_IMPORT
6-
} from "../../../lib/Components/Type/getOutputMetadataPropertyDefinition";
4+
METADATA_PROPERTY_IMPORT,
5+
OUTPUT_METADATA_PROPERTY,
6+
} from "../../../lib/Components/Type/constants";
77

88
describe('Exception', () => {
99
it('should include standard exception members if not defined', () => {
@@ -38,7 +38,7 @@ export interface MyException {
3838
*/
3939
message?: string;
4040
41-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
41+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
4242
}`
4343
);
4444
});
@@ -82,7 +82,7 @@ export interface MyException {
8282
*/
8383
message?: string;
8484
85-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
85+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
8686
}`
8787
);
8888
});
@@ -126,7 +126,7 @@ export interface MyException {
126126
*/
127127
name?: string;
128128
129-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
129+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
130130
}`
131131
);
132132
});
@@ -170,7 +170,7 @@ export interface MyException {
170170
*/
171171
stack?: string;
172172
173-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
173+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
174174
}`
175175
);
176176
});

packages/service-types-generator/__tests__/Components/Type/Output.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {
1414
import {IndentedSection} from "../../../lib/Components/IndentedSection";
1515
import {
1616
METADATA_PROPERTY_IMPORT,
17-
getOutputMetadataPropertyDefinition
18-
} from "../../../lib/Components/Type/getOutputMetadataPropertyDefinition";
17+
OUTPUT_METADATA_PROPERTY,
18+
} from "../../../lib/Components/Type/constants";
1919

2020
describe('Output', () => {
2121
it(
@@ -37,7 +37,7 @@ describe('Output', () => {
3737
* Operation output
3838
*/
3939
export interface ${name} {
40-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
40+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
4141
}`
4242
);
4343
}
@@ -71,7 +71,7 @@ export interface ${name}<${GENERIC_STREAM_TYPE}> {
7171
*/
7272
data?: ${getMemberType(StreamingBlob)};
7373
74-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
74+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
7575
}`
7676
);
7777
}
@@ -108,7 +108,7 @@ export interface ${name}<${GENERIC_STREAM_TYPE}> {
108108
*/
109109
data?: ${getMemberType(dataMember.shape, dataMember)};
110110
111-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
111+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
112112
}`
113113
);
114114
}
@@ -148,7 +148,7 @@ export interface ${name} {
148148
*/
149149
data?: ${getMemberType(structure)};
150150
151-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
151+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
152152
}`
153153
);
154154
});
@@ -195,7 +195,7 @@ export interface ${name} {
195195
*/
196196
data?: ${getMemberType(structureList)};
197197
198-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
198+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
199199
}`
200200
);
201201
});
@@ -253,7 +253,7 @@ export interface ${name} {
253253
*/
254254
data?: ${getMemberType(structureMap)};
255255
256-
${new IndentedSection(getOutputMetadataPropertyDefinition())}
256+
${new IndentedSection(OUTPUT_METADATA_PROPERTY)}
257257
}`
258258
);
259259
});

packages/service-types-generator/lib/Components/Type/Exception.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {IndentedSection} from "../IndentedSection";
44
import {getUnmarshalledShapeName} from "./helpers";
55
import {Import} from "../Import";
66
import {
7-
getOutputMetadataPropertyDefinition,
87
METADATA_PROPERTY_IMPORT,
9-
} from "./getOutputMetadataPropertyDefinition";
8+
OUTPUT_METADATA_PROPERTY,
9+
} from "./constants";
1010

1111
interface InnateMember {
1212
memberName: string;
@@ -22,7 +22,7 @@ export class Exception extends Structure {
2222
.concat(
2323
Object.keys(this.shape.members)
2424
.map(this.getMemberDefinition, this),
25-
getOutputMetadataPropertyDefinition()
25+
OUTPUT_METADATA_PROPERTY
2626
);
2727
return `
2828
${this.imports}

packages/service-types-generator/lib/Components/Type/Output.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {GENERIC_STREAM_TYPE} from '../../constants';
44
import {IndentedSection} from "../IndentedSection";
55
import {getUnmarshalledShapeName, hasStreamingBody} from "./helpers";
66
import {
7-
getOutputMetadataPropertyDefinition,
87
METADATA_PROPERTY_IMPORT,
9-
} from './getOutputMetadataPropertyDefinition';
8+
OUTPUT_METADATA_PROPERTY,
9+
} from './constants';
1010

1111
export class Output extends Structure {
1212
toString(): string {
@@ -18,7 +18,7 @@ export interface ${this.shape.name}${hasStreamingBody(this.shape) ? `<${GENERIC_
1818
${new IndentedSection(
1919
Object.keys(this.shape.members)
2020
.map(this.getMemberDefinition, this)
21-
.concat(getOutputMetadataPropertyDefinition())
21+
.concat(OUTPUT_METADATA_PROPERTY)
2222
.join('\n\n')
2323
)}
2424
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ export const METADATA_PROPERTY_IMPORT = new Import(
77
`ResponseMetadata as ${MD_PROP_ALIAS}`
88
);
99

10-
export function getOutputMetadataPropertyDefinition(): string {
11-
return `
10+
export const OUTPUT_METADATA_PROPERTY = `
1211
/**
1312
* Metadata about the response received, including the HTTP status code, HTTP
1413
* headers, and any request identifiers recognized by the SDK.
1514
*/
1615
$metadata: ${MD_PROP_ALIAS};
17-
`.trim();
18-
}
16+
`.trim();

0 commit comments

Comments
 (0)