From 457572a4ca8128d68382f39d9b21f903006f9095 Mon Sep 17 00:00:00 2001 From: Travis Prescott Date: Tue, 19 Sep 2023 10:51:06 -0700 Subject: [PATCH] Regen samples and update tests. --- .../openapi/openApi-FixNamespace_2023-09-19-19-48.json | 10 ++++++++++ packages/openapi/lib/decorators.tsp | 2 +- packages/openapi/src/decorators.ts | 2 +- packages/openapi/test/decorators.test.ts | 3 ++- packages/openapi/test/test-host.ts | 2 +- packages/openapi3/test/test-host.ts | 4 ++-- packages/openapi3/test/versioning.test.ts | 2 +- packages/playground-website/samples/unions.tsp | 2 +- .../specs/openapi-extensions/openapi-extensions.tsp | 2 +- .../specs/testserver/body-boolean/body-boolean.tsp | 2 +- .../specs/testserver/media-types/media-types.tsp | 2 +- 11 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 common/changes/@typespec/openapi/openApi-FixNamespace_2023-09-19-19-48.json diff --git a/common/changes/@typespec/openapi/openApi-FixNamespace_2023-09-19-19-48.json b/common/changes/@typespec/openapi/openApi-FixNamespace_2023-09-19-19-48.json new file mode 100644 index 00000000000..10d05bbee43 --- /dev/null +++ b/common/changes/@typespec/openapi/openApi-FixNamespace_2023-09-19-19-48.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@typespec/openapi", + "comment": "Changed namespace from `OpenAPI` to `TypeSpec.OpenAPI`.", + "type": "none" + } + ], + "packageName": "@typespec/openapi" +} \ No newline at end of file diff --git a/packages/openapi/lib/decorators.tsp b/packages/openapi/lib/decorators.tsp index 53dde05e333..99675e33665 100644 --- a/packages/openapi/lib/decorators.tsp +++ b/packages/openapi/lib/decorators.tsp @@ -1,6 +1,6 @@ using TypeSpec.Reflection; -namespace OpenAPI; +namespace TypeSpec.OpenAPI; /** * Specify the OpenAPI `operationId` property for this operation. diff --git a/packages/openapi/src/decorators.ts b/packages/openapi/src/decorators.ts index c5f100e7e9e..0c6b4f2e33c 100644 --- a/packages/openapi/src/decorators.ts +++ b/packages/openapi/src/decorators.ts @@ -12,7 +12,7 @@ import { setStatusCode } from "@typespec/http"; import { createStateSymbol, reportDiagnostic } from "./lib.js"; import { AdditionalInfo, ExtensionKey } from "./types.js"; -export const namespace = "OpenAPI"; +export const namespace = "TypeSpec.OpenAPI"; const operationIdsKey = createStateSymbol("operationIds"); /** diff --git a/packages/openapi/test/decorators.test.ts b/packages/openapi/test/decorators.test.ts index d6b608b92b3..dc604f58ab6 100644 --- a/packages/openapi/test/decorators.test.ts +++ b/packages/openapi/test/decorators.test.ts @@ -169,7 +169,8 @@ describe("openapi: decorators", () => { expectDiagnostics(diagnostics, { code: "invalid-argument", - message: "Argument '123' is not assignable to parameter of type 'OpenAPI.AdditionalInfo'", + message: + "Argument '123' is not assignable to parameter of type 'TypeSpec.OpenAPI.AdditionalInfo'", }); }); diff --git a/packages/openapi/test/test-host.ts b/packages/openapi/test/test-host.ts index 60166f3ad71..c32f07e16bb 100644 --- a/packages/openapi/test/test-host.ts +++ b/packages/openapi/test/test-host.ts @@ -10,5 +10,5 @@ export async function createOpenAPITestHost() { } export async function createOpenAPITestRunner() { const host = await createOpenAPITestHost(); - return createTestWrapper(host, { autoUsings: ["OpenAPI"] }); + return createTestWrapper(host, { autoUsings: ["TypeSpec.OpenAPI"] }); } diff --git a/packages/openapi3/test/test-host.ts b/packages/openapi3/test/test-host.ts index cb39e3004eb..7d3c64706b1 100644 --- a/packages/openapi3/test/test-host.ts +++ b/packages/openapi3/test/test-host.ts @@ -36,7 +36,7 @@ export async function createOpenAPITestRunner({ ${withVersioning ? `import "@typespec/versioning"` : ""}; using TypeSpec.Rest; using TypeSpec.Http; - using OpenAPI; + using TypeSpec.OpenAPI; ${withVersioning ? "using TypeSpec.Versioning;" : ""} `; return createTestWrapper(host, { @@ -67,7 +67,7 @@ export async function openApiFor( "./main.tsp", `import "@typespec/http"; import "@typespec/rest"; import "@typespec/openapi"; import "@typespec/openapi3"; ${ versions ? `import "@typespec/versioning"; using TypeSpec.Versioning;` : "" - }using TypeSpec.Rest;using TypeSpec.Http;using OpenAPI;${code}` + }using TypeSpec.Rest;using TypeSpec.Http;using TypeSpec.OpenAPI;${code}` ); const diagnostics = await host.diagnose("./main.tsp", { noEmit: false, diff --git a/packages/openapi3/test/versioning.test.ts b/packages/openapi3/test/versioning.test.ts index d05e7b3d6a7..985e6eaaf38 100644 --- a/packages/openapi3/test/versioning.test.ts +++ b/packages/openapi3/test/versioning.test.ts @@ -118,7 +118,7 @@ describe("openapi3: versioning", () => { const runner = createTestWrapper(host, { autoImports: [...host.libraries.map((x) => x.name), "./test.js"], - autoUsings: ["TypeSpec.Rest", "TypeSpec.Http", "OpenAPI", "TypeSpec.Versioning"], + autoUsings: ["TypeSpec.Rest", "TypeSpec.Http", "TypeSpec.OpenAPI", "TypeSpec.Versioning"], compilerOptions: { emit: ["@typespec/openapi3"] }, }); diff --git a/packages/playground-website/samples/unions.tsp b/packages/playground-website/samples/unions.tsp index 83ba04f26fa..6a6746d1afe 100644 --- a/packages/playground-website/samples/unions.tsp +++ b/packages/playground-website/samples/unions.tsp @@ -8,7 +8,7 @@ import "@typespec/openapi3"; namespace DemoService; using TypeSpec.Rest; using TypeSpec.Http; -using OpenAPI; +using TypeSpec.OpenAPI; model WidgetBase { @key id: string; diff --git a/packages/samples/specs/openapi-extensions/openapi-extensions.tsp b/packages/samples/specs/openapi-extensions/openapi-extensions.tsp index 0cde37d762c..2e466d3c49c 100644 --- a/packages/samples/specs/openapi-extensions/openapi-extensions.tsp +++ b/packages/samples/specs/openapi-extensions/openapi-extensions.tsp @@ -1,7 +1,7 @@ import "@typespec/rest"; import "@typespec/openapi"; -using OpenAPI; +using TypeSpec.OpenAPI; model MyConfig { name: "Foo"; diff --git a/packages/samples/specs/testserver/body-boolean/body-boolean.tsp b/packages/samples/specs/testserver/body-boolean/body-boolean.tsp index 8646759410b..5a5f809b580 100644 --- a/packages/samples/specs/testserver/body-boolean/body-boolean.tsp +++ b/packages/samples/specs/testserver/body-boolean/body-boolean.tsp @@ -2,7 +2,7 @@ import "@typespec/rest"; import "@typespec/openapi"; using TypeSpec.Http; -using OpenAPI; +using TypeSpec.OpenAPI; @service({ title: "sample", diff --git a/packages/samples/specs/testserver/media-types/media-types.tsp b/packages/samples/specs/testserver/media-types/media-types.tsp index c3fa1c72357..40b9745c950 100644 --- a/packages/samples/specs/testserver/media-types/media-types.tsp +++ b/packages/samples/specs/testserver/media-types/media-types.tsp @@ -2,7 +2,7 @@ import "@typespec/rest"; import "@typespec/openapi"; using TypeSpec.Http; -using OpenAPI; +using TypeSpec.OpenAPI; @service({ title: "sample",