@azure-tools/typespec-go 0.10.2 → 0.10.4
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/codegen.go/src/core/clientFactory.d.ts.map +1 -1
- package/dist/codegen.go/src/core/clientFactory.js +10 -4
- package/dist/codegen.go/src/core/clientFactory.js.map +1 -1
- package/dist/codegen.go/src/core/errors.d.ts +1 -1
- package/dist/codegen.go/src/core/errors.js +3 -3
- package/dist/codegen.go/src/core/errors.js.map +1 -1
- package/dist/codegen.go/src/core/example.d.ts.map +1 -1
- package/dist/codegen.go/src/core/example.js +28 -20
- package/dist/codegen.go/src/core/example.js.map +1 -1
- package/dist/codegen.go/src/core/gomod.d.ts.map +1 -1
- package/dist/codegen.go/src/core/gomod.js +11 -10
- package/dist/codegen.go/src/core/gomod.js.map +1 -1
- package/dist/codegen.go/src/core/helpers.d.ts.map +1 -1
- package/dist/codegen.go/src/core/helpers.js +40 -49
- package/dist/codegen.go/src/core/helpers.js.map +1 -1
- package/dist/codegen.go/src/core/imports.d.ts.map +1 -1
- package/dist/codegen.go/src/core/imports.js +3 -1
- package/dist/codegen.go/src/core/imports.js.map +1 -1
- package/dist/codegen.go/src/core/license.js.map +1 -1
- package/dist/codegen.go/src/core/models.d.ts.map +1 -1
- package/dist/codegen.go/src/core/models.js +18 -9
- package/dist/codegen.go/src/core/models.js.map +1 -1
- package/dist/codegen.go/src/core/operations.d.ts.map +1 -1
- package/dist/codegen.go/src/core/operations.js +26 -14
- package/dist/codegen.go/src/core/operations.js.map +1 -1
- package/dist/codegen.go/src/core/polymorphics.js.map +1 -1
- package/dist/codegen.go/src/core/responses.js +9 -4
- package/dist/codegen.go/src/core/responses.js.map +1 -1
- package/dist/codegen.go/src/emitter.js +44 -18
- package/dist/codegen.go/src/emitter.js.map +1 -1
- package/dist/codegen.go/src/fake/factory.js +2 -2
- package/dist/codegen.go/src/fake/factory.js.map +1 -1
- package/dist/codegen.go/src/fake/servers.js +10 -10
- package/dist/codegen.go/src/fake/servers.js.map +1 -1
- package/dist/codegen.go/src/index.js +3 -3
- package/dist/codegen.go/src/index.js.map +1 -1
- package/dist/codemodel.go/src/client.js +3 -3
- package/dist/codemodel.go/src/client.js.map +1 -1
- package/dist/codemodel.go/src/codeModel.js +3 -3
- package/dist/codemodel.go/src/codeModel.js.map +1 -1
- package/dist/codemodel.go/src/errors.d.ts +4 -4
- package/dist/codemodel.go/src/errors.d.ts.map +1 -1
- package/dist/codemodel.go/src/errors.js +3 -3
- package/dist/codemodel.go/src/errors.js.map +1 -1
- package/dist/codemodel.go/src/examples.js +3 -3
- package/dist/codemodel.go/src/examples.js.map +1 -1
- package/dist/codemodel.go/src/index.js +3 -3
- package/dist/codemodel.go/src/index.js.map +1 -1
- package/dist/codemodel.go/src/method.js +3 -3
- package/dist/codemodel.go/src/method.js.map +1 -1
- package/dist/codemodel.go/src/module.js +3 -3
- package/dist/codemodel.go/src/module.js.map +1 -1
- package/dist/codemodel.go/src/param.d.ts +1 -1
- package/dist/codemodel.go/src/param.d.ts.map +1 -1
- package/dist/codemodel.go/src/param.js +4 -3
- package/dist/codemodel.go/src/param.js.map +1 -1
- package/dist/codemodel.go/src/result.js +3 -3
- package/dist/codemodel.go/src/result.js.map +1 -1
- package/dist/codemodel.go/src/type.d.ts.map +1 -1
- package/dist/codemodel.go/src/type.js +3 -3
- package/dist/codemodel.go/src/type.js.map +1 -1
- package/dist/naming.go/src/mappings.d.ts.map +1 -1
- package/dist/naming.go/src/mappings.js +203 -41
- package/dist/naming.go/src/mappings.js.map +1 -1
- package/dist/naming.go/src/naming.d.ts.map +1 -1
- package/dist/naming.go/src/naming.js +6 -11
- package/dist/naming.go/src/naming.js.map +1 -1
- package/dist/typespec-go/src/emitter.d.ts.map +1 -1
- package/dist/typespec-go/src/emitter.js +1 -1
- package/dist/typespec-go/src/emitter.js.map +1 -1
- package/dist/typespec-go/src/lib.d.ts +2 -2
- package/dist/typespec-go/src/lib.d.ts.map +1 -1
- package/dist/typespec-go/src/lib.js +16 -16
- package/dist/typespec-go/src/lib.js.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/adapter.d.ts.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/adapter.js.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/clients.d.ts.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/clients.js +62 -24
- package/dist/typespec-go/src/tcgcadapter/clients.js.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/types.d.ts +8 -0
- package/dist/typespec-go/src/tcgcadapter/types.d.ts.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/types.js +53 -24
- package/dist/typespec-go/src/tcgcadapter/types.js.map +1 -1
- package/package.json +22 -22
|
@@ -10,7 +10,7 @@ const EmitterOptionsSchema = {
|
|
|
10
10
|
'azcore-version': {
|
|
11
11
|
type: 'string',
|
|
12
12
|
nullable: true,
|
|
13
|
-
description:
|
|
13
|
+
description: "Semantic version of azcore without the leading 'v' to use if different from the default version (e.g. 1.2.3).",
|
|
14
14
|
},
|
|
15
15
|
'containing-module': {
|
|
16
16
|
type: 'string',
|
|
@@ -47,7 +47,7 @@ const EmitterOptionsSchema = {
|
|
|
47
47
|
nullable: true,
|
|
48
48
|
description: 'Enables generation of spans for distributed tracing. The default is false.',
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
module: {
|
|
51
51
|
type: 'string',
|
|
52
52
|
nullable: true,
|
|
53
53
|
description: 'The module identity to use in go.mod. Mutually exclusive with containing-module.',
|
|
@@ -72,7 +72,7 @@ const EmitterOptionsSchema = {
|
|
|
72
72
|
nullable: true,
|
|
73
73
|
description: 'Indicates package has a single client. This will omit the Client prefix from options and response types. If multiple clients are detected, an error is returned. The default is false.',
|
|
74
74
|
},
|
|
75
|
-
|
|
75
|
+
stutter: {
|
|
76
76
|
type: 'string',
|
|
77
77
|
nullable: true,
|
|
78
78
|
description: 'Uses the specified value to remove stuttering from types and funcs instead of the built-in algorithm.',
|
|
@@ -104,30 +104,30 @@ const EmitterOptionsSchema = {
|
|
|
104
104
|
const libDef = {
|
|
105
105
|
name: '@azure-tools/typespec-go',
|
|
106
106
|
diagnostics: {
|
|
107
|
-
|
|
107
|
+
InternalError: {
|
|
108
108
|
severity: 'error',
|
|
109
109
|
messages: {
|
|
110
|
-
default: paramMessage `The emitter encountered an internal error during preprocessing. Please open an issue at https://github.com/Azure/autorest.go/issues and include the complete error message.\n${'stack'}
|
|
111
|
-
}
|
|
110
|
+
default: paramMessage `The emitter encountered an internal error during preprocessing. Please open an issue at https://github.com/Azure/autorest.go/issues and include the complete error message.\n${'stack'}`,
|
|
111
|
+
},
|
|
112
112
|
},
|
|
113
|
-
|
|
113
|
+
InvalidArgument: {
|
|
114
114
|
severity: 'error',
|
|
115
115
|
messages: {
|
|
116
|
-
default: paramMessage `Invalid arguments were passed to the emitter: ${'msg'}
|
|
117
|
-
}
|
|
116
|
+
default: paramMessage `Invalid arguments were passed to the emitter: ${'msg'}`,
|
|
117
|
+
},
|
|
118
118
|
},
|
|
119
|
-
|
|
119
|
+
NameCollision: {
|
|
120
120
|
severity: 'error',
|
|
121
121
|
messages: {
|
|
122
|
-
default: paramMessage `The emitter automatically renamed one or more types which resulted in a type name collision. Please update the client.tsp to rename the type(s) to avoid the collision: ${'msg'}
|
|
123
|
-
}
|
|
122
|
+
default: paramMessage `The emitter automatically renamed one or more types which resulted in a type name collision. Please update the client.tsp to rename the type(s) to avoid the collision: ${'msg'}`,
|
|
123
|
+
},
|
|
124
124
|
},
|
|
125
|
-
|
|
125
|
+
UnsupportedTsp: {
|
|
126
126
|
severity: 'error',
|
|
127
127
|
messages: {
|
|
128
|
-
default: paramMessage `The emitter encountered a TypeSpec definition that is currently not supported: ${'msg'}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
128
|
+
default: paramMessage `The emitter encountered a TypeSpec definition that is currently not supported: ${'msg'}`,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
131
|
},
|
|
132
132
|
emitter: {
|
|
133
133
|
options: EmitterOptionsSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../src/lib.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,qBAAqB,EAAkB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0BzF,MAAM,oBAAoB,GAAqC;IAC7D,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,IAAI;IAC1B,UAAU,EAAE;QACV,gBAAgB,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../src/lib.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,qBAAqB,EAAkB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA0BzF,MAAM,oBAAoB,GAAqC;IAC7D,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,IAAI;IAC1B,UAAU,EAAE;QACV,gBAAgB,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,+GAA+G;SAC7H;QACD,mBAAmB,EAAE;YACnB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,qFAAqF;SACnG;QACD,yBAAyB,EAAE;YACzB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,yHAAyH;SACvI;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,qIAAqI;SACnJ;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,sEAAsE;SACpF;QACD,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE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Q,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE;QACX,aAAa,EAAE;YACb,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,gLAAgL,OAAO,EAAE;aAC/M;SACF;QACD,eAAe,EAAE;YACf,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,iDAAiD,KAAK,EAAE;aAC9E;SACF;QACD,aAAa,EAAE;YACb,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,2KAA2K,KAAK,EAAE;aACxM;SACF;QACD,cAAc,EAAE;YACd,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,kFAAkF,KAAK,EAAE;aAC/G;SACF;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAoC,oBAAoB;KAChE;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAClD,gEAAgE;AAChE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAGzD,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAGzD,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;CAAG;AAE3C,+EAA+E;AAC/E,qBAAa,OAAO;IAClB;;;;;OAKG;WACU,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAyBjF,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IAEzC,OAAO;IAuCP,kEAAkE;IAClE,iBAAiB,IAAI,EAAE,CAAC,SAAS;CAclC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,KAAK,EAAE,MAAM,oCAAoC,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,iCAAiC,CAAC;AAC1D,OAAO,KAAK,IAAI,MAAM,6CAA6C,CAAC;AAGpE;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../src/tcgcadapter/adapter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE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AAI,YAAY,CAAC,eAAe,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../../../src/tcgcadapter/clients.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../../../src/tcgcadapter/clients.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAiD,WAAW,EAAE,MAAM,YAAY,CAAC;AAExF;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAc;IAKjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAkC;IAI/D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiC;gBAErD,EAAE,EAAE,WAAW;IAM3B;;;OAGG;IACH,YAAY;IAmBZ,OAAO,CAAC,oBAAoB;IAqS5B;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IAajC;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IA8B3B;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,WAAW;IAoHnB,OAAO,CAAC,cAAc;IAiDtB,OAAO,CAAC,qBAAqB;IAgR7B,OAAO,CAAC,gBAAgB;IAcxB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IA2K5B,OAAO,CAAC,0BAA0B;IAiBlC,OAAO,CAAC,qBAAqB;IAiM7B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,iBAAiB;IAoDzB,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,4BAA4B;IAQpC,OAAO,CAAC,6BAA6B;IAQrC,OAAO,CAAC,mBAAmB;IAsC3B,OAAO,CAAC,0BAA0B;IA8FlC,OAAO,CAAC,gBAAgB;CAuGzB"}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import * as tcgc from '@azure-tools/typespec-client-generator-core';
|
|
6
6
|
import { NoTarget } from '@typespec/compiler';
|
|
7
7
|
import * as go from '../../../codemodel.go/src/index.js';
|
|
8
|
-
import { capitalize, createOptionsTypeDescription, createResponseEnvelopeDescription, ensureNameCase, getEscapedReservedName, uncapitalize } from '../../../naming.go/src/naming.js';
|
|
8
|
+
import { capitalize, createOptionsTypeDescription, createResponseEnvelopeDescription, ensureNameCase, getEscapedReservedName, uncapitalize, } from '../../../naming.go/src/naming.js';
|
|
9
9
|
import { AdapterError } from './errors.js';
|
|
10
|
-
import { isTypePassedByValue } from './types.js';
|
|
10
|
+
import { adaptXMLInfo, isTypePassedByValue, hasXMLInfo } from './types.js';
|
|
11
11
|
/**
|
|
12
12
|
* used to convert tcgc clients and their methods to Go code model types
|
|
13
13
|
*/
|
|
@@ -338,7 +338,7 @@ export class ClientAdapter {
|
|
|
338
338
|
throw new AdapterError('InternalError', `too many scopes defined for credential type ${cred.type}`, cred.model);
|
|
339
339
|
}
|
|
340
340
|
const ctor = new go.Constructor(this.ta.getPkg(), `New${goClient.name}`);
|
|
341
|
-
ctor.parameters.push(new go.ClientCredentialParameter('credential', new go.TokenCredential(cred.flows[0].scopes.map(each => each.value))));
|
|
341
|
+
ctor.parameters.push(new go.ClientCredentialParameter('credential', new go.TokenCredential(cred.flows[0].scopes.map((each) => each.value))));
|
|
342
342
|
return ctor;
|
|
343
343
|
}
|
|
344
344
|
/**
|
|
@@ -435,9 +435,11 @@ export class ClientAdapter {
|
|
|
435
435
|
}
|
|
436
436
|
if (sdkMethod.lroMetadata.finalResponse?.resultSegments) {
|
|
437
437
|
// 'resultSegments' is designed for furture extensibility, currently only has one segment
|
|
438
|
-
goMethod.operationLocationResultPath = sdkMethod.lroMetadata.finalResponse.resultSegments
|
|
438
|
+
goMethod.operationLocationResultPath = sdkMethod.lroMetadata.finalResponse.resultSegments
|
|
439
|
+
.map((segment) => {
|
|
439
440
|
return segment.serializationOptions.json?.name;
|
|
440
|
-
})
|
|
441
|
+
})
|
|
442
|
+
.join('.');
|
|
441
443
|
}
|
|
442
444
|
};
|
|
443
445
|
const setPageableInfo = function (goMethod, sdkMethod) {
|
|
@@ -454,14 +456,16 @@ export class ClientAdapter {
|
|
|
454
456
|
}
|
|
455
457
|
}
|
|
456
458
|
if (sdkMethod.pagingMetadata.nextLinkSegments) {
|
|
457
|
-
goMethod.nextLinkName = capitalize(sdkMethod.pagingMetadata.nextLinkSegments
|
|
459
|
+
goMethod.nextLinkName = capitalize(sdkMethod.pagingMetadata.nextLinkSegments
|
|
460
|
+
.map((segment) => {
|
|
458
461
|
if (segment.kind === 'property') {
|
|
459
462
|
return ensureNameCase(segment.name);
|
|
460
463
|
}
|
|
461
464
|
else {
|
|
462
465
|
throw new AdapterError('UnsupportedTsp', `unsupported next link segment kind ${segment.kind}`, sdkMethod.__raw?.node);
|
|
463
466
|
}
|
|
464
|
-
})
|
|
467
|
+
})
|
|
468
|
+
.join('.'));
|
|
465
469
|
}
|
|
466
470
|
};
|
|
467
471
|
const statusCodes = getStatusCodes(sdkMethod.operation);
|
|
@@ -596,7 +600,7 @@ export class ClientAdapter {
|
|
|
596
600
|
let adaptedParam;
|
|
597
601
|
// for the @bodyRoot decorator opParam.type !== param.type which is obviously not a
|
|
598
602
|
// spread parameter. we also need to check the usage flag to disambiguate these cases.
|
|
599
|
-
if (opParam.kind === 'body' && opParam.type.kind === 'model' && opParam.type !== param.type &&
|
|
603
|
+
if (opParam.kind === 'body' && opParam.type.kind === 'model' && opParam.type !== param.type && opParam.type.usage & tcgc.UsageFlags.Spread) {
|
|
600
604
|
const paramStyle = this.adaptParameterStyle(param);
|
|
601
605
|
const paramName = getEscapedReservedName(ensureNameCase(param.name, paramStyle === 'required'), 'Param');
|
|
602
606
|
// if the param is required then it's always passed by value
|
|
@@ -673,7 +677,7 @@ export class ClientAdapter {
|
|
|
673
677
|
// Use the same naming approach as regular parameters for consistency
|
|
674
678
|
const paramGroupName = ensureNameCase(param.type.name);
|
|
675
679
|
// Remove the model from codeModel.models if it is a parameter group
|
|
676
|
-
const modelIndex = this.ta.getPkg().models.findIndex(m => m.name === paramGroupName);
|
|
680
|
+
const modelIndex = this.ta.getPkg().models.findIndex((m) => m.name === paramGroupName);
|
|
677
681
|
if (modelIndex >= 0) {
|
|
678
682
|
this.ta.getPkg().models.splice(modelIndex, 1);
|
|
679
683
|
}
|
|
@@ -708,7 +712,7 @@ export class ClientAdapter {
|
|
|
708
712
|
adaptedPropertyParam.group = paramGroup;
|
|
709
713
|
addParameterToMethod(adaptedPropertyParam, propertyOpParam);
|
|
710
714
|
// Only add to paramGroup.params if not already present
|
|
711
|
-
if (!paramGroup.params.some(p => p.name === adaptedPropertyParam.name)) {
|
|
715
|
+
if (!paramGroup.params.some((p) => p.name === adaptedPropertyParam.name)) {
|
|
712
716
|
paramGroup.params.push(adaptedPropertyParam);
|
|
713
717
|
}
|
|
714
718
|
}
|
|
@@ -879,6 +883,13 @@ export class ClientAdapter {
|
|
|
879
883
|
bodyType = this.ta.getReadSeekCloser(methodParam.type.kind === 'array');
|
|
880
884
|
}
|
|
881
885
|
adaptedParam = new go.BodyParameter(paramName, contentType, `"${opParam.defaultContentType}"`, bodyType, paramStyle, byVal);
|
|
886
|
+
if (contentType === 'XML' && methodParam.type.kind === 'array') {
|
|
887
|
+
adaptedParam.xml = adaptXMLInfo(this.ta.getPkg(), methodParam.type.decorators);
|
|
888
|
+
if (!adaptedParam.xml) {
|
|
889
|
+
adaptedParam.xml = new go.XMLInfo();
|
|
890
|
+
adaptedParam.xml.wrapper = methodParam.type.name;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
882
893
|
}
|
|
883
894
|
break;
|
|
884
895
|
case 'cookie':
|
|
@@ -917,7 +928,7 @@ export class ClientAdapter {
|
|
|
917
928
|
throw new AdapterError('InternalError', `unexpected kind ${type.kind} for QueryCollectionParameter ${methodParam.name}`, opParam.__raw?.node);
|
|
918
929
|
}
|
|
919
930
|
// TODO: unencoded query param
|
|
920
|
-
adaptedParam = new go.QueryCollectionParameter(paramName, opParam.serializedName, true, type, opParam.collectionFormat === 'simple' ? 'csv' :
|
|
931
|
+
adaptedParam = new go.QueryCollectionParameter(paramName, opParam.serializedName, true, type, opParam.collectionFormat === 'simple' ? 'csv' : opParam.collectionFormat === 'form' ? 'multi' : opParam.collectionFormat, paramStyle, byVal, location);
|
|
921
932
|
}
|
|
922
933
|
else {
|
|
923
934
|
// TODO: unencoded query param
|
|
@@ -1003,9 +1014,7 @@ export class ClientAdapter {
|
|
|
1003
1014
|
// however, we want the synthesized paged response envelope as that's what Go returns.
|
|
1004
1015
|
if (sdkMethod.kind === 'lropaging' || sdkMethod.kind === 'paging') {
|
|
1005
1016
|
// grab the paged response envelope type from the operation responses
|
|
1006
|
-
sdkResponseType = sdkMethod.kind === 'lropaging'
|
|
1007
|
-
? sdkMethod.lroMetadata.finalResponse?.result
|
|
1008
|
-
: sdkMethod.operation.responses[0].type;
|
|
1017
|
+
sdkResponseType = sdkMethod.kind === 'lropaging' ? sdkMethod.lroMetadata.finalResponse?.result : sdkMethod.operation.responses[0].type;
|
|
1009
1018
|
if (!sdkResponseType) {
|
|
1010
1019
|
throw new AdapterError('InternalError', `paged method ${method.name} has no synthesized response type`, sdkMethod.__raw?.node);
|
|
1011
1020
|
}
|
|
@@ -1064,7 +1073,7 @@ export class ClientAdapter {
|
|
|
1064
1073
|
// For polymorphic models, check if we can find a concrete type that matches the discriminator value
|
|
1065
1074
|
// If no concrete type is found, create a PolymorphicResult that uses the interface type
|
|
1066
1075
|
// else use the concrete type as the result type
|
|
1067
|
-
const concreteType = modelType.interface.possibleTypes.find(t => t.discriminatorValue?.literal === modelType.discriminatorValue?.literal);
|
|
1076
|
+
const concreteType = modelType.interface.possibleTypes.find((t) => t.discriminatorValue?.literal === modelType.discriminatorValue?.literal);
|
|
1068
1077
|
if (concreteType === undefined) {
|
|
1069
1078
|
respEnv.result = new go.PolymorphicResult(modelType.interface);
|
|
1070
1079
|
}
|
|
@@ -1105,7 +1114,25 @@ export class ClientAdapter {
|
|
|
1105
1114
|
else {
|
|
1106
1115
|
const resultType = this.ta.getWireType(sdkResponseType, false, false);
|
|
1107
1116
|
if (go.isMonomorphicResultType(resultType)) {
|
|
1108
|
-
|
|
1117
|
+
let fieldName;
|
|
1118
|
+
let xmlInfo;
|
|
1119
|
+
if (contentType === 'XML') {
|
|
1120
|
+
xmlInfo = adaptXMLInfo(method.receiver.type.pkg, sdkResponseType.decorators);
|
|
1121
|
+
if (!xmlInfo) {
|
|
1122
|
+
xmlInfo = new go.XMLInfo();
|
|
1123
|
+
}
|
|
1124
|
+
if (sdkResponseType.kind === 'array') {
|
|
1125
|
+
fieldName = sdkResponseType.name;
|
|
1126
|
+
const elementType = resultType.elementType;
|
|
1127
|
+
const elementTypeXmlName = hasXMLInfo(elementType)?.wrapper;
|
|
1128
|
+
xmlInfo.wraps = elementTypeXmlName ?? go.getTypeDeclaration(elementType, method.receiver.type.pkg);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
if (!fieldName) {
|
|
1132
|
+
fieldName = this.recursiveTypeName(sdkResponseType, false);
|
|
1133
|
+
}
|
|
1134
|
+
respEnv.result = new go.MonomorphicResult(fieldName, contentType, resultType, isTypePassedByValue(sdkResponseType));
|
|
1135
|
+
respEnv.result.xml = xmlInfo;
|
|
1109
1136
|
}
|
|
1110
1137
|
else {
|
|
1111
1138
|
throw new AdapterError('InternalError', `invalid monomorphic result type ${resultType.kind}`, sdkResponseType.__raw?.node);
|
|
@@ -1194,12 +1221,17 @@ export class ClientAdapter {
|
|
|
1194
1221
|
return structType;
|
|
1195
1222
|
}
|
|
1196
1223
|
adaptHeaderScalarType(sdkType, forParam) {
|
|
1224
|
+
// It would be ideal to force the ETag type for the known ETag headers per the RFC.
|
|
1225
|
+
// However, doing so introduces too many breaking changes (if-match and if-none-match).
|
|
1226
|
+
// TODO: If we decide to force ETag types by header name in the future,
|
|
1227
|
+
// update adaptHeaderScalarType to receive the header name and dispatch
|
|
1228
|
+
// to this.ta.getETagType() for ETag-related headers.
|
|
1197
1229
|
// for header params, we never pass the element type by pointer
|
|
1198
1230
|
const type = this.ta.getWireType(sdkType, forParam, false);
|
|
1199
1231
|
if (go.isHeaderScalarType(type)) {
|
|
1200
1232
|
return type;
|
|
1201
1233
|
}
|
|
1202
|
-
throw new AdapterError('InternalError', `unexpected header scalar parameter type ${
|
|
1234
|
+
throw new AdapterError('InternalError', `unexpected header scalar parameter type ${type.kind}`, sdkType.__raw?.node);
|
|
1203
1235
|
}
|
|
1204
1236
|
adaptPathScalarParameterType(sdkType) {
|
|
1205
1237
|
const type = this.ta.getWireType(sdkType, false, false);
|
|
@@ -1284,6 +1316,10 @@ export class ClientAdapter {
|
|
|
1284
1316
|
}
|
|
1285
1317
|
}
|
|
1286
1318
|
else {
|
|
1319
|
+
// skip literal parameters as they're set internally when composing the request
|
|
1320
|
+
if (go.isLiteralParameter(goParams[0].style)) {
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1287
1323
|
const paramExample = new go.ParameterExample(goParams[0], this.adaptExampleType(param.value, goParams[0]?.type));
|
|
1288
1324
|
if (goParams[0]?.group) {
|
|
1289
1325
|
goExample.optionalParamsGroup.push(paramExample);
|
|
@@ -1294,13 +1330,15 @@ export class ClientAdapter {
|
|
|
1294
1330
|
}
|
|
1295
1331
|
}
|
|
1296
1332
|
// only handle 200 response
|
|
1297
|
-
const response = example.responses.find((v) => {
|
|
1333
|
+
const response = example.responses.find((v) => {
|
|
1334
|
+
return v.statusCode === 200;
|
|
1335
|
+
});
|
|
1298
1336
|
if (response) {
|
|
1299
1337
|
goExample.responseEnvelope = new go.ResponseEnvelopeExample(method.returns);
|
|
1300
1338
|
// skip adding headers for LROs as they aren't useful on the response envelope
|
|
1301
1339
|
if (!go.isLROMethod(method)) {
|
|
1302
1340
|
for (const header of response.headers) {
|
|
1303
|
-
const goHeader = method.returns.headers.find(h => h.headerName === header.header.serializedName);
|
|
1341
|
+
const goHeader = method.returns.headers.find((h) => h.headerName === header.header.serializedName);
|
|
1304
1342
|
if (!goHeader) {
|
|
1305
1343
|
throw new AdapterError('InternalError', `can not find go header for example header ${header.header.serializedName}`);
|
|
1306
1344
|
}
|
|
@@ -1404,8 +1442,9 @@ export class ClientAdapter {
|
|
|
1404
1442
|
if (goType.kind === 'interface' || goType.kind === 'model' || goType.kind === 'polymorphicModel') {
|
|
1405
1443
|
let concreteType;
|
|
1406
1444
|
if (goType.kind === 'interface') {
|
|
1407
|
-
|
|
1408
|
-
|
|
1445
|
+
concreteType = goType.possibleTypes.find(
|
|
1446
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1447
|
+
(t) => t.discriminatorValue?.literal === exampleType.type.discriminatorValue || t.discriminatorValue?.literal.value === exampleType.type.discriminatorValue);
|
|
1409
1448
|
if (concreteType === undefined) {
|
|
1410
1449
|
// can't find the sub type of a discriminated type, fallback to the base type
|
|
1411
1450
|
concreteType = goType.rootType;
|
|
@@ -1419,7 +1458,7 @@ export class ClientAdapter {
|
|
|
1419
1458
|
}
|
|
1420
1459
|
const ret = new go.StructExample(concreteType);
|
|
1421
1460
|
for (const [k, v] of Object.entries(exampleType.value)) {
|
|
1422
|
-
const field = concreteType.fields.find(f => f.serializedName === k);
|
|
1461
|
+
const field = concreteType.fields.find((f) => f.serializedName === k);
|
|
1423
1462
|
if (!field) {
|
|
1424
1463
|
throw new AdapterError('InternalError', `field with serializedName '${k}' not found in model '${concreteType.name}'.`);
|
|
1425
1464
|
}
|
|
@@ -1428,7 +1467,7 @@ export class ClientAdapter {
|
|
|
1428
1467
|
if (exampleType.additionalPropertiesValue) {
|
|
1429
1468
|
ret.additionalProperties = {};
|
|
1430
1469
|
for (const [k, v] of Object.entries(exampleType.additionalPropertiesValue)) {
|
|
1431
|
-
const filed = concreteType.fields.find(f => f.annotations.isAdditionalProperties);
|
|
1470
|
+
const filed = concreteType.fields.find((f) => f.annotations.isAdditionalProperties);
|
|
1432
1471
|
if (!filed) {
|
|
1433
1472
|
throw new AdapterError('InternalError', `additional properties field not found in model '${concreteType.name}'.`);
|
|
1434
1473
|
}
|
|
@@ -1466,5 +1505,4 @@ function hasDecorator(name, decorators) {
|
|
|
1466
1505
|
function isHttpStatusCodeRange(statusCode) {
|
|
1467
1506
|
return statusCode.start !== undefined;
|
|
1468
1507
|
}
|
|
1469
|
-
;
|
|
1470
1508
|
//# sourceMappingURL=clients.js.map
|