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
7 changes: 7 additions & 0 deletions .chronus/changes/python-metadata-2025-4-15-18-12-43.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/http-client-python"
---

store apiVersion info in `_metadata.json`
3 changes: 3 additions & 0 deletions packages/http-client-python/emitter/src/code-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,8 @@ export function emitCodeModel(sdkContext: PythonSdkContext) {
...simpleTypesMap.values(),
];
codeModel["crossLanguagePackageId"] = ignoreDiagnostics(getCrossLanguagePackageId(sdkContext));
if ((sdkContext.emitContext.options as any).flavor === "azure") {
codeModel["metadata"] = sdkPackage.metadata;
}
return codeModel;
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(
self.has_subnamespace = False
self._operations_folder_name: Dict[str, str] = {}
self._relative_import_path: Dict[str, str] = {}
self.metadata: Dict[str, Any] = yaml_data.get("metadata", {})

@staticmethod
def get_imported_namespace_for_client(imported_namespace: str, async_mode: bool = False) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# license information.
# --------------------------------------------------------------------------
import logging
import json
from collections import namedtuple
import re
from typing import List, Any, Union
Expand Down Expand Up @@ -143,6 +144,13 @@ def serialize(self) -> None:
self._serialize_and_write_sample(env, namespace=client_namespace)
if self.code_model.options["generate_test"]:
self._serialize_and_write_test(env, namespace=client_namespace)

# add _metadata.json
if self.code_model.metadata:
self.write_file(
exec_path / Path("_metadata.json"),
json.dumps(self.code_model.metadata, indent=2),
)
elif client_namespace_type.clients:
# add clients folder if there are clients in this namespace
self._serialize_client_and_config_files(client_namespace, client_namespace_type.clients, env)
Expand Down
Loading