From 7bb685af3223f65e44bd2156481d866f29b13cae Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 14:56:09 -0800 Subject: [PATCH] Deprecate `@service` version and allow `@OpenAPI.info` to take all properties allowed by openapi (#2902) fix [#2821](https://github.com/microsoft/typespec/issues/2821) ## Deprecate `@service({version` Using this property will emit a deprecation warning ## Cover everything with `@OpenAPI.info` Makes sure all the properties allowed on the `info` object of openapi specification can also be provided in `@info`. The properties will either override other ways of specifying those previously or be the only way. - `@info({description` would override `@doc` on service namespace - `@info({summary` would override `@summary` on service namespace - `@info({title` would override `@service({title}` on service namespace --- ...ecate-service-version-2024-1-9-17-27-47.md | 8 ++++ ...ecate-service-version-2024-1-9-17-40-35.md | 9 +++++ ...ecate-service-version-2024-1-9-19-36-46.md | 6 +++ packages/compiler/src/lib/service.ts | 14 +++++-- .../compiler/test/decorators/service.test.ts | 10 ++++- packages/openapi/lib/decorators.tsp | 9 +++++ packages/openapi/src/decorators.ts | 29 +++++++++++++- packages/openapi/src/types.ts | 12 ++++++ packages/openapi/test/decorators.test.ts | 40 ++++++++++++++++++- packages/openapi3/src/openapi.ts | 10 ++--- packages/openapi3/test/info.test.ts | 7 +++- packages/openapi3/test/output-file.test.ts | 4 +- .../specs/multiple-types-union/main.tsp | 1 - packages/samples/specs/petstore/petstore.tsp | 1 - .../samples/specs/rest/petstore/petstore.tsp | 1 - .../openapi.TypeSpec.InterfaceAuth.yaml | 2 +- .../openapi.TypeSpec.OperationAuth.yaml | 2 +- .../openapi.TypeSpec.ServiceAuth.yaml | 2 +- .../binary/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../encoding/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../multipart/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../nested/@typespec/openapi3/openapi.yaml | 2 +- .../nullable/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../optional/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../petstore/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../petstore/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../simple/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../tags/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../body-time/@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- .../@typespec/openapi3/openapi.yaml | 2 +- packages/versioning/src/validate.ts | 2 + .../test/incompatible-versioning.test.ts | 1 + .../homepage/hero/http/out/openapi.yaml | 2 +- .../openapi3/hero/out/openapi.yaml | 2 +- 51 files changed, 179 insertions(+), 53 deletions(-) create mode 100644 .chronus/changes/deprecate-service-version-2024-1-9-17-27-47.md create mode 100644 .chronus/changes/deprecate-service-version-2024-1-9-17-40-35.md create mode 100644 .chronus/changes/deprecate-service-version-2024-1-9-19-36-46.md diff --git a/.chronus/changes/deprecate-service-version-2024-1-9-17-27-47.md b/.chronus/changes/deprecate-service-version-2024-1-9-17-27-47.md new file mode 100644 index 0000000000..93ce446ebf --- /dev/null +++ b/.chronus/changes/deprecate-service-version-2024-1-9-17-27-47.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: deprecation +packages: + - "@typespec/compiler" +--- + +Deprecate `@service` version property. If wanting to describe a service versioning you can use the `@typespec/versioning` library. If wanting to describe the project version you can use the package.json version. For OpenAPI generation. the `@OpenAPI.info` nows decorator allows providing the document version. diff --git a/.chronus/changes/deprecate-service-version-2024-1-9-17-40-35.md b/.chronus/changes/deprecate-service-version-2024-1-9-17-40-35.md new file mode 100644 index 0000000000..fb8907ceb4 --- /dev/null +++ b/.chronus/changes/deprecate-service-version-2024-1-9-17-40-35.md @@ -0,0 +1,9 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: feature +packages: + - "@typespec/openapi" + - "@typespec/openapi3" +--- + +Add support for all properties of openapi `info` object on the `@info` decorator diff --git a/.chronus/changes/deprecate-service-version-2024-1-9-19-36-46.md b/.chronus/changes/deprecate-service-version-2024-1-9-19-36-46.md new file mode 100644 index 0000000000..cfaa395db8 --- /dev/null +++ b/.chronus/changes/deprecate-service-version-2024-1-9-19-36-46.md @@ -0,0 +1,6 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: internal +packages: + - "@typespec/versioning" +--- diff --git a/packages/compiler/src/lib/service.ts b/packages/compiler/src/lib/service.ts index 658ca36bd9..408efb79d6 100644 --- a/packages/compiler/src/lib/service.ts +++ b/packages/compiler/src/lib/service.ts @@ -1,11 +1,12 @@ import { validateDecoratorUniqueOnNode } from "../core/decorator-utils.js"; -import { getTypeName } from "../core/index.js"; +import { getTypeName, reportDeprecated } from "../core/index.js"; import { reportDiagnostic } from "../core/messages.js"; import { Program } from "../core/program.js"; import { DecoratorContext, Model, Namespace } from "../core/types.js"; export interface ServiceDetails { title?: string; + /** @deprecated Service version is deprecated. If wanting to describe a service versioning you can use the `@typespec/versioning` library. If wanting to describe the project version you can use the package.json version */ version?: string; } @@ -68,7 +69,7 @@ export function $service(context: DecoratorContext, target: Namespace, options?: const serviceDetails: ServiceDetails = {}; const title = options?.properties.get("title")?.type; - const version = options?.properties.get("version")?.type; + const versionProp = options?.properties.get("version"); if (title) { if (title.kind === "String") { serviceDetails.title = title.value; @@ -80,8 +81,15 @@ export function $service(context: DecoratorContext, target: Namespace, options?: }); } } - if (version) { + if (versionProp) { + const version = versionProp.type; + reportDeprecated( + context.program, + "version: property is deprecated in @service. If wanting to describe a service versioning you can use the `@typespec/versioning` library. If wanting to describe the project version you can use the package.json version.", + versionProp + ); if (version.kind === "String") { + // eslint-disable-next-line deprecation/deprecation serviceDetails.version = version.value; } else { reportDiagnostic(context.program, { diff --git a/packages/compiler/test/decorators/service.test.ts b/packages/compiler/test/decorators/service.test.ts index 44bd9de97d..5b62eb4b92 100644 --- a/packages/compiler/test/decorators/service.test.ts +++ b/packages/compiler/test/decorators/service.test.ts @@ -71,7 +71,10 @@ describe("compiler: service", () => { it("customize service version", async () => { const { S } = await runner.compile(` - @test @service({version: "1.2.3"}) namespace S {} + @test @service({ + #suppress "deprecated" "test" + version: "1.2.3" + }) namespace S {} `); @@ -91,7 +94,10 @@ describe("compiler: service", () => { it("emit diagnostic if service version is not a string", async () => { const diagnostics = await runner.diagnose(` - @test @service({version: 123}) namespace S {} + @test @service({ + #suppress "deprecated" "test" + version: 123 + }) namespace S {} `); expectDiagnostics(diagnostics, { diff --git a/packages/openapi/lib/decorators.tsp b/packages/openapi/lib/decorators.tsp index 99675e3366..53bfec4a60 100644 --- a/packages/openapi/lib/decorators.tsp +++ b/packages/openapi/lib/decorators.tsp @@ -63,6 +63,15 @@ extern dec externalDocs(target: unknown, url: valueof string, description?: valu /** Additional information for the OpenAPI document. */ model AdditionalInfo { + /** The title of the API. Overrides the `@service` title. */ + title?: string; + + /** A short summary of the API. Overrides the `@summary` provided on the service namespace. */ + summary?: string; + + /** The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API implementation version). */ + version?: string; + /** A URL to the Terms of Service for the API. MUST be in the format of a URL. */ termsOfService?: url; diff --git a/packages/openapi/src/decorators.ts b/packages/openapi/src/decorators.ts index f86ee54f6c..58869af2c2 100644 --- a/packages/openapi/src/decorators.ts +++ b/packages/openapi/src/decorators.ts @@ -1,5 +1,8 @@ import { DecoratorContext, + getDoc, + getService, + getSummary, Model, Namespace, Operation, @@ -128,11 +131,35 @@ export function getExternalDocs(program: Program, entity: Type): ExternalDocs | const infoKey = createStateSymbol("info"); export function $info(context: DecoratorContext, entity: Namespace, model: Model) { - const [data, diagnostics] = typespecTypeToJson(model, context.getArgumentTarget(0)!); + const [data, diagnostics] = typespecTypeToJson( + model, + context.getArgumentTarget(0)! + ); context.program.reportDiagnostics(diagnostics); + if (data === undefined) { + return; + } context.program.stateMap(infoKey).set(entity, data); } export function getInfo(program: Program, entity: Namespace): AdditionalInfo | undefined { return program.stateMap(infoKey).get(entity); } + +/** Resolve the info entry by merging data specified with `@service`, `@summary` and `@info`. */ +export function resolveInfo(program: Program, entity: Namespace): AdditionalInfo | undefined { + const info = getInfo(program, entity); + const service = getService(program, entity); + return omitUndefined({ + ...info, + title: info?.title ?? service?.title, + // eslint-disable-next-line deprecation/deprecation + version: info?.version ?? service?.version, + summary: info?.summary ?? getSummary(program, entity), + description: info?.description ?? getDoc(program, entity), + }); +} + +function omitUndefined>(data: T): T { + return Object.fromEntries(Object.entries(data).filter(([k, v]) => v !== undefined)) as any; +} diff --git a/packages/openapi/src/types.ts b/packages/openapi/src/types.ts index d683789f1b..6445a4456c 100644 --- a/packages/openapi/src/types.ts +++ b/packages/openapi/src/types.ts @@ -4,6 +4,18 @@ export type ExtensionKey = `x-${string}`; * OpenAPI additional information */ export interface AdditionalInfo { + /** The title of the API. Overrides the `@service` title. */ + title?: string; + + /** A short summary of the API. Overrides the `@summary` provided on the service namespace. */ + summary?: string; + + /** A description of the API. Overrides the `@doc` provided on the service namespace. */ + description?: string; + + /** The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API implementation version). */ + version?: string; + /** A URL to the Terms of Service for the API. MUST be in the format of a URL. */ termsOfService?: string; diff --git a/packages/openapi/test/decorators.test.ts b/packages/openapi/test/decorators.test.ts index ee2f7934a0..fb6ae8a92e 100644 --- a/packages/openapi/test/decorators.test.ts +++ b/packages/openapi/test/decorators.test.ts @@ -2,7 +2,7 @@ import { Namespace } from "@typespec/compiler"; import { BasicTestRunner, expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual } from "assert"; import { beforeEach, describe, it } from "vitest"; -import { getExtensions, getExternalDocs, getInfo } from "../src/decorators.js"; +import { getExtensions, getExternalDocs, getInfo, resolveInfo } from "../src/decorators.js"; import { createOpenAPITestRunner } from "./test-host.js"; describe("openapi: decorators", () => { @@ -178,6 +178,9 @@ describe("openapi: decorators", () => { it("set all properties", async () => { const { Service } = (await runner.compile(` @info({ + title: "My API", + version: "1.0.0", + summary: "My API summary", termsOfService: "http://example.com/terms/", contact: { name: "API Support", @@ -193,6 +196,9 @@ describe("openapi: decorators", () => { `)) as { Service: Namespace }; deepStrictEqual(getInfo(runner.program, Service), { + title: "My API", + version: "1.0.0", + summary: "My API summary", termsOfService: "http://example.com/terms/", contact: { name: "API Support", @@ -205,5 +211,37 @@ describe("openapi: decorators", () => { }, }); }); + + it("resolveInfo() merge with data from @service and @summary", async () => { + const { Service } = (await runner.compile(` + @service({ + title: "Service API", + + #suppress "deprecated" "Test" + version: "2.0.0" + }) + @summary("My summary") + @info({ + version: "1.0.0", + termsOfService: "http://example.com/terms/", + }) + @test namespace Service {} + `)) as { Service: Namespace }; + + deepStrictEqual(resolveInfo(runner.program, Service), { + title: "Service API", + version: "1.0.0", + summary: "My summary", + termsOfService: "http://example.com/terms/", + }); + }); + + it("resolveInfo() returns empty object if nothing is provided", async () => { + const { Service } = (await runner.compile(` + @test namespace Service {} + `)) as { Service: Namespace }; + + deepStrictEqual(resolveInfo(runner.program, Service), {}); + }); }); }); diff --git a/packages/openapi3/src/openapi.ts b/packages/openapi3/src/openapi.ts index 2456923e04..8639706725 100644 --- a/packages/openapi3/src/openapi.ts +++ b/packages/openapi3/src/openapi.ts @@ -81,11 +81,11 @@ import { import { getExtensions, getExternalDocs, - getInfo, getOpenAPITypeName, getParameterKey, isDefaultResponse, isReadonlyProperty, + resolveInfo, resolveOperationId, shouldInline, } from "@typespec/openapi"; @@ -304,13 +304,13 @@ function createOAPIEmitter( const securitySchemes = getOpenAPISecuritySchemes(allHttpAuthentications); const security = getOpenAPISecurity(defaultAuth); + const info = resolveInfo(program, service.type); root = { openapi: "3.0.0", info: { - title: service.title ?? "(title)", - version: version ?? service.version ?? "0000-00-00", - description: getDoc(program, service.type), - ...getInfo(program, service.type), + title: "(title)", + ...info, + version: version ?? info?.version ?? "0.0.0", }, externalDocs: getExternalDocs(program, service.type), tags: [], diff --git a/packages/openapi3/test/info.test.ts b/packages/openapi3/test/info.test.ts index 273d0b3d6b..f740ad5b99 100644 --- a/packages/openapi3/test/info.test.ts +++ b/packages/openapi3/test/info.test.ts @@ -18,7 +18,10 @@ describe("openapi3: info", () => { it("set the service version with @service", async () => { const res = await openApiFor( ` - @service({version: "1.2.3-test"}) + @service({ + #suppress "deprecated" "For test" + version: "1.2.3-test" + }) namespace Foo { op test(): string; } @@ -78,7 +81,7 @@ describe("openapi3: info", () => { ); deepStrictEqual(res.info, { title: "(title)", - version: "0000-00-00", + version: "0.0.0", termsOfService: "http://example.com/terms/", contact: { name: "API Support", diff --git a/packages/openapi3/test/output-file.test.ts b/packages/openapi3/test/output-file.test.ts index 564a5b0e42..cb5f1c1ad1 100644 --- a/packages/openapi3/test/output-file.test.ts +++ b/packages/openapi3/test/output-file.test.ts @@ -15,7 +15,7 @@ describe("openapi3: output file", () => { ` "openapi": "3.0.0",`, ` "info": {`, ` "title": "(title)",`, - ` "version": "0000-00-00"`, + ` "version": "0.0.0"`, ` },`, ` "tags": [],`, ` "paths": {},`, @@ -28,7 +28,7 @@ describe("openapi3: output file", () => { `openapi: 3.0.0`, `info:`, ` title: (title)`, - ` version: 0000-00-00`, + ` version: 0.0.0`, `tags: []`, `paths: {}`, `components: {}`, diff --git a/packages/samples/specs/multiple-types-union/main.tsp b/packages/samples/specs/multiple-types-union/main.tsp index d7b9cf8592..7c5b72f86f 100644 --- a/packages/samples/specs/multiple-types-union/main.tsp +++ b/packages/samples/specs/multiple-types-union/main.tsp @@ -3,7 +3,6 @@ import "@typespec/openapi"; @service({ title: "Pet Store Service", - version: "2021-03-25", }) namespace PetStore; using TypeSpec.Http; diff --git a/packages/samples/specs/petstore/petstore.tsp b/packages/samples/specs/petstore/petstore.tsp index 0ece491f85..3db18df697 100644 --- a/packages/samples/specs/petstore/petstore.tsp +++ b/packages/samples/specs/petstore/petstore.tsp @@ -6,7 +6,6 @@ using TypeSpec.Http; @service({ title: "Pet Store Service", - version: "2021-03-25", }) @doc("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") namespace PetStore; diff --git a/packages/samples/specs/rest/petstore/petstore.tsp b/packages/samples/specs/rest/petstore/petstore.tsp index 5ccffa4f52..8754f966fd 100644 --- a/packages/samples/specs/rest/petstore/petstore.tsp +++ b/packages/samples/specs/rest/petstore/petstore.tsp @@ -3,7 +3,6 @@ import "@typespec/openapi"; @service({ title: "Pet Store Service", - version: "2021-03-25", }) namespace PetStore; diff --git a/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.InterfaceAuth.yaml b/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.InterfaceAuth.yaml index dc88e1db48..742a2437d4 100644 --- a/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.InterfaceAuth.yaml +++ b/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.InterfaceAuth.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Authenticated service with interface override - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /one: diff --git a/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.OperationAuth.yaml b/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.OperationAuth.yaml index dc13d3fa45..94576030ce 100644 --- a/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.OperationAuth.yaml +++ b/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.OperationAuth.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Authenticated service with method override - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /one: diff --git a/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.ServiceAuth.yaml b/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.ServiceAuth.yaml index 57801aa919..ea33f6db17 100644 --- a/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.ServiceAuth.yaml +++ b/packages/samples/test/output/authentication/@typespec/openapi3/openapi.TypeSpec.ServiceAuth.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Authenticated service - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/binary/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/binary/@typespec/openapi3/openapi.yaml index ac927c67f5..9eeafcf998 100644 --- a/packages/samples/test/output/binary/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/binary/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Binary sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /test/base64: diff --git a/packages/samples/test/output/documentation/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/documentation/@typespec/openapi3/openapi.yaml index 1b62c51d42..36f30e4eca 100644 --- a/packages/samples/test/output/documentation/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/documentation/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Documentation sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /foo/DefaultDescriptions: diff --git a/packages/samples/test/output/encoded-names/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/encoded-names/@typespec/openapi3/openapi.yaml index 6666176aac..fd6154ae8b 100644 --- a/packages/samples/test/output/encoded-names/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/encoded-names/@typespec/openapi3/openapi.yaml @@ -1,10 +1,10 @@ openapi: 3.0.0 info: title: Sample showcasing encoded names - version: 0000-00-00 description: |- This example showcase providing a different name over the wire. In this example the `WithEncodedNames` model has a `notBefore` property that should get serialized as `nbf` when serialized as json. + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/encoding/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/encoding/@typespec/openapi3/openapi.yaml index a81df683ad..09f5539505 100644 --- a/packages/samples/test/output/encoding/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/encoding/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/grpc-kiosk-example/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/grpc-kiosk-example/@typespec/openapi3/openapi.yaml index 17854c8214..3f73bf56e7 100644 --- a/packages/samples/test/output/grpc-kiosk-example/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/grpc-kiosk-example/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Grpc Kiosk sample - version: 0000-00-00 + version: 0.0.0 tags: - name: Display paths: diff --git a/packages/samples/test/output/grpc-library-example/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/grpc-library-example/@typespec/openapi3/openapi.yaml index b9b11f8d9c..496cb406fc 100644 --- a/packages/samples/test/output/grpc-library-example/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/grpc-library-example/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Grpc Library sample - version: 0000-00-00 + version: 0.0.0 tags: - name: LibraryService paths: diff --git a/packages/samples/test/output/multipart/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/multipart/@typespec/openapi3/openapi.yaml index c32a5d6f1b..08b373c5f8 100644 --- a/packages/samples/test/output/multipart/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/multipart/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/multiple-types-union/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/multiple-types-union/@typespec/openapi3/openapi.yaml index 4644ed20b7..e1accc666c 100644 --- a/packages/samples/test/output/multiple-types-union/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/multiple-types-union/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Pet Store Service - version: 2021-03-25 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/nested/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/nested/@typespec/openapi3/openapi.yaml index 7b5293ad6e..9263f208e4 100644 --- a/packages/samples/test/output/nested/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/nested/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Nested sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/nullable/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/nullable/@typespec/openapi3/openapi.yaml index 090b3b2961..534cf40e93 100644 --- a/packages/samples/test/output/nullable/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/nullable/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Nullable sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /test: diff --git a/packages/samples/test/output/openapi-extensions/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/openapi-extensions/@typespec/openapi3/openapi.yaml index fdf859a3ff..ed914e24fa 100644 --- a/packages/samples/test/output/openapi-extensions/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/openapi-extensions/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/optional/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/optional/@typespec/openapi3/openapi.yaml index 8fa818f0e0..f6ea73e68d 100644 --- a/packages/samples/test/output/optional/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/optional/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Optional sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /test: diff --git a/packages/samples/test/output/param-decorators/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/param-decorators/@typespec/openapi3/openapi.yaml index b55f996b7d..2a8f87b071 100644 --- a/packages/samples/test/output/param-decorators/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/param-decorators/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Parameter Decorators - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /thing/{name}: diff --git a/packages/samples/test/output/petstore/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/petstore/@typespec/openapi3/openapi.yaml index 80d4504ea3..0e25cb32ba 100644 --- a/packages/samples/test/output/petstore/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/petstore/@typespec/openapi3/openapi.yaml @@ -1,8 +1,8 @@ openapi: 3.0.0 info: title: Pet Store Service - version: 2021-03-25 description: 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.' + version: 0.0.0 tags: [] paths: /pets: diff --git a/packages/samples/test/output/polymorphism/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/polymorphism/@typespec/openapi3/openapi.yaml index 789dea0090..6e9172b3a2 100644 --- a/packages/samples/test/output/polymorphism/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/polymorphism/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Polymorphism sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /Pets: diff --git a/packages/samples/test/output/rest/petstore/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/rest/petstore/@typespec/openapi3/openapi.yaml index 9d8e111dea..3222939783 100644 --- a/packages/samples/test/output/rest/petstore/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/rest/petstore/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Pet Store Service - version: 2021-03-25 + version: 0.0.0 tags: [] paths: /checkups: diff --git a/packages/samples/test/output/signatures/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/signatures/@typespec/openapi3/openapi.yaml index 33ecc196ca..ff3a80a966 100644 --- a/packages/samples/test/output/signatures/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/signatures/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /accountProfiles: diff --git a/packages/samples/test/output/simple/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/simple/@typespec/openapi3/openapi.yaml index d94e658bef..61dbf7dc4a 100644 --- a/packages/samples/test/output/simple/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/simple/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /alpha/{id}: diff --git a/packages/samples/test/output/status-code-ranges/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/status-code-ranges/@typespec/openapi3/openapi.yaml index 1b0a8937f8..a590b376f3 100644 --- a/packages/samples/test/output/status-code-ranges/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/status-code-ranges/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/string-template/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/string-template/@typespec/openapi3/openapi.yaml index 2291a05bc9..28951f5f7a 100644 --- a/packages/samples/test/output/string-template/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/string-template/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: {} components: diff --git a/packages/samples/test/output/tags/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/tags/@typespec/openapi3/openapi.yaml index 64e19ac8d8..2787520ac3 100644 --- a/packages/samples/test/output/tags/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/tags/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Tags sample - version: 0000-00-00 + version: 0.0.0 tags: - name: foo - name: tag1 diff --git a/packages/samples/test/output/testserver/body-boolean/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/testserver/body-boolean/@typespec/openapi3/openapi.yaml index 790a36e7e9..14395fb8df 100644 --- a/packages/samples/test/output/testserver/body-boolean/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/testserver/body-boolean/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /bool/false: diff --git a/packages/samples/test/output/testserver/body-complex/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/testserver/body-complex/@typespec/openapi3/openapi.yaml index 15deb9e99e..86af522a24 100644 --- a/packages/samples/test/output/testserver/body-complex/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/testserver/body-complex/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /complex/array/valid: diff --git a/packages/samples/test/output/testserver/body-string/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/testserver/body-string/@typespec/openapi3/openapi.yaml index 8c2283f332..662f3e3b24 100644 --- a/packages/samples/test/output/testserver/body-string/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/testserver/body-string/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: sample - version: 0000-00-00 + version: 0.0.0 tags: - name: String Operations paths: diff --git a/packages/samples/test/output/testserver/body-time/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/testserver/body-time/@typespec/openapi3/openapi.yaml index 4dd5446e0e..dbd4482a24 100644 --- a/packages/samples/test/output/testserver/body-time/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/testserver/body-time/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /time: diff --git a/packages/samples/test/output/testserver/media-types/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/testserver/media-types/@typespec/openapi3/openapi.yaml index ec4bc34a9b..5910f93a72 100644 --- a/packages/samples/test/output/testserver/media-types/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/testserver/media-types/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /mediatypes/analyze: diff --git a/packages/samples/test/output/testserver/multiple-inheritance/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/testserver/multiple-inheritance/@typespec/openapi3/openapi.yaml index 5ab2f475ec..7d7bf46ef3 100644 --- a/packages/samples/test/output/testserver/multiple-inheritance/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/testserver/multiple-inheritance/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /multipleInheritance/cat: diff --git a/packages/samples/test/output/use-versioned-lib/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/use-versioned-lib/@typespec/openapi3/openapi.yaml index 0882394541..46fa8dbad8 100644 --- a/packages/samples/test/output/use-versioned-lib/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/use-versioned-lib/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Pet Store Service - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /: diff --git a/packages/samples/test/output/visibility/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/visibility/@typespec/openapi3/openapi.yaml index affea0069b..4da4186a02 100644 --- a/packages/samples/test/output/visibility/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/visibility/@typespec/openapi3/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Visibility sample - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /hello: diff --git a/packages/versioning/src/validate.ts b/packages/versioning/src/validate.ts index e81cf82c95..d3dd6f4e59 100644 --- a/packages/versioning/src/validate.ts +++ b/packages/versioning/src/validate.ts @@ -107,11 +107,13 @@ export function $onValidate(program: Program) { const [_, versionMap] = getVersions(program, namespace); validateVersionEnumValuesUnique(program, namespace); const serviceProps = getService(program, namespace); + // eslint-disable-next-line deprecation/deprecation if (serviceProps?.version !== undefined && versionMap !== undefined) { reportDiagnostic(program, { code: "no-service-fixed-version", format: { name: getNamespaceFullName(namespace), + // eslint-disable-next-line deprecation/deprecation version: serviceProps.version, }, target: namespace, diff --git a/packages/versioning/test/incompatible-versioning.test.ts b/packages/versioning/test/incompatible-versioning.test.ts index 17e40f8fdd..b604285b49 100644 --- a/packages/versioning/test/incompatible-versioning.test.ts +++ b/packages/versioning/test/incompatible-versioning.test.ts @@ -30,6 +30,7 @@ describe("versioning: incompatible use of decorators", () => { @versioned(Versions) @service({ title: "Widget Service", + #suppress "deprecated" "For test" version: "v3" }) namespace DemoService; diff --git a/packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml b/packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml index 202d64b49c..e822094a7a 100644 --- a/packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml +++ b/packages/website/static/tsp-samples/homepage/hero/http/out/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /stores: diff --git a/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml b/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml index e55e6993c6..08a9e97a43 100644 --- a/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml +++ b/packages/website/static/tsp-samples/openapi3/hero/out/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: (title) - version: 0000-00-00 + version: 0.0.0 tags: [] paths: /pets: