Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core
Submodule core updated 111 files
18 changes: 7 additions & 11 deletions packages/typespec-autorest/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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" } };
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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!, {
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 2 additions & 4 deletions packages/typespec-azure-core/src/decorators/unique-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions packages/typespec-azure-resource-manager/src/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions packages/typespec-client-generator-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Loading