diff --git a/core b/core index 266f99cbf5..db95fbd776 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 266f99cbf5b275bdc08713cdf2e1bad811412ca9 +Subproject commit db95fbd7763bf13a4ae0f4f7800ba233041f7455 diff --git a/packages/typespec-autorest/src/openapi.ts b/packages/typespec-autorest/src/openapi.ts index 230d886c78..c9b15b2e81 100644 --- a/packages/typespec-autorest/src/openapi.ts +++ b/packages/typespec-autorest/src/openapi.ts @@ -485,7 +485,7 @@ export async function getOpenAPIForService( const model: Model | IntrinsicType = metadata.finalResult; const schemaOrRef = resolveExternalRef(metadata.finalResult); let overrideName: ((name: string, visibility: Visibility) => string) | undefined = undefined; - if (model.kind === "Model" && isArrayModelType(program, model)) { + if (model.kind === "Model" && isArrayModelType(model)) { const itemType = getModelOrScalarTypeIfNullable(model.indexer?.value); if (itemType?.kind === "Model" && itemType.name.length > 0) { overrideName = (n: string, v: Visibility) => @@ -1159,7 +1159,7 @@ export async function getOpenAPIForService( return { type: "file" }; } - if (type.kind === "Model" && isArrayModelType(program, type)) { + if (type.kind === "Model" && isArrayModelType(type)) { const elementType = type.indexer.value; if (isBytes(elementType)) { return { type: "array", items: { type: "string", format: "binary" } }; @@ -1256,7 +1256,7 @@ export async function getOpenAPIForService( OpenAPI2QueryParameter | OpenAPI2HeaderParameter | OpenAPI2PathParameter, "type" | "items" > { - if (param.type.kind === "Model" && isArrayModelType(program, param.type)) { + if (param.type.kind === "Model" && isArrayModelType(param.type)) { const itemSchema = getSchemaForPrimitiveItems( param.type.indexer.value, schemaContext, @@ -1838,7 +1838,7 @@ export async function getOpenAPIForService( const properties: OpenAPI2Schema["properties"] = {}; - if (isRecordModelType(program, model)) { + if (isRecordModelType(model)) { modelSchema.additionalProperties = getSchemaOrRef(model.indexer.value, schemaContext); } @@ -2131,7 +2131,7 @@ export async function getOpenAPIForService( setXmlField("attribute", true); } - if (prop.type.kind === "Model" && isArrayModelType(program, prop.type)) { + if (prop.type.kind === "Model" && isArrayModelType(prop.type)) { const wrapped = !xml.module.isUnwrapped(program, prop); setXmlField("wrapped", wrapped); @@ -2460,7 +2460,7 @@ export async function getOpenAPIForService( context: SchemaContext, namespace?: Namespace, ): OpenAPI2Schema | undefined { - if (isArrayModelType(program, typespecType)) { + if (isArrayModelType(typespecType)) { const array: OpenAPI2Schema = { type: "array", items: getSchemaOrRef(typespecType.indexer.value!, { @@ -2488,11 +2488,7 @@ export async function getOpenAPIForService( property: ModelProperty, ) { const armIdentifiers = getArmIdentifiers(program, property); - if ( - typespecType.kind !== "Model" || - !isArrayModelType(program, typespecType) || - !armIdentifiers - ) { + if (typespecType.kind !== "Model" || !isArrayModelType(typespecType) || !armIdentifiers) { return; } diff --git a/packages/typespec-azure-core/src/decorators/unique-items.ts b/packages/typespec-azure-core/src/decorators/unique-items.ts index 829b9c5f33..64a50b9678 100644 --- a/packages/typespec-azure-core/src/decorators/unique-items.ts +++ b/packages/typespec-azure-core/src/decorators/unique-items.ts @@ -16,9 +16,7 @@ export const $uniqueItems: UniqueItemsDecorator = ( ) => { const { program } = context; if (entity.kind === "ModelProperty") { - if ( - !isTypeOrNullableType(entity.type, (t) => t.kind === "Model" && isArrayModelType(program, t)) - ) { + if (!isTypeOrNullableType(entity.type, (t) => t.kind === "Model" && isArrayModelType(t))) { reportDiagnostic(program, { code: "unique-items-invalid-type", target: entity, @@ -28,7 +26,7 @@ export const $uniqueItems: UniqueItemsDecorator = ( setUniqueItems(program, entity, true); return; } - if (!isArrayModelType(program, entity)) { + if (!isArrayModelType(entity)) { reportDiagnostic(program, { code: "unique-items-invalid-type", target: entity, diff --git a/packages/typespec-azure-resource-manager/src/resource.ts b/packages/typespec-azure-resource-manager/src/resource.ts index e4d0de9031..bf9541f8aa 100644 --- a/packages/typespec-azure-resource-manager/src/resource.ts +++ b/packages/typespec-azure-resource-manager/src/resource.ts @@ -1123,11 +1123,7 @@ export const $identifiers: IdentifiersDecorator = ( ) => { const { program } = context; const type = entity.kind === "ModelProperty" ? entity.type : entity; - if ( - type.kind !== "Model" || - !isArrayModelType(program, type) || - type.indexer.value.kind !== "Model" - ) { + if (type.kind !== "Model" || !isArrayModelType(type) || type.indexer.value.kind !== "Model") { reportDiagnostic(program, { code: "decorator-param-wrong-type", messageId: "armIdentifiersIncorrectEntity", diff --git a/packages/typespec-azure-resource-manager/src/rules/missing-x-ms-identifiers.ts b/packages/typespec-azure-resource-manager/src/rules/missing-x-ms-identifiers.ts index 4dde74667f..5d60502b02 100644 --- a/packages/typespec-azure-resource-manager/src/rules/missing-x-ms-identifiers.ts +++ b/packages/typespec-azure-resource-manager/src/rules/missing-x-ms-identifiers.ts @@ -25,7 +25,7 @@ export const missingXmsIdentifiersRule = createRule({ return { modelProperty: (property: ModelProperty) => { const type = property.type; - if (type.kind === "Model" && isArrayModelType(context.program, type)) { + if (type.kind === "Model" && isArrayModelType(type)) { if (isArrayMissingIdentifier(context.program, type, property)) { context.reportDiagnostic({ target: property, diff --git a/packages/typespec-azure-resource-manager/src/rules/no-empty-model.ts b/packages/typespec-azure-resource-manager/src/rules/no-empty-model.ts index fc5c3de8af..9190578eb0 100644 --- a/packages/typespec-azure-resource-manager/src/rules/no-empty-model.ts +++ b/packages/typespec-azure-resource-manager/src/rules/no-empty-model.ts @@ -14,7 +14,7 @@ export const noEmptyModel = createRule({ create(context) { return { model: (model: Model) => { - if (model.properties.size === 0 && !isRecordModelType(context.program, model)) { + if (model.properties.size === 0 && !isRecordModelType(model)) { context.reportDiagnostic({ code: "no-empty-model", target: model, diff --git a/packages/typespec-client-generator-core/src/types.ts b/packages/typespec-client-generator-core/src/types.ts index 0564a7fd10..8052f57c62 100644 --- a/packages/typespec-client-generator-core/src/types.ts +++ b/packages/typespec-client-generator-core/src/types.ts @@ -2188,7 +2188,7 @@ function updateXmlSerializationOptions( if ( type.__raw?.kind === "ModelProperty" && type.__raw.type.kind === "Model" && - isArrayModelType(context.program, type.__raw.type) + isArrayModelType(type.__raw.type) ) { if (!type.serializationOptions.xml.unwrapped) { // if wrapped, set itemsName and itemsNS according to the array item type @@ -2224,11 +2224,7 @@ function hasExplicitlyDefinedXmlSerializationInfo(context: TCGCContext, type: Ty return true; } } - if ( - type.kind === "ModelProperty" && - type.type.kind === "Model" && - isArrayModelType(context.program, type.type) - ) { + if (type.kind === "ModelProperty" && type.type.kind === "Model" && isArrayModelType(type.type)) { const itemType = type.type.indexer.value; if (itemType && hasExplicitlyDefinedXmlSerializationInfo(context, itemType)) { return true;