diff --git a/packages/http-client-python/emitter/src/code-model.ts b/packages/http-client-python/emitter/src/code-model.ts index b4f2d439fb..48d0006ba6 100644 --- a/packages/http-client-python/emitter/src/code-model.ts +++ b/packages/http-client-python/emitter/src/code-model.ts @@ -216,7 +216,7 @@ function emitClient( } return { name: client.name, - description: client.description ?? "", + description: (client.summary ? client.summary : client.doc) ?? "", parameters, operationGroups, url, diff --git a/packages/http-client-python/emitter/src/http.ts b/packages/http-client-python/emitter/src/http.ts index ae1d3def9f..8216bb0a7a 100644 --- a/packages/http-client-python/emitter/src/http.ts +++ b/packages/http-client-python/emitter/src/http.ts @@ -3,6 +3,7 @@ import { SdkBodyParameter, SdkClientType, SdkHeaderParameter, + SdkHttpErrorResponse, SdkHttpOperation, SdkHttpOperationExample, SdkHttpResponse, @@ -23,7 +24,6 @@ import { emitParamBase, getAddedOn, getDelimiterAndExplode, - getDescriptionAndSummary, getImplementation, isAbstract, isAzureCoreErrorResponse, @@ -55,8 +55,8 @@ export function emitBasicHttpMethod( abstract: isAbstract(method), internal: method.access === "internal", name: camelToSnakeCase(method.name), - description: getDescriptionAndSummary(method).description, - summary: getDescriptionAndSummary(method).summary, + description: method.doc ?? "", + summary: method.summary, }, ]; } @@ -73,8 +73,8 @@ function emitInitialLroHttpMethod( isLroInitialOperation: true, wantTracing: false, exposeStreamKeyword: false, - description: getDescriptionAndSummary(method).description, - summary: getDescriptionAndSummary(method).summary, + description: method.doc ?? "", + summary: method.summary, }; } @@ -90,8 +90,8 @@ function addLroInformation( discriminator: "lro", initialOperation: emitInitialLroHttpMethod(context, rootClient, method, operationGroupName), exposeStreamKeyword: false, - description: getDescriptionAndSummary(method).description, - summary: getDescriptionAndSummary(method).summary, + description: method.doc ?? "", + summary: method.summary, }; } @@ -119,8 +119,8 @@ function addPagingInformation( itemName: method.response.resultPath, continuationTokenName: method.nextLinkPath, itemType, - description: getDescriptionAndSummary(method).description, - summary: getDescriptionAndSummary(method).summary, + description: method.doc ?? "", + summary: method.summary, }; } @@ -338,7 +338,7 @@ function emitHttpBodyParameter( function emitHttpResponse( context: PythonSdkContext, statusCodes: HttpStatusCodeRange | number | "*", - response: SdkHttpResponse, + response: SdkHttpResponse | SdkHttpErrorResponse, method?: SdkServiceMethod, isException = false, ): Record | undefined { diff --git a/packages/http-client-python/emitter/src/types.ts b/packages/http-client-python/emitter/src/types.ts index 928bff9104..356ce0c54a 100644 --- a/packages/http-client-python/emitter/src/types.ts +++ b/packages/http-client-python/emitter/src/types.ts @@ -135,7 +135,7 @@ function emitMultiPartFile( } return getSimpleTypeResult({ type: type.kind, - description: type.type.description, + description: type.type.summary ? type.type.summary : type.type.doc, }); } @@ -239,7 +239,7 @@ function emitProperty( wireName: property.serializedName, type: getType(context, sourceType), optional: property.optional, - description: property.description, + description: property.summary ? property.summary : property.doc, addedOn: getAddedOn(context, property), visibility: visibilityMapping(property.visibility), isDiscriminator: property.discriminator, @@ -277,7 +277,7 @@ function emitModel( const newValue = { type: type.kind, name: type.name, - description: type.description, + description: type.summary ? type.summary : type.doc, parents: parents, discriminatorValue: type.discriminatorValue, discriminatedSubtypes: {} as Record>, @@ -345,7 +345,7 @@ function emitEnum(type: SdkEnumType): Record { const newValue = { name: name, snakeCaseName: camelToSnakeCase(name), - description: type.description || `Type of ${name}`, + description: (type.summary ? type.summary : type.doc) ?? `Type of ${name}`, internal: type.access === "internal", type: type.kind, valueType: emitBuiltInType(type.valueType), @@ -374,7 +374,7 @@ function emitEnumMember( return { name: enumName(type.name), value: type.value, - description: type.description, + description: type.summary ? type.summary : type.doc, enumType, type: type.kind, valueType: enumType["valueType"], diff --git a/packages/http-client-python/emitter/src/utils.ts b/packages/http-client-python/emitter/src/utils.ts index 8d9972857e..6bdde071c1 100644 --- a/packages/http-client-python/emitter/src/utils.ts +++ b/packages/http-client-python/emitter/src/utils.ts @@ -175,7 +175,7 @@ export function emitParamBase( } return { optional: parameter.optional, - description: parameter.description || "", + description: (parameter.summary ? parameter.summary : parameter.doc) ?? "", addedOn: getAddedOn(context, parameter), clientName: camelToSnakeCase(parameter.name), inOverload: false, @@ -196,20 +196,6 @@ export function isAzureCoreErrorResponse(t: SdkType | undefined): boolean { ); } -export function getDescriptionAndSummary( - method: SdkMethod, -): { description?: string; summary?: string } { - if (method.details) { - return { - description: method.details, - summary: method.description, - }; - } - return { - description: method.description ?? "", - }; -} - export function capitalize(name: string): string { return name[0].toUpperCase() + name.slice(1); } diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 8691af2568..5f50181f8b 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -20,7 +20,7 @@ "@azure-tools/typespec-azure-core": "~0.46.0", "@azure-tools/typespec-azure-resource-manager": "~0.46.0", "@azure-tools/typespec-azure-rulesets": "0.46.0", - "@azure-tools/typespec-client-generator-core": "0.46.1", + "@azure-tools/typespec-client-generator-core": "0.46.2", "@types/js-yaml": "~4.0.5", "@types/node": "~22.5.4", "@types/semver": "7.5.8", @@ -45,7 +45,7 @@ "@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0", "@azure-tools/typespec-azure-resource-manager": ">=0.46.0 <1.0.0", "@azure-tools/typespec-azure-rulesets": ">=0.46.0 <3.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.46.1 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.46.2 <1.0.0", "@typespec/compiler": ">=0.60.0 <1.0.0", "@typespec/http": ">=0.60.0 <1.0.0", "@typespec/openapi": ">=0.60.0 <1.0.0", @@ -235,9 +235,9 @@ } }, "node_modules/@azure-tools/typespec-client-generator-core": { - "version": "0.46.1", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.46.1.tgz", - "integrity": "sha512-mXA+ia5vS0yxPnxRW/vjKBJP5U4e4T5Gcr+GRjuS4+1gGolmklV2prJsXdR4iFLSVFfcH1zBFXQ2OPqsI5GMJw==", + "version": "0.46.2", + "resolved": "https://registry.npmjs.org/@azure-tools/typespec-client-generator-core/-/typespec-client-generator-core-0.46.2.tgz", + "integrity": "sha512-/HKeehCNDeylouOHMe7IwpcDcGJHRAuEy3a5FBnSY51m4EpMq4VMQzW9tka/8brFO2m5LLj7tyhOL/xnzi2fLg==", "dev": true, "dependencies": { "change-case": "~5.4.4", diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 39683079d3..59939027c3 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -54,7 +54,7 @@ "@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0", "@azure-tools/typespec-azure-resource-manager": ">=0.46.0 <1.0.0", "@azure-tools/typespec-autorest": ">=0.46.0 <1.0.0", - "@azure-tools/typespec-client-generator-core": ">=0.46.1 <1.0.0", + "@azure-tools/typespec-client-generator-core": ">=0.46.2 <1.0.0", "@azure-tools/typespec-azure-rulesets": ">=0.46.0 <3.0.0", "@typespec/compiler": ">=0.60.0 <1.0.0", "@typespec/http": ">=0.60.0 <1.0.0", @@ -80,7 +80,7 @@ "typescript": "~5.6.2", "typescript-eslint": "^8.5.0", "@azure-tools/typespec-azure-core": "~0.46.0", - "@azure-tools/typespec-client-generator-core": "0.46.1", + "@azure-tools/typespec-client-generator-core": "0.46.2", "@typespec/compiler": "~0.60.0", "@typespec/http": "~0.60.0", "@typespec/rest": "~0.60.0",