-
Notifications
You must be signed in to change notification settings - Fork 61
Advanced multipart implementation #2740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0853790
c1cb5fc
b58923f
4059961
8e152a7
99df939
9d03371
11748a1
523c1b1
dd200c0
f08497f
06c19ee
e712e35
6c94b84
a8d49c8
909288b
e5c4aa9
c43878f
c6b4336
e0b32a0
dfad160
dd3c751
f2556e8
89caa85
51dc805
7af96d8
1d2edfb
d81d91a
d1588ce
493e119
1c94593
f91635b
685a788
b5efa05
11f2653
a2a0754
a4e3c49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@azure-tools/typespec-python" | ||
| --- | ||
|
|
||
| Support advanced multipart for `@multipartBody` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,9 @@ async function getSubdirectories(baseDir: string, flags: RegenerateFlags): Promi | |
| // after xml support, remove this check | ||
| if (mainTspRelativePath.includes("xml")) return; | ||
|
|
||
| // after fix test generation for nested operation group, remove this check | ||
| if (mainTspRelativePath.includes("client-operation-group")) return; | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will make another PR to fix test generation for this case |
||
| const hasMainTsp = await promises | ||
| .access(mainTspPath) | ||
| .then(() => true) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { | |
| UsageFlags, | ||
| getCrossLanguagePackageId, | ||
| } from "@azure-tools/typespec-client-generator-core"; | ||
| import { KnownTypes, emitEndpointType, getType, simpleTypesMap, typesMap } from "./types.js"; | ||
| import { KnownTypes, disableGenerationMap, emitEndpointType, getType, simpleTypesMap, typesMap } from "./types.js"; | ||
| import { emitParamBase, getImplementation, removeUnderscoresFromNamespace } from "./utils.js"; | ||
| import { emitBasicHttpMethod, emitLroHttpMethod, emitLroPagingHttpMethod, emitPagingHttpMethod } from "./http.js"; | ||
| import { PythonSdkContext } from "./lib.js"; | ||
|
|
@@ -218,25 +218,28 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>( | |
| clients: [], | ||
| subnamespaceToClients: {}, | ||
| }; | ||
| for (const client of sdkPackage.clients) { | ||
| codeModel["clients"].push(emitClient(sdkContext, client)); | ||
| if (client.nameSpace === sdkPackage.rootNamespace) { | ||
| } else { | ||
| codeModel["subnamespaceToClients"][client.nameSpace] = emitClient(sdkContext, client); | ||
| } | ||
| } | ||
| // loop through models and enums since there may be some orphaned models needs to be generated | ||
| for (const model of sdkPackage.models) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put loop for models/enums behind emitClients so that we could collect models which will not be generated (e.g. models for multipart file part) and disable them by not calling getType to add them into typesMap |
||
| if (model.name === "" || (model.usage & UsageFlags.Spread) > 0) { | ||
| continue; | ||
| } | ||
| getType(sdkContext, model); | ||
| if (!disableGenerationMap.has(model)) { | ||
|
tadelesh marked this conversation as resolved.
|
||
| getType(sdkContext, model); | ||
| } | ||
| } | ||
| for (const sdkEnum of sdkPackage.enums) { | ||
| if (sdkEnum.usage === UsageFlags.ApiVersionEnum) { | ||
| continue; | ||
| } | ||
| getType(sdkContext, sdkEnum); | ||
| } | ||
| for (const client of sdkPackage.clients) { | ||
| codeModel["clients"].push(emitClient(sdkContext, client)); | ||
| if (client.nameSpace === sdkPackage.rootNamespace) { | ||
| } else { | ||
| codeModel["subnamespaceToClients"][client.nameSpace] = emitClient(sdkContext, client); | ||
| } | ||
| } | ||
| codeModel["types"] = [...typesMap.values(), ...Object.values(KnownTypes), ...simpleTypesMap.values()]; | ||
| codeModel["crossLanguagePackageId"] = ignoreDiagnostics(getCrossLanguagePackageId(sdkContext)); | ||
| return codeModel; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new type, we don't need special logic in docstring/typing annotation for multipart properties anymore. And it is much easier to evolve in the future.