Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into bump-tcgc-version
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcturusZhang committed Dec 10, 2024
2 parents 32642fc + 86f3649 commit db15e17
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 21 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/ReleaseHttpSpecsAlpha4-2024-11-8-23-14-16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/http-specs"
---

Modifies Spec Scenarios
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/compiler"
---

Fixes incorrect default value in dev doc
2 changes: 1 addition & 1 deletion packages/compiler/src/testing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface TypeSpecTestLibraryInit {
typespecFileFolder?: string;

/**
* JS files folder. @default "dist"
* JS files folder. @default "dist/src"
*/
jsFileFolder?: string;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/http-client-python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log - @typespec/http-client-python

## 0.4.2

### Bug Fixes

- Ignore models/enum only used as LRO envelope results
- Refine exception handling logic to keep compatibility for legacy SDK

## 0.4.1

### Bug Fixes
Expand Down
27 changes: 14 additions & 13 deletions packages/http-client-python/emitter/src/code-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ function emitClient<TServiceOperation extends SdkServiceOperation>(
};
}

function onlyUsedByPolling(usage: UsageFlags): boolean {
return (
((usage & UsageFlags.LroInitial) > 0 ||
(usage & UsageFlags.LroFinalEnvelope) > 0 ||
(usage & UsageFlags.LroPolling) > 0) &&
(usage & UsageFlags.Input) === 0 &&
(usage & UsageFlags.Output) === 0
);
}

export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
sdkContext: PythonSdkContext<TServiceOperation>,
) {
Expand All @@ -269,9 +279,6 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
}
// loop through models and enums since there may be some orphaned models needs to be generated
for (const model of sdkPackage.models) {
if (isAzureCoreModel(model)) {
continue;
}
// filter out spread models
if (
model.name === "" ||
Expand All @@ -282,13 +289,7 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
continue;
}
// filter out models only used for polling and or envelope result
if (
((model.usage & UsageFlags.LroInitial) > 0 ||
(model.usage & UsageFlags.LroFinalEnvelope) > 0 ||
(model.usage & UsageFlags.LroPolling) > 0) &&
(model.usage & UsageFlags.Input) === 0 &&
(model.usage & UsageFlags.Output) === 0
) {
if (onlyUsedByPolling(model.usage)) {
continue;
}
// filter out specific models not used in python, e.g., pageable models
Expand All @@ -302,13 +303,13 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
getType(sdkContext, model);
}
for (const sdkEnum of sdkPackage.enums) {
if (isAzureCoreModel(sdkEnum)) {
continue;
}
// filter out api version enum since python do not generate it
if (sdkEnum.usage === UsageFlags.ApiVersionEnum) {
continue;
}
if (onlyUsedByPolling(sdkEnum.usage)) {
continue;
}
// filter out core enums
if (isAzureCoreModel(sdkEnum)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def default_error_deserialization(self) -> Optional[str]:
exception_schema = default_exceptions[0].type
if isinstance(exception_schema, ModelType):
return exception_schema.type_annotation(skip_quote=True)
return None
return None if self.code_model.options["models_mode"] == "dpg" else "'object'"

@property
def non_default_errors(self) -> List[Response]:
Expand Down
4 changes: 2 additions & 2 deletions packages/http-client-python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/http-client-python/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typespec/http-client-python",
"version": "0.4.1",
"version": "0.4.2",
"author": "Microsoft Corporation",
"description": "TypeSpec emitter for Python SDKs",
"homepage": "https://typespec.io",
Expand Down
4 changes: 4 additions & 0 deletions packages/http-specs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @typespec/http-specs

## 0.1.0-alpha.4

- Update Versioning/Removed Project And Removed Type/Model/Templated. Please refer [PR #5217](https://github.com/microsoft/typespec/pull/5217) for further details.

## 0.1.0-alpha.3

- Create coverages container if not existing
Expand Down
4 changes: 2 additions & 2 deletions packages/http-specs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typespec/http-specs",
"version": "0.1.0-alpha.3",
"version": "0.1.0-alpha.4",
"description": "Spec scenarios and mock apis",
"main": "dist/index.js",
"type": "module",
Expand All @@ -13,7 +13,7 @@
"generate-scenarios-summary": "tsp-spector generate-scenarios-summary ./specs",
"regen-docs": "pnpm generate-scenarios-summary",
"upload-manifest": "tsp-spector upload-manifest ./specs --setName @typespec/http-specs --containerName manifests-typespec --storageAccountName typespec",
"upload-coverage": "tsp-spector upload-coverage --generatorName @typespec/http-specs --generatorVersion 0.1.0-alpha.3 --containerName coverages --generatorMode standard --storageAccountName typespec",
"upload-coverage": "tsp-spector upload-coverage --generatorName @typespec/http-specs --generatorVersion 0.1.0-alpha.4 --containerName coverages --generatorMode standard --storageAccountName typespec",
"validate-mock-apis": "tsp-spector validate-mock-apis ./specs",
"check-scenario-coverage": "tsp-spector check-coverage ./specs",
"validate-client-server": "concurrently \"tsp-spector server start ./specs\" \"npm run client\" && tsp-spector server stop",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const GeneratorInformation: FunctionComponent<GeneratorInformationProps>
valueTitle={report.createdAt}
/>
<InfoEntry
label="Cadl Ranch Spec version"
label="Spec version"
caption="This is the version of the spec package used to create this report"
value={report.scenariosMetadata.version}
/>
Expand Down

0 comments on commit db15e17

Please sign in to comment.