Skip to content

Commit

Permalink
Back merge autorest 0.42.1 hotfix into main (Azure#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored May 15, 2024
1 parent 00fb10e commit 46a27cc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/typespec-autorest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log - @azure-tools/typespec-autorest

## 0.42.1

### Bug Fixes

- [#839](https://github.com/Azure/typespec-azure/pull/839) Do not omit unreferenced non version enum when `omit-unreachable-types` is not set to true


## 0.42.0

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-autorest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/typespec-autorest",
"version": "0.42.0",
"version": "0.42.1",
"author": "Microsoft Corporation",
"description": "TypeSpec library for emitting openapi from the TypeSpec REST protocol binding",
"homepage": "https://azure.github.io/typespec-azure",
Expand Down
4 changes: 2 additions & 2 deletions packages/typespec-autorest/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,8 @@ export async function getOpenAPIForService(
}

function isVersionEnum(program: Program, enumObj: Enum): boolean {
const versions = getVersionsForEnum(program, enumObj);
if (versions !== undefined && versions.length > 0) {
const [_, map] = getVersionsForEnum(program, enumObj);
if (map !== undefined && map.getVersions()[0].enumMember.enum === enumObj) {
return true;
}
return false;
Expand Down
13 changes: 13 additions & 0 deletions packages/typespec-autorest/test/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ op test(): void;
});
deepStrictEqual(Object.keys(output.definitions!), ["NotReferenced", "Versions"]);
});

it("doesn't omit other enums", async () => {
const output = await openapiWithOptions(
`@service
@versioned(Versions)
namespace My {
enum Versions {v1, v2}
enum NotReferenced {a, b}
}`,
{}
);
deepStrictEqual(Object.keys(output.definitions!), ["NotReferenced"]);
});
});

describe("include-x-typespec-name", () => {
Expand Down

0 comments on commit 46a27cc

Please sign in to comment.