@azure-tools/typespec-ts 0.54.0-alpha.20260601.2 → 0.54.0-dev.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/CHANGELOG.md +0 -11
- package/README.md +0 -4
- package/dist/src/contextManager.js +3 -3
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/hooks/binder.js +19 -20
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.js +1 -2
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
- package/dist/src/framework/load-static-helpers.js +7 -8
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/framework/reference.js +1 -1
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +34 -45
- package/dist/src/index.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +14 -15
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +4 -3
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.js +1 -2
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildModularOptions.js +4 -5
- package/dist/src/modular/buildModularOptions.js.map +1 -1
- package/dist/src/modular/buildOperations.js +1 -2
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +1 -2
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.js +1 -2
- package/dist/src/modular/buildRestorePoller.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +9 -14
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.js +1 -2
- package/dist/src/modular/buildSubpathIndex.js.map +1 -1
- package/dist/src/modular/emitLoggerFile.js +2 -2
- package/dist/src/modular/emitLoggerFile.js.map +1 -1
- package/dist/src/modular/emitModels.js +32 -46
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/emitModelsOptions.js +1 -1
- package/dist/src/modular/emitModelsOptions.js.map +1 -1
- package/dist/src/modular/emitSamples.js +34 -30
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/modular/emitTests.js +4 -6
- package/dist/src/modular/emitTests.js.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +42 -42
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +20 -25
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js +39 -32
- package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +3 -5
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +75 -99
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +3 -5
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js +11 -14
- package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +17 -20
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js +31 -40
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.d.ts.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.js +24 -25
- package/dist/src/modular/serialization/serializeUtils.js.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.js +1 -2
- package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.js +5 -6
- package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.js +2 -3
- package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js +2 -4
- package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
- package/dist/src/rlc-common/buildClient.js +26 -30
- package/dist/src/rlc-common/buildClient.js.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.js +6 -5
- package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.js +2 -3
- package/dist/src/rlc-common/buildIndexFile.js.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js +12 -10
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -1
- package/dist/src/rlc-common/buildLogger.js +1 -2
- package/dist/src/rlc-common/buildLogger.js.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.js +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.js +38 -60
- package/dist/src/rlc-common/buildObjectTypes.js.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.js +12 -15
- package/dist/src/rlc-common/buildParameterTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.js +7 -8
- package/dist/src/rlc-common/buildPollingHelper.js.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.js +4 -5
- package/dist/src/rlc-common/buildResponseTypes.js.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.js +5 -6
- package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.js +9 -12
- package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.js +2 -4
- package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.js +9 -10
- package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.js +10 -21
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/packageUtil.js +3 -6
- package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.js +2 -6
- package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.js +4 -8
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +4 -7
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +2 -3
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +1 -2
- package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +3 -4
- package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.js +19 -23
- package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.js +25 -25
- package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.js +1 -2
- package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +3 -4
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTestConfig.js +3 -4
- package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.js +6 -8
- package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.js +2 -3
- package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.js +2 -3
- package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +2 -3
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +2 -2
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/utils.js +1 -2
- package/dist/src/rlc-common/metadata/utils.js.map +1 -1
- package/dist/src/rlc-common/test/buildRecordedClient.js +2 -3
- package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.js +2 -3
- package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.js +4 -5
- package/dist/src/rlc-common/test/buildSnippets.js.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.js +23 -23
- package/dist/src/rlc-common/transformSampleGroups.js.map +1 -1
- package/dist/src/transform/transform.js +20 -18
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +7 -7
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +2 -3
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.js +15 -22
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.js +9 -12
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.js +10 -14
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.js +17 -22
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +23 -22
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.js +6 -11
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/credentialUtils.js +1 -2
- package/dist/src/utils/credentialUtils.js.map +1 -1
- package/dist/src/utils/crossLanguageDef.js +6 -6
- package/dist/src/utils/crossLanguageDef.js.map +1 -1
- package/dist/src/utils/emitUtil.js +1 -1
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/fileSystemUtils.d.ts +2 -0
- package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
- package/dist/src/utils/fileSystemUtils.js +24 -5
- package/dist/src/utils/fileSystemUtils.js.map +1 -1
- package/dist/src/utils/importHelper.js +1 -2
- package/dist/src/utils/importHelper.js.map +1 -1
- package/dist/src/utils/modelUtils.js +78 -104
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/namespaceUtils.js +4 -5
- package/dist/src/utils/namespaceUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.js +38 -46
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/parameterUtils.js +7 -11
- package/dist/src/utils/parameterUtils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +38 -41
- package/src/index.ts +11 -10
- package/src/modular/buildRootIndex.ts +0 -1
- package/src/modular/emitSamples.ts +1 -3
- package/src/modular/helpers/exampleValueHelpers.ts +2 -6
- package/src/modular/serialization/serializeUtils.ts +0 -1
- package/src/rlc-common/buildClientDefinitions.ts +1 -0
- package/src/utils/fileSystemUtils.ts +29 -5
- package/static/static-helpers/pollingHelpers.ts +3 -3
- package/static/static-helpers/serialization/get-binary-response-browser.mts +3 -1
- package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +1 -3
- package/static/static-helpers/serialization/xml-helpers.ts +1 -1
- package/static/static-helpers/simplePollerHelpers.ts +1 -1
|
@@ -63,9 +63,8 @@ export function enrichBinaryTypeInBody(schema) {
|
|
|
63
63
|
return schema;
|
|
64
64
|
}
|
|
65
65
|
export function getSchemaForType(dpgContext, typeInput, options) {
|
|
66
|
-
var _a, _b, _c, _d;
|
|
67
66
|
const program = dpgContext.program;
|
|
68
|
-
const { usage } = options
|
|
67
|
+
const { usage } = options ?? {};
|
|
69
68
|
const type = getEffectiveModelFromType(dpgContext, typeInput);
|
|
70
69
|
const builtinType = getSchemaForLiteral(type);
|
|
71
70
|
if (builtinType !== undefined) {
|
|
@@ -109,7 +108,7 @@ export function getSchemaForType(dpgContext, typeInput, options) {
|
|
|
109
108
|
}
|
|
110
109
|
const schema = getSchemaForModel(dpgContext, type, options);
|
|
111
110
|
if (isAnonymousObjectSchema(schema)) {
|
|
112
|
-
if (Object.keys(
|
|
111
|
+
if (Object.keys(schema.properties ?? {}).length === 0) {
|
|
113
112
|
// Handle empty anonymous model as Record
|
|
114
113
|
schema.typeName =
|
|
115
114
|
schema.type === "object" ? "Record<string, unknown>" : "unknown";
|
|
@@ -128,8 +127,8 @@ export function getSchemaForType(dpgContext, typeInput, options) {
|
|
|
128
127
|
}
|
|
129
128
|
schema.typeName = getModelInlineSigniture(schema, {
|
|
130
129
|
usage: [SchemaContext.Input],
|
|
131
|
-
multipart:
|
|
132
|
-
isMediaTypeMultipartFormData(
|
|
130
|
+
multipart: options?.isRequestBody &&
|
|
131
|
+
isMediaTypeMultipartFormData(options?.mediaTypes ?? [])
|
|
133
132
|
});
|
|
134
133
|
schema.type = "object";
|
|
135
134
|
}
|
|
@@ -179,7 +178,7 @@ export function getSchemaForType(dpgContext, typeInput, options) {
|
|
|
179
178
|
code: "invalid-schema",
|
|
180
179
|
format: {
|
|
181
180
|
type: type.kind,
|
|
182
|
-
property:
|
|
181
|
+
property: options?.relevantProperty?.name ?? ""
|
|
183
182
|
},
|
|
184
183
|
target: type
|
|
185
184
|
});
|
|
@@ -199,12 +198,11 @@ export function getEffectiveModelFromType(context, type) {
|
|
|
199
198
|
return type;
|
|
200
199
|
}
|
|
201
200
|
export function includeDerivedModel(model, needRef = false) {
|
|
202
|
-
var _a;
|
|
203
201
|
return (!needRef &&
|
|
204
202
|
!isTemplateDeclaration(model) &&
|
|
205
203
|
(!model.templateMapper ||
|
|
206
204
|
!model.templateMapper.args ||
|
|
207
|
-
|
|
205
|
+
model.templateMapper.args?.length === 0 ||
|
|
208
206
|
model.derivedModels.length > 0));
|
|
209
207
|
}
|
|
210
208
|
function applyEncoding(dpgContext, typespecType, target = {}) {
|
|
@@ -222,21 +220,20 @@ function applyEncoding(dpgContext, typespecType, target = {}) {
|
|
|
222
220
|
return target;
|
|
223
221
|
}
|
|
224
222
|
function mergeFormatAndEncoding(format, encoding, encodeAsFormat) {
|
|
225
|
-
var _a, _b;
|
|
226
223
|
switch (format) {
|
|
227
224
|
case undefined:
|
|
228
|
-
return
|
|
225
|
+
return encodeAsFormat ?? encoding ?? format;
|
|
229
226
|
case "date-time":
|
|
230
227
|
return encoding;
|
|
231
228
|
case "duration":
|
|
232
229
|
default:
|
|
233
|
-
return
|
|
230
|
+
return encodeAsFormat ?? encoding ?? format;
|
|
234
231
|
}
|
|
235
232
|
}
|
|
236
233
|
function getSchemaForScalar(dpgContext, scalar, options) {
|
|
237
234
|
let result = {};
|
|
238
235
|
const isStd = dpgContext.program.checker.isStdType(scalar);
|
|
239
|
-
const { relevantProperty, isRequestBody, isParentRequestBody, mediaTypes: contentTypes } = options
|
|
236
|
+
const { relevantProperty, isRequestBody, isParentRequestBody, mediaTypes: contentTypes } = options ?? {};
|
|
240
237
|
if (isStd) {
|
|
241
238
|
result = getSchemaForStdScalar(dpgContext.program, scalar, {
|
|
242
239
|
relevantProperty
|
|
@@ -281,17 +278,16 @@ function getSchemaForScalar(dpgContext, scalar, options) {
|
|
|
281
278
|
}
|
|
282
279
|
}
|
|
283
280
|
function getSchemaForUnion(dpgContext, union, options) {
|
|
284
|
-
var _a, _b;
|
|
285
281
|
const [asEnum, _] = getUnionAsEnum(union);
|
|
286
282
|
const variants = Array.from(union.variants.values());
|
|
287
283
|
const values = [];
|
|
288
284
|
let namedUnionMember = false;
|
|
289
|
-
if (!(
|
|
290
|
-
if (
|
|
285
|
+
if (!(options?.needRef && union.name && !asEnum)) {
|
|
286
|
+
if (asEnum?.open && asEnum.members.size > 0) {
|
|
291
287
|
for (const [_, member] of asEnum.members.entries()) {
|
|
292
288
|
const memberType = getSchemaForType(dpgContext, member.type, {
|
|
293
289
|
...options,
|
|
294
|
-
needRef:
|
|
290
|
+
needRef: options?.needRef ?? false
|
|
295
291
|
});
|
|
296
292
|
values.push(memberType);
|
|
297
293
|
if (memberType.name) {
|
|
@@ -316,15 +312,15 @@ function getSchemaForUnion(dpgContext, union, options) {
|
|
|
316
312
|
const schema = {};
|
|
317
313
|
if (values.length > 0) {
|
|
318
314
|
schema.enum = values;
|
|
319
|
-
const unionAlias =
|
|
315
|
+
const unionAlias = asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
320
316
|
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
321
317
|
: values
|
|
322
|
-
.map((item) =>
|
|
318
|
+
.map((item) => `${getTypeName(item, [SchemaContext.Input]) ?? item}`)
|
|
323
319
|
.join(" | ");
|
|
324
|
-
const outputUnionAlias =
|
|
320
|
+
const outputUnionAlias = asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
325
321
|
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
326
322
|
: values
|
|
327
|
-
.map((item) =>
|
|
323
|
+
.map((item) => `${getTypeName(item, [SchemaContext.Output]) ?? item}`)
|
|
328
324
|
.join(" | ");
|
|
329
325
|
schema.alias = unionAlias;
|
|
330
326
|
schema.outputAlias = outputUnionAlias;
|
|
@@ -347,7 +343,7 @@ function getSchemaForUnion(dpgContext, union, options) {
|
|
|
347
343
|
}
|
|
348
344
|
else {
|
|
349
345
|
schema.type = "union";
|
|
350
|
-
schema.typeName =
|
|
346
|
+
schema.typeName = union.name ?? schema.alias;
|
|
351
347
|
schema.outputTypeName = union.name
|
|
352
348
|
? union.name + "Output"
|
|
353
349
|
: schema.outputAlias;
|
|
@@ -385,7 +381,6 @@ function isOasString(type) {
|
|
|
385
381
|
return false;
|
|
386
382
|
}
|
|
387
383
|
function isStringLiteral(type) {
|
|
388
|
-
var _a;
|
|
389
384
|
if (type.kind === "Union") {
|
|
390
385
|
// A union where all variants are an OasString
|
|
391
386
|
for (const variant of type.variants) {
|
|
@@ -397,12 +392,11 @@ function isStringLiteral(type) {
|
|
|
397
392
|
}
|
|
398
393
|
return (type.kind === "String" ||
|
|
399
394
|
(type.kind === "EnumMember" &&
|
|
400
|
-
typeof (
|
|
395
|
+
typeof (type.value ?? type.name) === "string") ||
|
|
401
396
|
(type.kind === "UnionVariant" && type.type.kind === "String"));
|
|
402
397
|
}
|
|
403
398
|
// Return any string literal values for type
|
|
404
399
|
function getStringValues(type) {
|
|
405
|
-
var _a;
|
|
406
400
|
switch (type.kind) {
|
|
407
401
|
case "String":
|
|
408
402
|
return [type.value];
|
|
@@ -411,7 +405,7 @@ function getStringValues(type) {
|
|
|
411
405
|
.flatMap((x) => getStringValues(x.type))
|
|
412
406
|
.filter((x) => x !== undefined);
|
|
413
407
|
case "EnumMember":
|
|
414
|
-
return typeof type.value !== "number" ? [
|
|
408
|
+
return typeof type.value !== "number" ? [type.value ?? type.name] : [];
|
|
415
409
|
case "UnionVariant":
|
|
416
410
|
return getStringValues(type.type);
|
|
417
411
|
default:
|
|
@@ -419,7 +413,6 @@ function getStringValues(type) {
|
|
|
419
413
|
}
|
|
420
414
|
}
|
|
421
415
|
function validateDiscriminator(program, discriminator, derivedModels) {
|
|
422
|
-
var _a;
|
|
423
416
|
const { propertyName } = discriminator;
|
|
424
417
|
const retVals = derivedModels.map((t) => {
|
|
425
418
|
const prop = getProperty(t, propertyName);
|
|
@@ -456,7 +449,7 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
456
449
|
const discriminatorValues = new Map();
|
|
457
450
|
for (const t of derivedModels) {
|
|
458
451
|
// Get the discriminator property directly in the child model
|
|
459
|
-
const prop =
|
|
452
|
+
const prop = t.properties?.get(propertyName);
|
|
460
453
|
// Issue warning diagnostic if discriminator property missing or is not a string literal
|
|
461
454
|
if (!prop || !isStringLiteral(prop.type)) {
|
|
462
455
|
reportDiagnostic(program, {
|
|
@@ -490,19 +483,18 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
490
483
|
return retVals.every((v) => v);
|
|
491
484
|
}
|
|
492
485
|
function getSchemaForModel(dpgContext, model, options) {
|
|
493
|
-
|
|
494
|
-
const { usage, needRef, isRequestBody, mediaTypes: contentTypes } = options !== null && options !== void 0 ? options : {};
|
|
486
|
+
const { usage, needRef, isRequestBody, mediaTypes: contentTypes } = options ?? {};
|
|
495
487
|
if (isArrayModelType(model)) {
|
|
496
488
|
return getSchemaForArrayModel(dpgContext, model, options);
|
|
497
489
|
}
|
|
498
490
|
const program = dpgContext.program;
|
|
499
|
-
const isMultipartBody = isMediaTypeMultipartFormData(contentTypes
|
|
491
|
+
const isMultipartBody = isMediaTypeMultipartFormData(contentTypes ?? []);
|
|
500
492
|
const isCoreModel = isAzureCoreErrorType(program, model);
|
|
501
493
|
const modelSchema = {
|
|
502
494
|
name: getModelName(dpgContext, model),
|
|
503
495
|
type: "object",
|
|
504
496
|
isMultipartBody,
|
|
505
|
-
description:
|
|
497
|
+
description: getDoc(program, model) ?? "",
|
|
506
498
|
fromCore: isCoreModel
|
|
507
499
|
};
|
|
508
500
|
// normalized the output name
|
|
@@ -533,7 +525,7 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
533
525
|
needRef: true
|
|
534
526
|
});
|
|
535
527
|
for (const [name, prop] of child.properties) {
|
|
536
|
-
if (name ===
|
|
528
|
+
if (name === discriminator?.propertyName) {
|
|
537
529
|
const propSchema = getSchemaForType(dpgContext, prop.type, {
|
|
538
530
|
usage,
|
|
539
531
|
needRef: !isAnonymousModelType(prop.type),
|
|
@@ -543,13 +535,13 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
543
535
|
break;
|
|
544
536
|
}
|
|
545
537
|
}
|
|
546
|
-
|
|
547
|
-
|
|
538
|
+
modelSchema.children?.all?.push(childSchema);
|
|
539
|
+
modelSchema.children?.immediate?.push(childSchema);
|
|
548
540
|
}
|
|
549
541
|
// Enable option `isPolyParent` and discriminator only when it has valid children
|
|
550
542
|
if (discriminator &&
|
|
551
|
-
|
|
552
|
-
|
|
543
|
+
modelSchema?.children?.all?.length &&
|
|
544
|
+
modelSchema?.children?.all?.length > 0) {
|
|
553
545
|
if (!validateDiscriminator(program, discriminator, derivedModels)) {
|
|
554
546
|
// appropriate diagnostic is generated in the validate function
|
|
555
547
|
return {};
|
|
@@ -575,7 +567,7 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
575
567
|
}
|
|
576
568
|
for (const [propName, prop] of model.properties) {
|
|
577
569
|
const restApiName = getWireName(dpgContext, prop);
|
|
578
|
-
const name = `"${restApiName
|
|
570
|
+
const name = `"${restApiName ?? propName}"`;
|
|
579
571
|
if (!isSchemaProperty(program, prop)) {
|
|
580
572
|
continue;
|
|
581
573
|
}
|
|
@@ -606,7 +598,7 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
606
598
|
modelSchema.discriminator = {
|
|
607
599
|
...modelSchema.discriminator,
|
|
608
600
|
...{
|
|
609
|
-
type:
|
|
601
|
+
type: propSchema.typeName ?? propSchema.type,
|
|
610
602
|
typeName: propSchema.typeName,
|
|
611
603
|
outputTypeName: propSchema.outputTypeName
|
|
612
604
|
}
|
|
@@ -648,11 +640,11 @@ function getSchemaForModel(dpgContext, model, options) {
|
|
|
648
640
|
immediate: []
|
|
649
641
|
};
|
|
650
642
|
}
|
|
651
|
-
|
|
643
|
+
modelSchema.parents.all?.push(getSchemaForType(dpgContext, model.baseModel, {
|
|
652
644
|
usage,
|
|
653
645
|
needRef: true
|
|
654
646
|
}));
|
|
655
|
-
|
|
647
|
+
modelSchema.parents.immediate?.push(getSchemaForType(dpgContext, model.baseModel, {
|
|
656
648
|
usage,
|
|
657
649
|
needRef: true
|
|
658
650
|
}));
|
|
@@ -692,7 +684,6 @@ function getSdkVisibility(program, type) {
|
|
|
692
684
|
* Return the model name for a given model
|
|
693
685
|
*/
|
|
694
686
|
function getModelName(dpgContext, model) {
|
|
695
|
-
var _a, _b;
|
|
696
687
|
const { program } = dpgContext;
|
|
697
688
|
// 1. check if this is an anonymous model
|
|
698
689
|
if (model.name === "") {
|
|
@@ -710,22 +701,21 @@ function getModelName(dpgContext, model) {
|
|
|
710
701
|
}
|
|
711
702
|
// 4. check if this is a model with template arguments
|
|
712
703
|
let name = model.name;
|
|
713
|
-
if (
|
|
704
|
+
if (model.templateMapper?.args) {
|
|
714
705
|
// const isPage = getPagedResult(program, model);
|
|
715
706
|
const templateTypeNames = model.templateMapper.args
|
|
716
707
|
.map((arg) => (arg.entityKind === "Indeterminate" ? arg.type : arg))
|
|
717
708
|
.map((arg) => {
|
|
718
|
-
var _a, _b;
|
|
719
709
|
switch (arg.kind) {
|
|
720
710
|
case "Model":
|
|
721
711
|
case "Enum":
|
|
722
712
|
case "Union":
|
|
723
713
|
case "Scalar":
|
|
724
|
-
return
|
|
714
|
+
return arg.name ?? "";
|
|
725
715
|
case "String":
|
|
726
716
|
case "Boolean":
|
|
727
717
|
case "Number":
|
|
728
|
-
return
|
|
718
|
+
return arg.value ?? "";
|
|
729
719
|
default:
|
|
730
720
|
return "";
|
|
731
721
|
}
|
|
@@ -746,7 +736,7 @@ function getModelName(dpgContext, model) {
|
|
|
746
736
|
fullNamespacePrefix = "";
|
|
747
737
|
}
|
|
748
738
|
// 5. check if this model should be namespaced
|
|
749
|
-
return
|
|
739
|
+
return dpgContext.rlcOptions?.enableModelNamespace
|
|
750
740
|
? `${fullNamespacePrefix}${name}`
|
|
751
741
|
: name;
|
|
752
742
|
}
|
|
@@ -776,7 +766,7 @@ function applyIntrinsicDecorators(program, type, target) {
|
|
|
776
766
|
const docStr = getDoc(program, type);
|
|
777
767
|
const isString = isStringType(program, getPropertyType(type));
|
|
778
768
|
const isNumeric = isNumericType(program, getPropertyType(type));
|
|
779
|
-
if (isString && !
|
|
769
|
+
if (isString && !target?.documentation && docStr) {
|
|
780
770
|
newTarget.description = docStr;
|
|
781
771
|
}
|
|
782
772
|
const summaryStr = getSummary(program, type);
|
|
@@ -814,8 +804,7 @@ function applyIntrinsicDecorators(program, type, target) {
|
|
|
814
804
|
return newTarget;
|
|
815
805
|
}
|
|
816
806
|
function getSchemaForEnumMember(program, e) {
|
|
817
|
-
|
|
818
|
-
const value = (_a = e.value) !== null && _a !== void 0 ? _a : e.name;
|
|
807
|
+
const value = e.value ?? e.name;
|
|
819
808
|
const type = enumMemberType(e) === "string" ? `"${value}"` : `${value}`;
|
|
820
809
|
return { type, description: getDoc(program, e), isConstant: true };
|
|
821
810
|
}
|
|
@@ -847,7 +836,7 @@ function getSchemaForEnum(dpgContext, e) {
|
|
|
847
836
|
if (values.length > 0) {
|
|
848
837
|
schema.enum = values;
|
|
849
838
|
const unionAlias = values
|
|
850
|
-
.map((item) =>
|
|
839
|
+
.map((item) => `${getTypeName(item, [SchemaContext.Input]) ?? item}`)
|
|
851
840
|
.join(" | ");
|
|
852
841
|
schema.alias = unionAlias;
|
|
853
842
|
schema.outputAlias = unionAlias;
|
|
@@ -865,10 +854,9 @@ function enumMemberType(member) {
|
|
|
865
854
|
* Map TypeSpec intrinsic models to open api definitions
|
|
866
855
|
*/
|
|
867
856
|
function getSchemaForArrayModel(dpgContext, type, options) {
|
|
868
|
-
var _a, _b, _c;
|
|
869
857
|
const { program } = dpgContext;
|
|
870
858
|
const { indexer } = type;
|
|
871
|
-
const { usage, isParentRequestBody, mediaTypes: contentTypes } = options
|
|
859
|
+
const { usage, isParentRequestBody, mediaTypes: contentTypes } = options ?? {};
|
|
872
860
|
let schema = {};
|
|
873
861
|
if (!indexer) {
|
|
874
862
|
return schema;
|
|
@@ -890,7 +878,7 @@ function getSchemaForArrayModel(dpgContext, type, options) {
|
|
|
890
878
|
};
|
|
891
879
|
if (!program.checker.isStdType(indexer.value) &&
|
|
892
880
|
!isUnknownType(indexer.value) &&
|
|
893
|
-
|
|
881
|
+
indexer.value?.kind &&
|
|
894
882
|
schema.items.name &&
|
|
895
883
|
!schema.items.enum) {
|
|
896
884
|
schema.typeName = `Array<${schema.items.name}>`;
|
|
@@ -944,7 +932,7 @@ function getSchemaForArrayModel(dpgContext, type, options) {
|
|
|
944
932
|
}
|
|
945
933
|
}
|
|
946
934
|
}
|
|
947
|
-
else if (
|
|
935
|
+
else if (schema.items?.type?.includes("|")) {
|
|
948
936
|
schema.typeName = `(${schema.items.type})[]`;
|
|
949
937
|
}
|
|
950
938
|
else {
|
|
@@ -956,16 +944,15 @@ function getSchemaForArrayModel(dpgContext, type, options) {
|
|
|
956
944
|
}
|
|
957
945
|
}
|
|
958
946
|
function getSchemaForRecordModel(dpgContext, type, options) {
|
|
959
|
-
var _a, _b;
|
|
960
947
|
const { program } = dpgContext;
|
|
961
948
|
const { indexer } = type;
|
|
962
|
-
const { usage } = options
|
|
949
|
+
const { usage } = options ?? {};
|
|
963
950
|
let schema = {};
|
|
964
951
|
if (!indexer) {
|
|
965
952
|
return schema;
|
|
966
953
|
}
|
|
967
954
|
if (isRecordModelType(type)) {
|
|
968
|
-
const valueType = getSchemaForType(dpgContext, indexer
|
|
955
|
+
const valueType = getSchemaForType(dpgContext, indexer?.value, {
|
|
969
956
|
usage,
|
|
970
957
|
needRef: !isAnonymousModelType(indexer.value)
|
|
971
958
|
});
|
|
@@ -985,9 +972,9 @@ function getSchemaForRecordModel(dpgContext, type, options) {
|
|
|
985
972
|
}
|
|
986
973
|
}
|
|
987
974
|
else if (isUnknownType(indexer.value)) {
|
|
988
|
-
schema.typeName = `Record<string, ${
|
|
975
|
+
schema.typeName = `Record<string, ${valueType.typeName ?? valueType.type}>`;
|
|
989
976
|
if (usage && usage.includes(SchemaContext.Output)) {
|
|
990
|
-
schema.outputTypeName = `Record<string, ${
|
|
977
|
+
schema.outputTypeName = `Record<string, ${valueType.outputTypeName ?? valueType.type}>`;
|
|
991
978
|
}
|
|
992
979
|
}
|
|
993
980
|
else {
|
|
@@ -1014,8 +1001,7 @@ export function isArrayType(schema) {
|
|
|
1014
1001
|
return schema.type === "array";
|
|
1015
1002
|
}
|
|
1016
1003
|
function getSchemaForStdScalar(program, type, options) {
|
|
1017
|
-
|
|
1018
|
-
const { relevantProperty } = options !== null && options !== void 0 ? options : {};
|
|
1004
|
+
const { relevantProperty } = options ?? {};
|
|
1019
1005
|
if (!program.checker.isStdType(type)) {
|
|
1020
1006
|
return undefined;
|
|
1021
1007
|
}
|
|
@@ -1109,9 +1095,9 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1109
1095
|
reportDiagnostic(program, {
|
|
1110
1096
|
code: "decimal-to-number",
|
|
1111
1097
|
format: {
|
|
1112
|
-
propertyName:
|
|
1098
|
+
propertyName: relevantProperty?.name ?? ""
|
|
1113
1099
|
},
|
|
1114
|
-
target: relevantProperty
|
|
1100
|
+
target: relevantProperty ?? NoTarget
|
|
1115
1101
|
});
|
|
1116
1102
|
return applyIntrinsicDecorators(program, type, {
|
|
1117
1103
|
type: "number",
|
|
@@ -1122,9 +1108,9 @@ function getSchemaForStdScalar(program, type, options) {
|
|
|
1122
1108
|
reportDiagnostic(program, {
|
|
1123
1109
|
code: "decimal-to-number",
|
|
1124
1110
|
format: {
|
|
1125
|
-
propertyName:
|
|
1111
|
+
propertyName: relevantProperty?.name ?? ""
|
|
1126
1112
|
},
|
|
1127
|
-
target: relevantProperty
|
|
1113
|
+
target: relevantProperty ?? NoTarget
|
|
1128
1114
|
});
|
|
1129
1115
|
return applyIntrinsicDecorators(program, type, {
|
|
1130
1116
|
type: "number",
|
|
@@ -1201,12 +1187,10 @@ function isEncodeTypeEffective(type, encodeData) {
|
|
|
1201
1187
|
return true;
|
|
1202
1188
|
}
|
|
1203
1189
|
export function getTypeName(schema, usage) {
|
|
1204
|
-
var _a, _b;
|
|
1205
1190
|
// TODO: Handle more cases
|
|
1206
|
-
return
|
|
1191
|
+
return getPriorityName(schema, usage) ?? schema.type ?? "any";
|
|
1207
1192
|
}
|
|
1208
1193
|
export function getImportedModelName(schema, usage) {
|
|
1209
|
-
var _a, _b;
|
|
1210
1194
|
switch (schema.type) {
|
|
1211
1195
|
case "array": {
|
|
1212
1196
|
const ret = new Set();
|
|
@@ -1218,7 +1202,7 @@ export function getImportedModelName(schema, usage) {
|
|
|
1218
1202
|
case "object": {
|
|
1219
1203
|
if (isAnonymousObjectSchema(schema)) {
|
|
1220
1204
|
const ret = new Set();
|
|
1221
|
-
const properties =
|
|
1205
|
+
const properties = schema.properties ?? {};
|
|
1222
1206
|
for (const name in properties) {
|
|
1223
1207
|
if (!properties[name]) {
|
|
1224
1208
|
continue;
|
|
@@ -1240,7 +1224,7 @@ export function getImportedModelName(schema, usage) {
|
|
|
1240
1224
|
}
|
|
1241
1225
|
case "union": {
|
|
1242
1226
|
const ret = new Set();
|
|
1243
|
-
(
|
|
1227
|
+
(schema.enum ?? [])
|
|
1244
1228
|
.filter((i) => !!i)
|
|
1245
1229
|
.forEach((i) => getImportedModelName(i, usage).forEach((it) => ret.add(it)));
|
|
1246
1230
|
return [...ret];
|
|
@@ -1250,12 +1234,11 @@ export function getImportedModelName(schema, usage) {
|
|
|
1250
1234
|
}
|
|
1251
1235
|
}
|
|
1252
1236
|
function getPriorityName(schema, usage) {
|
|
1253
|
-
var _a, _b, _c;
|
|
1254
1237
|
return usage &&
|
|
1255
1238
|
usage.includes(SchemaContext.Input) &&
|
|
1256
1239
|
!usage.includes(SchemaContext.Output)
|
|
1257
|
-
? (
|
|
1258
|
-
: (
|
|
1240
|
+
? (schema.typeName ?? schema.name)
|
|
1241
|
+
: (schema.outputTypeName ?? schema.typeName ?? schema.name);
|
|
1259
1242
|
}
|
|
1260
1243
|
function getEnumStringDescription(type) {
|
|
1261
1244
|
if ((type.name === "string" ||
|
|
@@ -1275,8 +1258,7 @@ function getEnumStringDescription(type) {
|
|
|
1275
1258
|
return undefined;
|
|
1276
1259
|
}
|
|
1277
1260
|
function getBinaryDescription(type) {
|
|
1278
|
-
|
|
1279
|
-
if ((_a = type === null || type === void 0 ? void 0 : type.typeName) === null || _a === void 0 ? void 0 : _a.includes(BINARY_TYPE_UNION)) {
|
|
1261
|
+
if (type?.typeName?.includes(BINARY_TYPE_UNION)) {
|
|
1280
1262
|
return `Value may contain any sequence of octets`;
|
|
1281
1263
|
}
|
|
1282
1264
|
return undefined;
|
|
@@ -1294,21 +1276,20 @@ Always be cautious with direct arithmetic operations and consider implementing a
|
|
|
1294
1276
|
return undefined;
|
|
1295
1277
|
}
|
|
1296
1278
|
export function getFormattedPropertyDoc(program, type, schemaType, sperator = "\n\n") {
|
|
1297
|
-
var _a, _b;
|
|
1298
1279
|
const propertyDoc = getDoc(program, type);
|
|
1299
|
-
const enhancedDocFromType =
|
|
1280
|
+
const enhancedDocFromType = getEnumStringDescription(schemaType) ??
|
|
1281
|
+
getDecimalDescription(schemaType) ??
|
|
1282
|
+
getBinaryDescription(schemaType);
|
|
1300
1283
|
if (propertyDoc && enhancedDocFromType) {
|
|
1301
1284
|
return `${propertyDoc}${sperator}${enhancedDocFromType}`;
|
|
1302
1285
|
}
|
|
1303
|
-
return propertyDoc
|
|
1286
|
+
return propertyDoc ?? enhancedDocFromType;
|
|
1304
1287
|
}
|
|
1305
1288
|
export function getBodyType(route) {
|
|
1306
|
-
|
|
1307
|
-
const bodyModel = (_a = route.parameters.body) === null || _a === void 0 ? void 0 : _a.type;
|
|
1289
|
+
const bodyModel = route.parameters.body?.type;
|
|
1308
1290
|
return bodyModel;
|
|
1309
1291
|
}
|
|
1310
1292
|
export function getValueTypeValue(value) {
|
|
1311
|
-
var _a;
|
|
1312
1293
|
switch (value.valueKind) {
|
|
1313
1294
|
case "ArrayValue":
|
|
1314
1295
|
return value.values.map((x) => getValueTypeValue(x));
|
|
@@ -1319,7 +1300,7 @@ export function getValueTypeValue(value) {
|
|
|
1319
1300
|
case "NumericValue":
|
|
1320
1301
|
return value.value.asNumber();
|
|
1321
1302
|
case "EnumValue":
|
|
1322
|
-
return
|
|
1303
|
+
return value.value.value ?? value.value.name;
|
|
1323
1304
|
case "ObjectValue":
|
|
1324
1305
|
return Object.fromEntries([...value.properties.keys()].map((x) => [
|
|
1325
1306
|
x,
|
|
@@ -1340,7 +1321,6 @@ export function getValueTypeValue(value) {
|
|
|
1340
1321
|
* @returns
|
|
1341
1322
|
*/
|
|
1342
1323
|
export function predictDefaultValue(dpgContext, param) {
|
|
1343
|
-
var _a, _b;
|
|
1344
1324
|
if (!param) {
|
|
1345
1325
|
return;
|
|
1346
1326
|
}
|
|
@@ -1361,7 +1341,7 @@ export function predictDefaultValue(dpgContext, param) {
|
|
|
1361
1341
|
}
|
|
1362
1342
|
return specificDefault;
|
|
1363
1343
|
}
|
|
1364
|
-
const serviceNamespace =
|
|
1344
|
+
const serviceNamespace = getDefaultService(program, dpgContext.rlcOptions?.isModularLibrary)?.type;
|
|
1365
1345
|
if (!serviceNamespace) {
|
|
1366
1346
|
return;
|
|
1367
1347
|
}
|
|
@@ -1391,11 +1371,10 @@ export function getDefaultService(program, isModularLibrary = true) {
|
|
|
1391
1371
|
* Return the default api version from the program; undefined if no default
|
|
1392
1372
|
*/
|
|
1393
1373
|
export function getDefaultApiVersionString(dpgContext) {
|
|
1394
|
-
var _a, _b;
|
|
1395
1374
|
const program = dpgContext.program;
|
|
1396
|
-
const isModularLibrary =
|
|
1375
|
+
const isModularLibrary = dpgContext.rlcOptions?.isModularLibrary;
|
|
1397
1376
|
return getDefaultService(program, isModularLibrary)
|
|
1398
|
-
?
|
|
1377
|
+
? getDefaultApiVersion(dpgContext, getDefaultService(program, isModularLibrary).type)?.value
|
|
1399
1378
|
: undefined;
|
|
1400
1379
|
}
|
|
1401
1380
|
export function trimUsage(model) {
|
|
@@ -1423,14 +1402,13 @@ export function isAzureCoreErrorType(program, t) {
|
|
|
1423
1402
|
return isAzureCoreFoundationsNamespace(effective);
|
|
1424
1403
|
}
|
|
1425
1404
|
function isAzureCoreFoundationsNamespace(t, skipFoundation = false) {
|
|
1426
|
-
var _a;
|
|
1427
1405
|
const namespaces = (skipFoundation ? ".Azure.Core" : ".Azure.Core.Foundations").split(".");
|
|
1428
1406
|
while (namespaces.length > 0 &&
|
|
1429
|
-
(
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1407
|
+
(t?.kind === "Model" ||
|
|
1408
|
+
t?.kind === "Enum" ||
|
|
1409
|
+
t?.kind === "Union" ||
|
|
1410
|
+
t?.kind === "Namespace") &&
|
|
1411
|
+
t.namespace?.name === namespaces.pop()) {
|
|
1434
1412
|
t = t.namespace;
|
|
1435
1413
|
}
|
|
1436
1414
|
return namespaces.length == 0;
|
|
@@ -1476,8 +1454,7 @@ export function getModelInlineSigniture(schema, options = {}) {
|
|
|
1476
1454
|
return schemaSignature;
|
|
1477
1455
|
}
|
|
1478
1456
|
function getMultipartInlineSignature(schema, importedModels, usage) {
|
|
1479
|
-
|
|
1480
|
-
const types = Object.entries((_a = schema.properties) !== null && _a !== void 0 ? _a : {})
|
|
1457
|
+
const types = Object.entries(schema.properties ?? {})
|
|
1481
1458
|
.map(([propertyName, property]) => {
|
|
1482
1459
|
let schema;
|
|
1483
1460
|
// Flatten arrays for file uploads
|
|
@@ -1515,12 +1492,11 @@ function getMultipartInlineSignature(schema, importedModels, usage) {
|
|
|
1515
1492
|
* represented as properties in typespec.
|
|
1516
1493
|
*/
|
|
1517
1494
|
export function isSchemaProperty(program, property) {
|
|
1518
|
-
var _a;
|
|
1519
1495
|
const headerInfo = getHeaderFieldName(program, property);
|
|
1520
1496
|
const queryInfo = getQueryParamName(program, property);
|
|
1521
1497
|
const pathInfo = getPathParamName(program, property);
|
|
1522
1498
|
const statusCodeInfo = isStatusCode(program, property);
|
|
1523
|
-
const isNonVisibility =
|
|
1499
|
+
const isNonVisibility = getSdkVisibility(program, property)?.includes(Visibility.None);
|
|
1524
1500
|
return !(headerInfo ||
|
|
1525
1501
|
queryInfo ||
|
|
1526
1502
|
pathInfo ||
|
|
@@ -1528,7 +1504,6 @@ export function isSchemaProperty(program, property) {
|
|
|
1528
1504
|
isNonVisibility);
|
|
1529
1505
|
}
|
|
1530
1506
|
export function getEffectiveSchemaType(program, type) {
|
|
1531
|
-
var _a, _b;
|
|
1532
1507
|
// If type is an anonymous model, tries to find a named model that has the same properties
|
|
1533
1508
|
let effective = undefined;
|
|
1534
1509
|
if (type.kind === "Union") {
|
|
@@ -1536,8 +1511,8 @@ export function getEffectiveSchemaType(program, type) {
|
|
|
1536
1511
|
.map((x) => x.type)
|
|
1537
1512
|
.filter((t) => !isNullType(t));
|
|
1538
1513
|
if (nonNullOptions.length === 1 &&
|
|
1539
|
-
|
|
1540
|
-
|
|
1514
|
+
nonNullOptions[0]?.kind === "Model" &&
|
|
1515
|
+
nonNullOptions[0]?.name === "") {
|
|
1541
1516
|
effective = getEffectiveModelType(program, nonNullOptions[0]);
|
|
1542
1517
|
}
|
|
1543
1518
|
return type;
|
|
@@ -1545,14 +1520,13 @@ export function getEffectiveSchemaType(program, type) {
|
|
|
1545
1520
|
else if (type.name === "") {
|
|
1546
1521
|
effective = getEffectiveModelType(program, type, (property) => isSchemaProperty(program, property));
|
|
1547
1522
|
}
|
|
1548
|
-
if (effective
|
|
1523
|
+
if (effective?.name) {
|
|
1549
1524
|
return effective;
|
|
1550
1525
|
}
|
|
1551
1526
|
return type;
|
|
1552
1527
|
}
|
|
1553
1528
|
export function isBodyRequired(parameter) {
|
|
1554
|
-
|
|
1555
|
-
return ((_a = parameter.body) === null || _a === void 0 ? void 0 : _a.type) && ((_c = (_b = parameter.body) === null || _b === void 0 ? void 0 : _b.property) === null || _c === void 0 ? void 0 : _c.optional) !== true
|
|
1529
|
+
return parameter.body?.type && parameter.body?.property?.optional !== true
|
|
1556
1530
|
? true
|
|
1557
1531
|
: false;
|
|
1558
1532
|
}
|
|
@@ -1563,7 +1537,7 @@ export function getCollectionFormat(context, param) {
|
|
|
1563
1537
|
if (param.explode) {
|
|
1564
1538
|
return "multi";
|
|
1565
1539
|
}
|
|
1566
|
-
switch (encode
|
|
1540
|
+
switch (encode?.encoding) {
|
|
1567
1541
|
case "ArrayEncoding.pipeDelimited":
|
|
1568
1542
|
return "pipes";
|
|
1569
1543
|
case "ArrayEncoding.spaceDelimited":
|