@azure-tools/typespec-go 0.17.5-dev.4 → 0.17.5-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/codegen/core/example.js +11 -11
- package/dist/src/codegen/core/example.js.map +1 -1
- package/dist/src/codegen/core/helpers.d.ts +3 -8
- package/dist/src/codegen/core/helpers.d.ts.map +1 -1
- package/dist/src/codegen/core/helpers.js +28 -44
- package/dist/src/codegen/core/helpers.js.map +1 -1
- package/dist/src/codegen/core/imports.d.ts.map +1 -1
- package/dist/src/codegen/core/imports.js +3 -0
- package/dist/src/codegen/core/imports.js.map +1 -1
- package/dist/src/codegen/core/models.d.ts.map +1 -1
- package/dist/src/codegen/core/models.js +171 -129
- package/dist/src/codegen/core/models.js.map +1 -1
- package/dist/src/codegen/core/operations.js +4 -4
- package/dist/src/codegen/core/operations.js.map +1 -1
- package/dist/src/codegen/core/options.js +1 -5
- package/dist/src/codegen/core/options.js.map +1 -1
- package/dist/src/codegen/core/request-handler.d.ts.map +1 -1
- package/dist/src/codegen/core/request-handler.js +23 -19
- package/dist/src/codegen/core/request-handler.js.map +1 -1
- package/dist/src/codegen/core/response-handler.js +12 -10
- package/dist/src/codegen/core/response-handler.js.map +1 -1
- package/dist/src/codegen/core/responses.js +4 -17
- package/dist/src/codegen/core/responses.js.map +1 -1
- package/dist/src/codegen/core/unions.js +21 -16
- package/dist/src/codegen/core/unions.js.map +1 -1
- package/dist/src/codegen/fake/servers.js +81 -68
- package/dist/src/codegen/fake/servers.js.map +1 -1
- package/dist/src/codemodel/client.js +1 -1
- package/dist/src/codemodel/client.js.map +1 -1
- package/dist/src/codemodel/method.d.ts +1 -3
- package/dist/src/codemodel/method.d.ts.map +1 -1
- package/dist/src/codemodel/method.js +1 -2
- package/dist/src/codemodel/method.js.map +1 -1
- package/dist/src/codemodel/param.d.ts +41 -29
- package/dist/src/codemodel/param.d.ts.map +1 -1
- package/dist/src/codemodel/param.js +33 -33
- package/dist/src/codemodel/param.js.map +1 -1
- package/dist/src/codemodel/result.d.ts +12 -10
- package/dist/src/codemodel/result.d.ts.map +1 -1
- package/dist/src/codemodel/result.js +2 -4
- package/dist/src/codemodel/result.js.map +1 -1
- package/dist/src/codemodel/type.d.ts +80 -51
- package/dist/src/codemodel/type.d.ts.map +1 -1
- package/dist/src/codemodel/type.js +65 -27
- package/dist/src/codemodel/type.js.map +1 -1
- package/dist/src/tcgcadapter/clients.d.ts.map +1 -1
- package/dist/src/tcgcadapter/clients.js +46 -51
- package/dist/src/tcgcadapter/clients.js.map +1 -1
- package/dist/src/tcgcadapter/helpers.d.ts +2 -23
- package/dist/src/tcgcadapter/helpers.d.ts.map +1 -1
- package/dist/src/tcgcadapter/helpers.js +16 -82
- package/dist/src/tcgcadapter/helpers.js.map +1 -1
- package/dist/src/tcgcadapter/types.d.ts +5 -3
- package/dist/src/tcgcadapter/types.d.ts.map +1 -1
- package/dist/src/tcgcadapter/types.js +92 -42
- package/dist/src/tcgcadapter/types.js.map +1 -1
- package/package.json +11 -11
|
@@ -6,73 +6,6 @@ import * as tcgc from "@azure-tools/typespec-client-generator-core";
|
|
|
6
6
|
import * as tsp from "@typespec/compiler";
|
|
7
7
|
import * as go from "../codemodel/index.js";
|
|
8
8
|
import * as naming from "../naming/index.js";
|
|
9
|
-
/**
|
|
10
|
-
* creates XMLInfo for models and model fields.
|
|
11
|
-
* returns undefined if no XMLInfo is required.
|
|
12
|
-
*
|
|
13
|
-
* @param src the source information to adapt
|
|
14
|
-
* @returns XMLInfo or undefined
|
|
15
|
-
*/
|
|
16
|
-
export function adaptXMLInfo(src) {
|
|
17
|
-
const xmlInfo = new go.XMLInfo();
|
|
18
|
-
let returnXMLInfo = false;
|
|
19
|
-
if (src.xml?.name && src.xml.name !== src.goTypeName) {
|
|
20
|
-
xmlInfo.name = src.xml.name;
|
|
21
|
-
returnXMLInfo = true;
|
|
22
|
-
}
|
|
23
|
-
if (src.xml?.attribute) {
|
|
24
|
-
xmlInfo.attribute = true;
|
|
25
|
-
returnXMLInfo = true;
|
|
26
|
-
}
|
|
27
|
-
if (src.type.kind === "slice") {
|
|
28
|
-
const elementXMLInfo = hasXMLInfo(src.type.elementType);
|
|
29
|
-
if (src.xml?.unwrapped === false) {
|
|
30
|
-
if (src.xml.itemsName) {
|
|
31
|
-
xmlInfo.wraps = src.xml.itemsName;
|
|
32
|
-
}
|
|
33
|
-
else if (elementXMLInfo?.name) {
|
|
34
|
-
xmlInfo.wraps = elementXMLInfo.name;
|
|
35
|
-
}
|
|
36
|
-
else if (src.orTypeName !== src.goTypeName) {
|
|
37
|
-
xmlInfo.wraps = src.orTypeName;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
xmlInfo.wraps = src.goTypeName;
|
|
41
|
-
}
|
|
42
|
-
returnXMLInfo = true;
|
|
43
|
-
}
|
|
44
|
-
else if (elementXMLInfo?.name) {
|
|
45
|
-
xmlInfo.name = elementXMLInfo.name;
|
|
46
|
-
returnXMLInfo = true;
|
|
47
|
-
}
|
|
48
|
-
else if (src.orTypeName !== src.goTypeName) {
|
|
49
|
-
// we can land here if the Go-specific type name was renamed to remove stuttering
|
|
50
|
-
xmlInfo.name = src.orTypeName;
|
|
51
|
-
returnXMLInfo = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else if (src.xml?.unwrapped && src.type.kind === "string") {
|
|
55
|
-
// an unwrapped string means it's text
|
|
56
|
-
xmlInfo.text = true;
|
|
57
|
-
// the ",chardata" tag is mutually exclusive
|
|
58
|
-
// with a name tag so clear it if set
|
|
59
|
-
xmlInfo.name = undefined;
|
|
60
|
-
returnXMLInfo = true;
|
|
61
|
-
}
|
|
62
|
-
return returnXMLInfo ? xmlInfo : undefined;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* returns any XMLInfo available for the provided type or undefined
|
|
66
|
-
*
|
|
67
|
-
* @param type the type to inspect for XMLInfo
|
|
68
|
-
* @returns the XMLInfo or undefined
|
|
69
|
-
*/
|
|
70
|
-
export function hasXMLInfo(type) {
|
|
71
|
-
if ("xml" in type) {
|
|
72
|
-
return type.xml;
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
9
|
/**
|
|
77
10
|
* returns true if model is a polymorphic root type.
|
|
78
11
|
*
|
|
@@ -92,22 +25,23 @@ export function isPolymorphicRoot(model) {
|
|
|
92
25
|
return false;
|
|
93
26
|
}
|
|
94
27
|
}
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
28
|
+
/** narrows type to a PtrType within the conditional block */
|
|
29
|
+
export function isPtrType(type) {
|
|
30
|
+
switch (type.kind) {
|
|
31
|
+
case "constant":
|
|
32
|
+
case "etag":
|
|
33
|
+
case "literal":
|
|
34
|
+
case "model":
|
|
35
|
+
case "multipartContent":
|
|
36
|
+
case "polymorphicModel":
|
|
37
|
+
case "scalar":
|
|
38
|
+
case "string":
|
|
39
|
+
case "time":
|
|
40
|
+
case "unionStruct":
|
|
41
|
+
return true;
|
|
42
|
+
default:
|
|
43
|
+
return false;
|
|
105
44
|
}
|
|
106
|
-
return (type.kind === "unknown" ||
|
|
107
|
-
type.kind === "array" ||
|
|
108
|
-
type.kind === "bytes" ||
|
|
109
|
-
type.kind === "dict" ||
|
|
110
|
-
(type.kind === "model" && isPolymorphicRoot(type)));
|
|
111
45
|
}
|
|
112
46
|
/** contains the set of client options */
|
|
113
47
|
const clientOptionKinds = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/tcgcadapter/helpers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,IAAI,MAAM,6CAA6C,CAAC;AACpE,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,EAAE,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F,sFAAsF;QACtF,qFAAqF;QACrF,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACnD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AACjD,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,cAAc,CAAC,KAAwB;IACrD,uDAAuD;IACvD,6DAA6D;IAC7D,OAAO,CACL,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,eAAe,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CACjG,CAAC;AACJ,CAAC"}
|
|
@@ -22,9 +22,9 @@ export declare class TypeAdapter {
|
|
|
22
22
|
*/
|
|
23
23
|
adaptTypes(): void;
|
|
24
24
|
private getPagedResponses;
|
|
25
|
-
getWireType(type: tcgc.SdkType, elementTypeByValue: boolean, substituteDiscriminator: boolean): go.WireType
|
|
25
|
+
getWireType(type: tcgc.SdkType, elementTypeByValue: boolean, substituteDiscriminator: boolean, xmlItemsName?: string): Exclude<go.WireType, go.Ptr>;
|
|
26
26
|
private getTimeType;
|
|
27
|
-
getReadSeekCloser(sliceOf: boolean): go.
|
|
27
|
+
getReadSeekCloser(sliceOf: boolean): go.ReadSeekCloser | go.Slice<go.ReadSeekCloser>;
|
|
28
28
|
/**
|
|
29
29
|
* returns the Go code model type for streaming.MultipartContent.
|
|
30
30
|
* contentType is the fixed content type for the part (e.g. "image/png").
|
|
@@ -35,7 +35,7 @@ export declare class TypeAdapter {
|
|
|
35
35
|
* @param contentType set when the request uses a fixed content type
|
|
36
36
|
* @returns the go.MultipartContent instance
|
|
37
37
|
*/
|
|
38
|
-
getMultipartContent(sliceOf: boolean, contentType?: string): go.
|
|
38
|
+
getMultipartContent(sliceOf: boolean, contentType?: string): go.MultipartContent | go.Slice<go.MultipartContent>;
|
|
39
39
|
private getBuiltInType;
|
|
40
40
|
private getConstantType;
|
|
41
41
|
getETagType(): go.ETag;
|
|
@@ -48,6 +48,8 @@ export declare class TypeAdapter {
|
|
|
48
48
|
* @returns a Go literal
|
|
49
49
|
*/
|
|
50
50
|
getLiteral<T extends go.LiteralType = go.LiteralType>(type: T, value: unknown, extensibleEnum?: boolean): go.Literal<T>;
|
|
51
|
+
/** returns a pointer to the specified type */
|
|
52
|
+
getPtrType<T extends go.PtrType>(goType: T): go.Ptr<T>;
|
|
51
53
|
/** returns a Go string type */
|
|
52
54
|
getStringType(): go.String;
|
|
53
55
|
private getInterfaceType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tcgcadapter/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,IAAI,MAAM,6CAA6C,CAAC;AAGpE,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK5C,wDAAwD;AACxD,qBAAa,WAAW;IACtB,sCAAsC;IACtC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC;IAE9B,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC;IAGjC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;IAGlE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2B;IACjD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgC;gBAEhD,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS;IAQzD;;;;;OAKG;IACH,MAAM,IAAI,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,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC;IAoBtD,OAAO,CAAC,cAAc;IAiItB,OAAO,CAAC,eAAe;IAuBvB,WAAW,IAAI,EAAE,CAAC,IAAI;IAWtB;;;;;;;OAOG;IACH,UAAU,CAAC,CAAC,SAAS,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,EAClD,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,OAAO,EACd,cAAc,GAAE,OAAc,GAC7B,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAsChB,8CAA8C;IAC9C,UAAU,CAAC,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAyCtD,+BAA+B;IAC/B,aAAa,IAAI,EAAE,CAAC,MAAM;IAU1B,OAAO,CAAC,gBAAgB;IA2CxB,OAAO,CAAC,QAAQ;IAuGhB,OAAO,CAAC,uBAAuB;IAc/B,OAAO,CAAC,aAAa;IAqHrB,OAAO,CAAC,iBAAiB;IAwCzB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,eAAe;IA4IvB,iDAAiD;IACjD,OAAO,CAAC,eAAe;IAsBvB,0DAA0D;IAC1D,OAAO,CAAC,aAAa;IAsDrB,OAAO,CAAC,cAAc;CAyCvB"}
|
|
@@ -125,8 +125,8 @@ export class TypeAdapter {
|
|
|
125
125
|
}
|
|
126
126
|
if (content.addlProps) {
|
|
127
127
|
const annotations = new go.ModelFieldAnnotations(false, false, true, false);
|
|
128
|
-
const addlPropsType = new go.Map(this.getMapValueType(content.addlProps, false, false)
|
|
129
|
-
const addlProps = new go.ModelField("AdditionalProperties", addlPropsType,
|
|
128
|
+
const addlPropsType = new go.Map(this.getMapValueType(content.addlProps, false, false));
|
|
129
|
+
const addlProps = new go.ModelField("AdditionalProperties", addlPropsType, "", annotations);
|
|
130
130
|
modelType.go.fields.push(addlProps);
|
|
131
131
|
}
|
|
132
132
|
this.getPkg().models.push(modelType.go);
|
|
@@ -163,7 +163,7 @@ export class TypeAdapter {
|
|
|
163
163
|
// returns the Go code model type for the specified SDK type.
|
|
164
164
|
// the operation is idempotent, so getting the same type multiple times
|
|
165
165
|
// returns the same instance of the converted type.
|
|
166
|
-
getWireType(type, elementTypeByValue, substituteDiscriminator) {
|
|
166
|
+
getWireType(type, elementTypeByValue, substituteDiscriminator, xmlItemsName) {
|
|
167
167
|
switch (type.kind) {
|
|
168
168
|
case "boolean":
|
|
169
169
|
case "bytes":
|
|
@@ -188,11 +188,11 @@ export class TypeAdapter {
|
|
|
188
188
|
case "url":
|
|
189
189
|
return this.getBuiltInType(type);
|
|
190
190
|
case "array": {
|
|
191
|
-
let
|
|
191
|
+
let valueType = type.valueType;
|
|
192
192
|
let nullable = false;
|
|
193
|
-
if (
|
|
193
|
+
if (valueType.kind === "nullable") {
|
|
194
194
|
// unwrap the nullable type
|
|
195
|
-
|
|
195
|
+
valueType = valueType.type;
|
|
196
196
|
nullable = true;
|
|
197
197
|
}
|
|
198
198
|
// prefer elementTypeByValue. if false, then if the array elements have been explicitly marked as nullable then prefer that, else fall back to our usual algorithm
|
|
@@ -200,22 +200,24 @@ export class TypeAdapter {
|
|
|
200
200
|
? true
|
|
201
201
|
: nullable
|
|
202
202
|
? false
|
|
203
|
-
: this.codeModel.options["slice-elements-byval"]
|
|
204
|
-
|
|
205
|
-
const keyName = recursiveKeyName(`array-${myElementTypeByValue}`, elementType, substituteDiscriminator);
|
|
203
|
+
: this.codeModel.options["slice-elements-byval"] === true;
|
|
204
|
+
const keyName = recursiveKeyName(`array-${myElementTypeByValue}${xmlItemsName ? `-${xmlItemsName}` : ""}`, valueType, substituteDiscriminator);
|
|
206
205
|
let arrayType = this.types.get(keyName);
|
|
207
206
|
if (arrayType) {
|
|
208
207
|
return arrayType;
|
|
209
208
|
}
|
|
210
|
-
const
|
|
211
|
-
switch (
|
|
209
|
+
const elementType = this.getWireType(valueType, elementTypeByValue, substituteDiscriminator);
|
|
210
|
+
switch (elementType.kind) {
|
|
212
211
|
case "constantDef":
|
|
213
212
|
case "constantValue":
|
|
214
213
|
case "etag":
|
|
215
214
|
case "literal":
|
|
216
|
-
throw new AdapterError("UnsupportedTsp", `unsupported kind ${
|
|
215
|
+
throw new AdapterError("UnsupportedTsp", `unsupported kind ${elementType.kind} for slice element type`, type.valueType.__raw?.node);
|
|
217
216
|
}
|
|
218
|
-
arrayType = new go.Slice(
|
|
217
|
+
arrayType = new go.Slice(!myElementTypeByValue && helpers.isPtrType(elementType)
|
|
218
|
+
? this.getPtrType(elementType)
|
|
219
|
+
: elementType);
|
|
220
|
+
arrayType.xmlName = xmlItemsName;
|
|
219
221
|
this.types.set(keyName, arrayType);
|
|
220
222
|
return arrayType;
|
|
221
223
|
}
|
|
@@ -235,13 +237,13 @@ export class TypeAdapter {
|
|
|
235
237
|
// forces GMT and Unix is absolute), so restrict it to that encoding.
|
|
236
238
|
return this.getTimeType(type.encode, getDateTimeEncoding(type.encode) === "RFC3339");
|
|
237
239
|
case "dict": {
|
|
238
|
-
const
|
|
239
|
-
const keyName = recursiveKeyName(`dict
|
|
240
|
+
const valueType = this.getMapValueType(type.valueType, elementTypeByValue, substituteDiscriminator);
|
|
241
|
+
const keyName = recursiveKeyName(`dict${valueType.kind === "ptr" ? "-ptr" : ""}`, type.valueType, substituteDiscriminator);
|
|
240
242
|
let mapType = this.types.get(keyName);
|
|
241
243
|
if (mapType) {
|
|
242
244
|
return mapType;
|
|
243
245
|
}
|
|
244
|
-
mapType = new go.Map(
|
|
246
|
+
mapType = new go.Map(valueType);
|
|
245
247
|
this.types.set(keyName, mapType);
|
|
246
248
|
return mapType;
|
|
247
249
|
}
|
|
@@ -301,7 +303,7 @@ export class TypeAdapter {
|
|
|
301
303
|
if (!rsc) {
|
|
302
304
|
rsc = new go.ReadSeekCloser();
|
|
303
305
|
if (sliceOf) {
|
|
304
|
-
rsc = new go.Slice(rsc
|
|
306
|
+
rsc = new go.Slice(rsc);
|
|
305
307
|
}
|
|
306
308
|
this.types.set(keyName, rsc);
|
|
307
309
|
}
|
|
@@ -330,7 +332,7 @@ export class TypeAdapter {
|
|
|
330
332
|
const ct = contentType ? new go.Literal(this.getStringType(), `"${contentType}"`) : undefined;
|
|
331
333
|
mpc = new go.MultipartContent(ct);
|
|
332
334
|
if (sliceOf) {
|
|
333
|
-
mpc = new go.Slice(mpc
|
|
335
|
+
mpc = new go.Slice(mpc);
|
|
334
336
|
}
|
|
335
337
|
this.types.set(keyName, mpc);
|
|
336
338
|
}
|
|
@@ -531,6 +533,46 @@ export class TypeAdapter {
|
|
|
531
533
|
}
|
|
532
534
|
return literalType;
|
|
533
535
|
}
|
|
536
|
+
/** returns a pointer to the specified type */
|
|
537
|
+
getPtrType(goType) {
|
|
538
|
+
let ptrKey = "ptr-";
|
|
539
|
+
switch (goType.kind) {
|
|
540
|
+
case "constant":
|
|
541
|
+
case "etag":
|
|
542
|
+
case "model":
|
|
543
|
+
case "multipartContent":
|
|
544
|
+
case "polymorphicModel":
|
|
545
|
+
case "unionStruct":
|
|
546
|
+
ptrKey += goType.name;
|
|
547
|
+
break;
|
|
548
|
+
case "literal": {
|
|
549
|
+
// enum-value literals hold a ConstantValue object; key by its unique name.
|
|
550
|
+
const literal = goType.literal;
|
|
551
|
+
ptrKey +=
|
|
552
|
+
goType.type.kind === "constant"
|
|
553
|
+
? `${goType.kind}-${literal.name}`
|
|
554
|
+
: `${goType.kind}-${goType.type.kind}-${literal}`;
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
case "scalar":
|
|
558
|
+
ptrKey += `${goType.kind}-${goType.type}-${goType.encodeAsString}`;
|
|
559
|
+
break;
|
|
560
|
+
case "string":
|
|
561
|
+
ptrKey += `${goType.kind}`;
|
|
562
|
+
break;
|
|
563
|
+
case "time":
|
|
564
|
+
ptrKey += `${goType.kind}-${goType.format}-${goType.utc}`;
|
|
565
|
+
break;
|
|
566
|
+
default:
|
|
567
|
+
goType;
|
|
568
|
+
}
|
|
569
|
+
let ptrType = this.types.get(ptrKey);
|
|
570
|
+
if (!ptrType) {
|
|
571
|
+
ptrType = new go.Ptr(goType);
|
|
572
|
+
this.types.set(ptrKey, ptrType);
|
|
573
|
+
}
|
|
574
|
+
return ptrType;
|
|
575
|
+
}
|
|
534
576
|
/** returns a Go string type */
|
|
535
577
|
getStringType() {
|
|
536
578
|
const stringKey = "string";
|
|
@@ -644,13 +686,11 @@ export class TypeAdapter {
|
|
|
644
686
|
}
|
|
645
687
|
else {
|
|
646
688
|
modelType = new go.Model(this.getPkg(), modelName, annotations, usage);
|
|
647
|
-
//
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
xml: model.serializationOptions.xml,
|
|
653
|
-
});
|
|
689
|
+
// no XML support for polymorphic types
|
|
690
|
+
if (model.serializationOptions.xml?.name &&
|
|
691
|
+
model.serializationOptions.xml.name !== modelType.name) {
|
|
692
|
+
modelType.xmlName = model.serializationOptions.xml.name;
|
|
693
|
+
}
|
|
654
694
|
}
|
|
655
695
|
modelType.docs.summary = model.summary;
|
|
656
696
|
modelType.docs.description = model.doc;
|
|
@@ -696,7 +736,7 @@ export class TypeAdapter {
|
|
|
696
736
|
type = this.getMultipartContent(prop.type.kind === "array", fixedContentType);
|
|
697
737
|
}
|
|
698
738
|
else {
|
|
699
|
-
type = this.getWireType(prop.type, isMultipartFormData, true);
|
|
739
|
+
type = this.getWireType(prop.type, isMultipartFormData, true, prop.serializationOptions.xml?.itemsName);
|
|
700
740
|
}
|
|
701
741
|
if (prop.visibility) {
|
|
702
742
|
// the field is read-only IFF the only visibility attribute present is Read.
|
|
@@ -723,10 +763,11 @@ export class TypeAdapter {
|
|
|
723
763
|
isExactName: prop.isExactName,
|
|
724
764
|
access: prop.access,
|
|
725
765
|
});
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
const
|
|
766
|
+
// pointer-capable types are wrapped in a pointer. the exception is multipart/form
|
|
767
|
+
// data fields, which default to by-value with only the optional ones being
|
|
768
|
+
// pointer-to-type (see the isMultipartFormData comment above).
|
|
769
|
+
const usePtr = isMultipartFormData ? prop.optional : true;
|
|
770
|
+
const field = new go.ModelField(fieldName, usePtr && helpers.isPtrType(type) ? this.getPtrType(type) : type, serializedName, annotations);
|
|
730
771
|
field.docs.summary = prop.summary;
|
|
731
772
|
field.docs.description = prop.doc;
|
|
732
773
|
if (prop.discriminator && modelType.discriminatorValue) {
|
|
@@ -736,20 +777,26 @@ export class TypeAdapter {
|
|
|
736
777
|
field.defaultValue = this.getDiscriminatorLiteral(prop);
|
|
737
778
|
}
|
|
738
779
|
else if (prop.clientDefaultValue) {
|
|
739
|
-
|
|
740
|
-
|
|
780
|
+
const unwrappedPtr = go.unwrapPtr(type);
|
|
781
|
+
if (!go.isLiteralValueType(unwrappedPtr)) {
|
|
782
|
+
throw new AdapterError("InternalError", `unexpected client side default kind ${unwrappedPtr.kind} for field ${field.name}`, prop.__raw?.node);
|
|
741
783
|
}
|
|
742
|
-
field.defaultValue = this.getLiteral(
|
|
784
|
+
field.defaultValue = this.getLiteral(unwrappedPtr, prop.clientDefaultValue, helpers.isExtensibleEnum(prop.type));
|
|
743
785
|
if (!field.docs.summary && !field.docs.description) {
|
|
744
786
|
field.docs.summary = helpers.getClientDefaultValueDoc(field.defaultValue);
|
|
745
787
|
}
|
|
746
788
|
}
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
789
|
+
if (prop.serializationOptions.xml?.attribute) {
|
|
790
|
+
field.xmlKind = "attribute";
|
|
791
|
+
}
|
|
792
|
+
else if (prop.serializationOptions.xml?.unwrapped) {
|
|
793
|
+
if (type.kind === "string") {
|
|
794
|
+
field.xmlKind = "text";
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
field.xmlKind = "unwrappedList";
|
|
798
|
+
}
|
|
799
|
+
}
|
|
753
800
|
if (helpers.hasDecorator("@deserializeEmptyStringAsNull", prop.decorators)) {
|
|
754
801
|
field.annotations.unmarshalEmptyStringAsNil = true;
|
|
755
802
|
}
|
|
@@ -929,7 +976,7 @@ export class TypeAdapter {
|
|
|
929
976
|
case "literal":
|
|
930
977
|
throw new AdapterError("UnsupportedTsp", `unsupported kind ${valueType.kind} for map value type`, sdkType.__raw?.node);
|
|
931
978
|
default:
|
|
932
|
-
return valueType;
|
|
979
|
+
return helpers.isPtrType(valueType) ? this.getPtrType(valueType) : valueType;
|
|
933
980
|
}
|
|
934
981
|
}
|
|
935
982
|
/** adapts the SDK type to an encoded string array type */
|
|
@@ -964,7 +1011,7 @@ export class TypeAdapter {
|
|
|
964
1011
|
default:
|
|
965
1012
|
throw new AdapterError("UnsupportedTsp", `unsupported kind ${sdkType.valueType.kind} for string encoded array`, sdkType.__raw?.node);
|
|
966
1013
|
}
|
|
967
|
-
sliceArray = new go.SliceArray(
|
|
1014
|
+
sliceArray = new go.SliceArray(this.codeModel.options["slice-elements-byval"] ? elementType : this.getPtrType(elementType), getSliceArrayDelimiter(encoding));
|
|
968
1015
|
this.types.set(keyName, sliceArray);
|
|
969
1016
|
return sliceArray;
|
|
970
1017
|
}
|
|
@@ -983,7 +1030,8 @@ export class TypeAdapter {
|
|
|
983
1030
|
if (!go.isUnionVariantType(type)) {
|
|
984
1031
|
throw new AdapterError("UnsupportedTsp", `unsupported kind ${variant.kind} for union variant`, variant.__raw?.node);
|
|
985
1032
|
}
|
|
986
|
-
|
|
1033
|
+
const fieldType = helpers.isPtrType(type) ? this.getPtrType(type) : type;
|
|
1034
|
+
goUnion.fields.push(new go.UnionField(recursiveVariantFieldName(fieldType), fieldType));
|
|
987
1035
|
}
|
|
988
1036
|
goUnion.docs.summary = sdkUnion.summary;
|
|
989
1037
|
goUnion.docs.description = sdkUnion.doc;
|
|
@@ -1084,6 +1132,8 @@ function recursiveVariantFieldName(type) {
|
|
|
1084
1132
|
return `Literal${recursiveVariantFieldName(type.type)}`;
|
|
1085
1133
|
case "map":
|
|
1086
1134
|
return `MapOf${recursiveVariantFieldName(type.valueType)}`;
|
|
1135
|
+
case "ptr":
|
|
1136
|
+
return recursiveVariantFieldName(type.ptrType);
|
|
1087
1137
|
case "slice":
|
|
1088
1138
|
return `SliceOf${recursiveVariantFieldName(type.elementType)}`;
|
|
1089
1139
|
case "scalar":
|