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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-autorest-canonical"
---

16 changes: 8 additions & 8 deletions packages/typespec-autorest-canonical/src/emitter.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import {
AutorestDocumentEmitterOptions,
AutorestEmitterContext,
type AutorestDocumentEmitterOptions,
type AutorestEmitterContext,
getOpenAPIForService,
sortOpenAPIDocument,
} from "@azure-tools/typespec-autorest";
import { isArmCommonType } from "@azure-tools/typespec-azure-resource-manager";
import { createTCGCContext, type TCGCContext } from "@azure-tools/typespec-client-generator-core";
import {
EmitContext,
type EmitContext,
emitFile,
getDirectoryPath,
getNamespaceFullName,
interpolatePath,
listServices,
Namespace,
type Namespace,
navigateType,
Program,
type Program,
resolvePath,
Service,
Type,
type Service,
type Type,
} from "@typespec/compiler";
import {
getRenamedFrom,
getReturnTypeChangedFrom,
getTypeChangedFrom,
getVersion,
} from "@typespec/versioning";
import { AutorestCanonicalEmitterOptions, reportDiagnostic } from "./lib.js";
import { type AutorestCanonicalEmitterOptions, reportDiagnostic } from "./lib.js";

const defaultOptions = {
"output-file": "{azure-resource-provider-folder}/{service-name}/canonical/openapi.json",
Expand Down
3 changes: 2 additions & 1 deletion packages/typespec-autorest-canonical/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { $onEmit } from "./emitter.js";
export { $lib, AutorestCanonicalEmitterOptions } from "./lib.js";
export { $lib } from "./lib.js";
export type { AutorestCanonicalEmitterOptions } from "./lib.js";
2 changes: 1 addition & 1 deletion packages/typespec-autorest-canonical/src/lib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createTypeSpecLibrary, JSONSchemaType, paramMessage } from "@typespec/compiler";
import { createTypeSpecLibrary, type JSONSchemaType, paramMessage } from "@typespec/compiler";

export interface AutorestCanonicalEmitterOptions {
/**
Expand Down
10 changes: 0 additions & 10 deletions packages/typespec-autorest-canonical/src/testing/index.ts

This file was deleted.

63 changes: 0 additions & 63 deletions packages/typespec-autorest-canonical/test/test-host.ts

This file was deleted.

31 changes: 31 additions & 0 deletions packages/typespec-autorest-canonical/test/tester.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { resolvePath } from "@typespec/compiler";
import { createTester } from "@typespec/compiler/testing";

export const ApiTester = createTester(resolvePath(import.meta.dirname, ".."), {
libraries: [
"@typespec/http",
"@typespec/rest",
"@typespec/openapi",
"@azure-tools/typespec-autorest-canonical",
"@typespec/versioning",
],
});

export const Tester = ApiTester.import(
"@typespec/http",
"@typespec/rest",
"@typespec/openapi",
"@typespec/versioning",
)
.using("Http", "Rest", "OpenAPI", "Versioning")
.emit("@azure-tools/typespec-autorest-canonical");

export async function openApiFor(code: string) {
const runner = await Tester.createInstance();
const results = await runner.compile(code);
return JSON.parse(results.outputs["canonical/openapi.json"]);
}

export async function diagnoseOpenApiFor(code: string) {
return Tester.diagnose(code);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expectDiagnostics } from "@typespec/compiler/testing";
import { deepStrictEqual, strictEqual } from "assert";
import { it } from "vitest";
import { canonicalVersion } from "../src/emitter.js";
import { diagnoseOpenApiFor, openApiFor } from "./test-host.js";
import { diagnoseOpenApiFor, openApiFor } from "./tester.js";

it("works with models", async () => {
const v = await openApiFor(
Expand Down
3 changes: 2 additions & 1 deletion packages/typespec-autorest-canonical/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
"tsBuildInfoFile": "temp/tsconfig.tsbuildinfo"
"tsBuildInfoFile": "temp/tsconfig.tsbuildinfo",
"verbatimModuleSyntax": true
},
"include": ["src/**/*.ts", "test/**/*.ts"]
}
Loading