Skip to content
Open
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
32 changes: 26 additions & 6 deletions packages/http-client-java/emitter/src/code-model-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,11 @@ export class CodeModelBuilder {
// skip models under "com.azure.core." in java, or "Azure." in typespec, if branded
!(
(
this.isBranded() &&
(schema.language.java?.namespace?.startsWith("com.azure.core.") ||
schema.language.default?.namespace?.startsWith("Azure.") ||
schema.language.java?.namespace?.startsWith("com.azure.v2.core.") ||
(this.isBranded() &&
(schema.language.java?.namespace?.startsWith("com.azure.core.") ||
schema.language.default?.namespace?.startsWith("Azure.") ||
schema.language.java?.namespace?.startsWith("com.azure.v2.core."))) ||
(!this.isBranded() &&
schema.language.java?.namespace?.startsWith("io.clientcore.core."))
) // because azure core v2 uses clientcore types
)
Expand Down Expand Up @@ -1072,6 +1073,22 @@ export class CodeModelBuilder {
? pageItemsResponseProperty[0].serializedName
: undefined;

if (
this.isAzureV1() &&
(pageItemsResponseProperty === undefined || pageItemsResponseProperty.length > 1)
) {
// TCGC should have verified that pageItems exists

// Azure V1 does not support nested page items
reportDiagnostic(this.program, {
code: "nested-page-items-not-supported",
target:
sdkMethod.response.resultSegments?.[sdkMethod.response.resultSegments.length - 1]
?.__raw ?? NoTarget,
});
return;
}

// nextLink
// TODO: nextLink can also be a response header, similar to "sdkMethod.pagingMetadata.continuationTokenResponseSegments"
const nextLinkResponseProperty = findResponsePropertySegments(
Expand All @@ -1088,7 +1105,7 @@ export class CodeModelBuilder {
let continuationTokenParameter: Parameter | undefined;
let continuationTokenResponseProperty: Property[] | undefined;
let continuationTokenResponseHeader: HttpHeader | undefined;
if (!this.isBranded()) {
if (!this.isAzureV1()) {
Copy link
Contributor Author

@weidongxu-microsoft weidongxu-microsoft Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azurev2 can have same generated code, as unbranded

// parameter would either be query or header parameter, so taking the last segment would be enough
const continuationTokenParameterSegment =
sdkMethod.pagingMetadata.continuationTokenParameterSegments?.at(-1);
Expand Down Expand Up @@ -1807,7 +1824,10 @@ export class CodeModelBuilder {
}
}

const schemaName = groupToRequestConditions ? "RequestConditions" : "MatchConditions";
let schemaName = groupToRequestConditions ? "RequestConditions" : "MatchConditions";
if (!this.isBranded()) {
schemaName = "Http" + schemaName;
Copy link
Contributor Author

@weidongxu-microsoft weidongxu-microsoft Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
const schemaDescription = groupToRequestConditions
? "Specifies HTTP options for conditional requests based on modification time."
: "Specifies HTTP options for conditional requests.";
Expand Down
6 changes: 6 additions & 0 deletions packages/http-client-java/emitter/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export const $lib = createTypeSpecLibrary({
default: paramMessage`Namespace '${"namespace"}' contains reserved Java keywords, replaced it with '${"processedNamespace"}'.`,
},
},
"nested-page-items-not-supported": {
severity: "warning",
messages: {
default: "Nested pageItems is not supported in Azure V1.",
},
},
},
emitter: {
options: EmitterOptionsSchema,
Expand Down
Loading