@azure-tools/typespec-go 0.10.1 → 0.10.3
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.js +5 -9
- 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 +15 -7
- 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 +20 -11
- 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 +71 -54
- package/dist/typespec-go/src/tcgcadapter/clients.js.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/types.d.ts +1 -0
- package/dist/typespec-go/src/tcgcadapter/types.d.ts.map +1 -1
- package/dist/typespec-go/src/tcgcadapter/types.js +14 -13
- 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,iGAAiG;SAC/G;QACD,iBAAiB,EAAE;YAC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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,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,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C,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,EAAuB,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D;;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;IAoK5B,OAAO,CAAC,0BAA0B;IAiBlC,OAAO,CAAC,qBAAqB;IA8K7B;;;;;;;;;;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,7 +5,7 @@
|
|
|
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
10
|
import { isTypePassedByValue } from './types.js';
|
|
11
11
|
/**
|
|
@@ -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
|
}
|
|
@@ -885,7 +889,14 @@ export class ClientAdapter {
|
|
|
885
889
|
// TODO: currently we don't have Azure service using cookie parameter. need to add support if needed in the future.
|
|
886
890
|
throw new AdapterError('UnsupportedTsp', 'unsupported parameter type cookie', opParam.__raw?.node);
|
|
887
891
|
case 'header':
|
|
888
|
-
if (opParam.
|
|
892
|
+
if (opParam.serializedName === 'x-ms-meta') {
|
|
893
|
+
const type = this.ta.getWireType(methodParam.type, true, false);
|
|
894
|
+
if (type.kind !== 'map') {
|
|
895
|
+
throw new AdapterError('InternalError', `unexpected kind ${type.kind} for HeaderMapParameter ${methodParam.name}`, opParam.__raw?.node);
|
|
896
|
+
}
|
|
897
|
+
adaptedParam = new go.HeaderMapParameter(paramName, `${opParam.serializedName}-`, type, paramStyle, byVal, location);
|
|
898
|
+
}
|
|
899
|
+
else if (opParam.collectionFormat) {
|
|
889
900
|
if (opParam.collectionFormat === 'multi' || opParam.collectionFormat === 'form') {
|
|
890
901
|
throw new AdapterError('InternalError', `unexpected collection format ${opParam.collectionFormat} for HeaderCollectionParameter`, opParam.__raw?.node);
|
|
891
902
|
}
|
|
@@ -910,7 +921,7 @@ export class ClientAdapter {
|
|
|
910
921
|
throw new AdapterError('InternalError', `unexpected kind ${type.kind} for QueryCollectionParameter ${methodParam.name}`, opParam.__raw?.node);
|
|
911
922
|
}
|
|
912
923
|
// TODO: unencoded query param
|
|
913
|
-
adaptedParam = new go.QueryCollectionParameter(paramName, opParam.serializedName, true, type, opParam.collectionFormat === 'simple' ? 'csv' :
|
|
924
|
+
adaptedParam = new go.QueryCollectionParameter(paramName, opParam.serializedName, true, type, opParam.collectionFormat === 'simple' ? 'csv' : opParam.collectionFormat === 'form' ? 'multi' : opParam.collectionFormat, paramStyle, byVal, location);
|
|
914
925
|
}
|
|
915
926
|
else {
|
|
916
927
|
// TODO: unencoded query param
|
|
@@ -954,21 +965,28 @@ export class ClientAdapter {
|
|
|
954
965
|
this.ta.getPkg().responseEnvelopes.push(respEnv);
|
|
955
966
|
// add any headers
|
|
956
967
|
const addedHeaders = new Set();
|
|
957
|
-
|
|
958
|
-
for (const
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
968
|
+
if (!go.isLROMethod(method)) {
|
|
969
|
+
for (const httpResp of sdkMethod.operation.responses) {
|
|
970
|
+
for (const httpHeader of httpResp.headers) {
|
|
971
|
+
if (addedHeaders.has(httpHeader.serializedName)) {
|
|
972
|
+
continue;
|
|
973
|
+
}
|
|
974
|
+
let headerResp;
|
|
975
|
+
if (httpHeader.serializedName === 'x-ms-meta' || httpHeader.serializedName === 'x-ms-or') {
|
|
976
|
+
const type = this.ta.getWireType(httpHeader.type, true, false);
|
|
977
|
+
if (type.kind !== 'map') {
|
|
978
|
+
throw new AdapterError('InternalError', `unexpected kind ${type.kind} for HeaderMapResponse ${httpHeader.name}`);
|
|
979
|
+
}
|
|
980
|
+
headerResp = new go.HeaderMapResponse(ensureNameCase(httpHeader.name), type, `${httpHeader.serializedName}-`);
|
|
981
|
+
}
|
|
982
|
+
else {
|
|
983
|
+
headerResp = new go.HeaderScalarResponse(ensureNameCase(httpHeader.name), this.adaptHeaderScalarType(httpHeader.type, false), httpHeader.serializedName, isTypePassedByValue(httpHeader.type));
|
|
984
|
+
}
|
|
985
|
+
headerResp.docs.summary = httpHeader.summary;
|
|
986
|
+
headerResp.docs.description = httpHeader.doc;
|
|
987
|
+
respEnv.headers.push(headerResp);
|
|
988
|
+
addedHeaders.add(httpHeader.serializedName);
|
|
965
989
|
}
|
|
966
|
-
// TODO: x-ms-header-collection-prefix
|
|
967
|
-
const headerResp = new go.HeaderScalarResponse(ensureNameCase(httpHeader.name), this.adaptHeaderScalarType(httpHeader.type, false), httpHeader.serializedName, isTypePassedByValue(httpHeader.type));
|
|
968
|
-
headerResp.docs.summary = httpHeader.summary;
|
|
969
|
-
headerResp.docs.description = httpHeader.doc;
|
|
970
|
-
respEnv.headers.push(headerResp);
|
|
971
|
-
addedHeaders.add(httpHeader.serializedName);
|
|
972
990
|
}
|
|
973
991
|
}
|
|
974
992
|
let sdkResponseType = sdkMethod.response.type;
|
|
@@ -989,9 +1007,7 @@ export class ClientAdapter {
|
|
|
989
1007
|
// however, we want the synthesized paged response envelope as that's what Go returns.
|
|
990
1008
|
if (sdkMethod.kind === 'lropaging' || sdkMethod.kind === 'paging') {
|
|
991
1009
|
// grab the paged response envelope type from the operation responses
|
|
992
|
-
sdkResponseType = sdkMethod.kind === 'lropaging'
|
|
993
|
-
? sdkMethod.lroMetadata.finalResponse?.result
|
|
994
|
-
: sdkMethod.operation.responses[0].type;
|
|
1010
|
+
sdkResponseType = sdkMethod.kind === 'lropaging' ? sdkMethod.lroMetadata.finalResponse?.result : sdkMethod.operation.responses[0].type;
|
|
995
1011
|
if (!sdkResponseType) {
|
|
996
1012
|
throw new AdapterError('InternalError', `paged method ${method.name} has no synthesized response type`, sdkMethod.__raw?.node);
|
|
997
1013
|
}
|
|
@@ -1050,7 +1066,7 @@ export class ClientAdapter {
|
|
|
1050
1066
|
// For polymorphic models, check if we can find a concrete type that matches the discriminator value
|
|
1051
1067
|
// If no concrete type is found, create a PolymorphicResult that uses the interface type
|
|
1052
1068
|
// else use the concrete type as the result type
|
|
1053
|
-
const concreteType = modelType.interface.possibleTypes.find(t => t.discriminatorValue?.literal === modelType.discriminatorValue?.literal);
|
|
1069
|
+
const concreteType = modelType.interface.possibleTypes.find((t) => t.discriminatorValue?.literal === modelType.discriminatorValue?.literal);
|
|
1054
1070
|
if (concreteType === undefined) {
|
|
1055
1071
|
respEnv.result = new go.PolymorphicResult(modelType.interface);
|
|
1056
1072
|
}
|
|
@@ -1180,12 +1196,17 @@ export class ClientAdapter {
|
|
|
1180
1196
|
return structType;
|
|
1181
1197
|
}
|
|
1182
1198
|
adaptHeaderScalarType(sdkType, forParam) {
|
|
1199
|
+
// It would be ideal to force the ETag type for the known ETag headers per the RFC.
|
|
1200
|
+
// However, doing so introduces too many breaking changes (if-match and if-none-match).
|
|
1201
|
+
// TODO: If we decide to force ETag types by header name in the future,
|
|
1202
|
+
// update adaptHeaderScalarType to receive the header name and dispatch
|
|
1203
|
+
// to this.ta.getETagType() for ETag-related headers.
|
|
1183
1204
|
// for header params, we never pass the element type by pointer
|
|
1184
1205
|
const type = this.ta.getWireType(sdkType, forParam, false);
|
|
1185
1206
|
if (go.isHeaderScalarType(type)) {
|
|
1186
1207
|
return type;
|
|
1187
1208
|
}
|
|
1188
|
-
throw new AdapterError('InternalError', `unexpected header scalar parameter type ${
|
|
1209
|
+
throw new AdapterError('InternalError', `unexpected header scalar parameter type ${type.kind}`, sdkType.__raw?.node);
|
|
1189
1210
|
}
|
|
1190
1211
|
adaptPathScalarParameterType(sdkType) {
|
|
1191
1212
|
const type = this.ta.getWireType(sdkType, false, false);
|
|
@@ -1270,6 +1291,10 @@ export class ClientAdapter {
|
|
|
1270
1291
|
}
|
|
1271
1292
|
}
|
|
1272
1293
|
else {
|
|
1294
|
+
// skip literal parameters as they're set internally when composing the request
|
|
1295
|
+
if (go.isLiteralParameter(goParams[0].style)) {
|
|
1296
|
+
continue;
|
|
1297
|
+
}
|
|
1273
1298
|
const paramExample = new go.ParameterExample(goParams[0], this.adaptExampleType(param.value, goParams[0]?.type));
|
|
1274
1299
|
if (goParams[0]?.group) {
|
|
1275
1300
|
goExample.optionalParamsGroup.push(paramExample);
|
|
@@ -1280,19 +1305,20 @@ export class ClientAdapter {
|
|
|
1280
1305
|
}
|
|
1281
1306
|
}
|
|
1282
1307
|
// only handle 200 response
|
|
1283
|
-
const response = example.responses.find((v) => {
|
|
1308
|
+
const response = example.responses.find((v) => {
|
|
1309
|
+
return v.statusCode === 200;
|
|
1310
|
+
});
|
|
1284
1311
|
if (response) {
|
|
1285
1312
|
goExample.responseEnvelope = new go.ResponseEnvelopeExample(method.returns);
|
|
1286
|
-
for
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1313
|
+
// skip adding headers for LROs as they aren't useful on the response envelope
|
|
1314
|
+
if (!go.isLROMethod(method)) {
|
|
1315
|
+
for (const header of response.headers) {
|
|
1316
|
+
const goHeader = method.returns.headers.find((h) => h.headerName === header.header.serializedName);
|
|
1317
|
+
if (!goHeader) {
|
|
1318
|
+
throw new AdapterError('InternalError', `can not find go header for example header ${header.header.serializedName}`);
|
|
1319
|
+
}
|
|
1320
|
+
goExample.responseEnvelope.headers.push(new go.ResponseHeaderExample(goHeader, this.adaptExampleType(header.value, goHeader.type)));
|
|
1294
1321
|
}
|
|
1295
|
-
goExample.responseEnvelope.headers.push(new go.ResponseHeaderExample(goHeader, this.adaptExampleType(header.value, goHeader.type)));
|
|
1296
1322
|
}
|
|
1297
1323
|
// there are some problems with LROs at present which can cause the result
|
|
1298
1324
|
// to be undefined even though the operation returns a response.
|
|
@@ -1391,8 +1417,9 @@ export class ClientAdapter {
|
|
|
1391
1417
|
if (goType.kind === 'interface' || goType.kind === 'model' || goType.kind === 'polymorphicModel') {
|
|
1392
1418
|
let concreteType;
|
|
1393
1419
|
if (goType.kind === 'interface') {
|
|
1394
|
-
|
|
1395
|
-
|
|
1420
|
+
concreteType = goType.possibleTypes.find(
|
|
1421
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
1422
|
+
(t) => t.discriminatorValue?.literal === exampleType.type.discriminatorValue || t.discriminatorValue?.literal.value === exampleType.type.discriminatorValue);
|
|
1396
1423
|
if (concreteType === undefined) {
|
|
1397
1424
|
// can't find the sub type of a discriminated type, fallback to the base type
|
|
1398
1425
|
concreteType = goType.rootType;
|
|
@@ -1406,7 +1433,7 @@ export class ClientAdapter {
|
|
|
1406
1433
|
}
|
|
1407
1434
|
const ret = new go.StructExample(concreteType);
|
|
1408
1435
|
for (const [k, v] of Object.entries(exampleType.value)) {
|
|
1409
|
-
const field = concreteType.fields.find(f => f.serializedName === k);
|
|
1436
|
+
const field = concreteType.fields.find((f) => f.serializedName === k);
|
|
1410
1437
|
if (!field) {
|
|
1411
1438
|
throw new AdapterError('InternalError', `field with serializedName '${k}' not found in model '${concreteType.name}'.`);
|
|
1412
1439
|
}
|
|
@@ -1415,7 +1442,7 @@ export class ClientAdapter {
|
|
|
1415
1442
|
if (exampleType.additionalPropertiesValue) {
|
|
1416
1443
|
ret.additionalProperties = {};
|
|
1417
1444
|
for (const [k, v] of Object.entries(exampleType.additionalPropertiesValue)) {
|
|
1418
|
-
const filed = concreteType.fields.find(f => f.annotations.isAdditionalProperties);
|
|
1445
|
+
const filed = concreteType.fields.find((f) => f.annotations.isAdditionalProperties);
|
|
1419
1446
|
if (!filed) {
|
|
1420
1447
|
throw new AdapterError('InternalError', `additional properties field not found in model '${concreteType.name}'.`);
|
|
1421
1448
|
}
|
|
@@ -1453,14 +1480,4 @@ function hasDecorator(name, decorators) {
|
|
|
1453
1480
|
function isHttpStatusCodeRange(statusCode) {
|
|
1454
1481
|
return statusCode.start !== undefined;
|
|
1455
1482
|
}
|
|
1456
|
-
;
|
|
1457
|
-
/**
|
|
1458
|
-
* checks if the specified header is an LRO polling header.
|
|
1459
|
-
* LRO polling headers are not useful on the response envelope and should be filtered out.
|
|
1460
|
-
* @param headerName - the serialized name of the header to check
|
|
1461
|
-
* @returns true if the header is an LRO polling header, false otherwise
|
|
1462
|
-
*/
|
|
1463
|
-
function isLROPollingHeader(headerName) {
|
|
1464
|
-
return /Azure-AsyncOperation|Location|Operation-Location|Retry-After/i.test(headerName);
|
|
1465
|
-
}
|
|
1466
1483
|
//# sourceMappingURL=clients.js.map
|