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/route_to_err-2024-8-9-11-51-57.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-python"
---

Include link to core models for `HttpResponseError` when it's included as a property in a model
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ class SdkCoreType(PrimitiveType):
def __init__(self, yaml_data: Dict[str, Any], code_model: "CodeModel") -> None:
super().__init__(yaml_data=yaml_data, code_model=code_model)
self.name = yaml_data.get("name", "")
self.submodule = yaml_data.get("submodule", "")

def docstring_type(self, **kwargs: Any) -> str:
return f"~{self.code_model.core_library}.{self.type_annotation(**kwargs)}"
Expand All @@ -620,7 +621,7 @@ def type_annotation(self, **kwargs: Any) -> str:

def imports(self, **kwargs: Any) -> FileImport:
file_import = super().imports(**kwargs)
file_import.add_submodule_import("", self.name, ImportType.SDKCORE)
file_import.add_submodule_import(self.submodule, self.name, ImportType.SDKCORE)
return file_import

@property
Expand Down
7 changes: 7 additions & 0 deletions packages/typespec-python/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ function emitModel<TServiceOperation extends SdkServiceOperation>(
if (typesMap.has(type)) {
return typesMap.get(type)!;
}
if (type.crossLanguageDefinitionId === "Azure.Core.Foundations.Error") {
return {
type: "sdkcore",
name: "HttpResponseError",
submodule: "exceptions",
};
}
const parents: Record<string, any>[] = [];
const newValue = {
type: type.kind,
Expand Down