Skip to content

Commit

Permalink
Add x-ms-original-file in generated sample to declare original samp…
Browse files Browse the repository at this point in the history
…le file of typespec (#2805)

* original file in sample

* changelog

* fix for ci
  • Loading branch information
msyyc authored Sep 2, 2024
1 parent 3856eb4 commit 8ad6754
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .chronus/changes/sample-dir-2024-8-2-13-40-48.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-python"
---

Add `x-ms-original-file` in generated sample to declare original sample file of typespec
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def _origin_file(self) -> str:
name = self.sample.get("x-ms-original-file", "")
if "specification" in name:
return "specification" + name.split("specification")[-1]
return ""
return name if self.code_model.options["from_typespec"] else ""

def serialize(self) -> str:
operation_result, return_var = self._operation_result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def main():
print(response)


# x-ms-original-file: 2022-12-01-preview/basic.json
if __name__ == "__main__":
main()

0 comments on commit 8ad6754

Please sign in to comment.