From 6c5de0a00b70591be03ef7d8453ce9c90fcee8cc Mon Sep 17 00:00:00 2001 From: Romain Lenzotti Date: Mon, 14 Mar 2022 18:16:20 +0100 Subject: [PATCH] fix(openspec): remove depreciation annotation --- .../specs/openspec/src/openspec2/OS2Header.ts | 3 -- .../openspec/src/openspec2/OS2Operation.ts | 3 -- .../openspec/src/openspec2/OS2Parameter.ts | 43 ------------------- .../specs/openspec/src/openspec2/OS2Paths.ts | 3 -- .../openspec/src/openspec2/OS2Response.ts | 3 -- .../specs/openspec/src/openspec2/OS2Schema.ts | 12 ++---- .../openspec/src/openspec2/OS2Security.ts | 27 ------------ .../specs/schema/src/utils/generateSpec.ts | 6 +-- 8 files changed, 6 insertions(+), 94 deletions(-) diff --git a/packages/specs/openspec/src/openspec2/OS2Header.ts b/packages/specs/openspec/src/openspec2/OS2Header.ts index 3b9268884da..61642d19672 100644 --- a/packages/specs/openspec/src/openspec2/OS2Header.ts +++ b/packages/specs/openspec/src/openspec2/OS2Header.ts @@ -1,8 +1,5 @@ import {OS2BaseSchema} from "./OS2Schema"; -/** - * @deprecated - */ export interface OS2Header extends OS2BaseSchema { /** * The type of the object. The value MUST be one of `string`, `number`, `integer`, `boolean`, or `array`. diff --git a/packages/specs/openspec/src/openspec2/OS2Operation.ts b/packages/specs/openspec/src/openspec2/OS2Operation.ts index 8a7b7552226..2ad9a1a9d18 100644 --- a/packages/specs/openspec/src/openspec2/OS2Operation.ts +++ b/packages/specs/openspec/src/openspec2/OS2Operation.ts @@ -5,9 +5,6 @@ import {OpenSpecSecurity} from "../common/OpenSpecSecurity"; import {OS2Parameter} from "./OS2Parameter"; import {OS2Response} from "./OS2Response"; -/** - * @deprecated - */ export interface OS2Operation { /** * A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. diff --git a/packages/specs/openspec/src/openspec2/OS2Parameter.ts b/packages/specs/openspec/src/openspec2/OS2Parameter.ts index 496da496941..fd80c30ac4c 100644 --- a/packages/specs/openspec/src/openspec2/OS2Parameter.ts +++ b/packages/specs/openspec/src/openspec2/OS2Parameter.ts @@ -1,9 +1,6 @@ import {OpenSpecTypes} from "../common/OpenSpecTypes"; import {OS2BaseSchema, OS2Schema} from "./OS2Schema"; -/** - * @deprecated - */ export type OS2BaseParameter = { name: string; in: "body" | "query" | "path" | "header" | "formData"; @@ -11,62 +8,34 @@ export type OS2BaseParameter = { description?: string; }; -/** - * @deprecated - */ export type OS2BodyParameter = OS2BaseParameter & { in: "body"; schema?: OS2Schema; }; -/** - * @deprecated - */ export type OS2GenericFormat = { type?: OpenSpecTypes; format?: string; }; -/** - * @deprecated - */ export type OS2IntegerFormat = { type: "integer"; format?: "int32" | "int64"; }; -/** - * @deprecated - */ export type OS2NumberFormat = { type: "number"; format?: "float" | "double"; }; -/** - * @deprecated - */ export type OS2StringFormat = { type: "string"; format?: "" | "byte" | "binary" | "date" | "date-time" | "password"; }; -/** - * @deprecated - */ export type OS2SchemaFormatConstraints = OS2GenericFormat | OS2IntegerFormat | OS2NumberFormat | OS2StringFormat; -/** - * @deprecated - */ export type OS2BaseFormatContrainedParameter = OS2BaseParameter & OS2SchemaFormatConstraints; -/** - * @deprecated - */ export type ParameterCollectionFormat = "csv" | "ssv" | "tsv" | "pipes" | "multi"; - -/** - * @deprecated - */ export type OS2QueryParameter = OS2BaseFormatContrainedParameter & OS2BaseSchema & { in: "query"; @@ -74,26 +43,17 @@ export type OS2QueryParameter = OS2BaseFormatContrainedParameter & collectionFormat?: ParameterCollectionFormat; }; -/** - * @deprecated - */ export type OS2PathParameter = OS2BaseFormatContrainedParameter & OS2BaseSchema & { in: "path"; required: true; }; -/** - * @deprecated - */ export type OS2HeaderParameter = OS2BaseFormatContrainedParameter & OS2BaseSchema & { in: "header"; }; -/** - * @deprecated - */ export type OS2FormDataParameter = OS2BaseFormatContrainedParameter & OS2BaseSchema & { in: "formData"; @@ -102,7 +62,4 @@ export type OS2FormDataParameter = OS2BaseFormatContrainedParameter & collectionFormat?: ParameterCollectionFormat; }; -/** - * @deprecated - */ export type OS2Parameter = OS2BodyParameter | OS2FormDataParameter | OS2QueryParameter | OS2PathParameter | OS2HeaderParameter; diff --git a/packages/specs/openspec/src/openspec2/OS2Paths.ts b/packages/specs/openspec/src/openspec2/OS2Paths.ts index 2847c6f19d2..d5ab807ddab 100644 --- a/packages/specs/openspec/src/openspec2/OS2Paths.ts +++ b/packages/specs/openspec/src/openspec2/OS2Paths.ts @@ -3,9 +3,6 @@ import {OpenSpecRef} from "../common/OpenSpecRef"; import {OS2Operation} from "./OS2Operation"; import {OS2Parameter} from "./OS2Parameter"; -/** - * @deprecated - */ export interface OS2Paths extends OpenSpecPath { parameters?: (OS2Parameter | OpenSpecRef)[]; } diff --git a/packages/specs/openspec/src/openspec2/OS2Response.ts b/packages/specs/openspec/src/openspec2/OS2Response.ts index 5edcac64f06..33b9764469a 100644 --- a/packages/specs/openspec/src/openspec2/OS2Response.ts +++ b/packages/specs/openspec/src/openspec2/OS2Response.ts @@ -2,9 +2,6 @@ import {OpenSpecHash} from "../common/OpenSpecHash"; import {OS2Header} from "./OS2Header"; import {OS2Schema} from "./OS2Schema"; -/** - * @deprecated - */ export interface OS2Response { /** * A short description of the response. GFM syntax can be used for rich text representation. diff --git a/packages/specs/openspec/src/openspec2/OS2Schema.ts b/packages/specs/openspec/src/openspec2/OS2Schema.ts index e68fef488bd..9a984f3dd66 100644 --- a/packages/specs/openspec/src/openspec2/OS2Schema.ts +++ b/packages/specs/openspec/src/openspec2/OS2Schema.ts @@ -2,9 +2,7 @@ import {OpenSpecExternalDocs} from "../common/OpenSpecExternalDocs"; import {OpenSpecBaseJsonSchema, OpenSpecJsonSchema} from "../common/OpenSpecJsonSchema"; import {OpenSpecRef} from "../common/OpenSpecRef"; import {OpenSpecXML} from "../common/OpenSpecXML"; -/** - * @deprecated - */ + export interface OS2XML { name?: string; namespace?: string; @@ -12,18 +10,14 @@ export interface OS2XML { attribute?: boolean; wrapped?: boolean; } -/** - * @deprecated - */ + export interface OS2BaseSchema extends OpenSpecBaseJsonSchema { /** * Required if type is "array". Describes the type of items in the array. */ items?: OS2Schema | OpenSpecRef; } -/** - * @deprecated - */ + export interface OS2Schema extends OpenSpecJsonSchema { /** * Adds support for polymorphism. diff --git a/packages/specs/openspec/src/openspec2/OS2Security.ts b/packages/specs/openspec/src/openspec2/OS2Security.ts index e77413f8add..a51f33575d8 100644 --- a/packages/specs/openspec/src/openspec2/OS2Security.ts +++ b/packages/specs/openspec/src/openspec2/OS2Security.ts @@ -1,8 +1,5 @@ import {OpenSpecHash} from "../common/OpenSpecHash"; -/** - * @deprecated - */ export interface OS2SecurityBase { /** * The type of the security scheme @@ -14,25 +11,16 @@ export interface OS2SecurityBase { description?: string; } -/** - * @deprecated - */ export interface OS2SecurityBasic extends OS2SecurityBase { type: "basic"; } -/** - * @deprecated - */ export interface OS2SecurityApiKey extends OS2SecurityBase { type: "apiKey"; name: string; in: "query" | "header"; } -/** - * @deprecated - */ export interface OS2SecurityOAuth extends OS2SecurityBase { type: "oauth2"; flow: "accessCode" | "application" | "implicit" | "password"; @@ -42,36 +30,24 @@ export interface OS2SecurityOAuth extends OS2SecurityBase { scopes: OpenSpecHash; } -/** - * @deprecated - */ export interface OS2FlowImplicit extends OS2SecurityOAuth { type: "oauth2"; flow: "implicit"; authorizationUrl: string; } -/** - * @deprecated - */ export interface OS2FlowPassword extends OS2SecurityOAuth { type: "oauth2"; flow: "password"; tokenUrl: string; } -/** - * @deprecated - */ export interface OS2FlowApplication extends OS2SecurityOAuth { type: "oauth2"; flow: "application"; tokenUrl: string; } -/** - * @deprecated - */ export interface OS2FlowAccessCode extends OS2SecurityOAuth { type: "oauth2"; flow: "accessCode"; @@ -79,7 +55,4 @@ export interface OS2FlowAccessCode extends OS2SecurityOAuth { authorizationUrl: string; } -/** - * @deprecated - */ export type OS2Security = OS2SecurityBasic | OS2FlowAccessCode | OS2FlowApplication | OS2FlowImplicit | OS2FlowPassword | OS2SecurityApiKey; diff --git a/packages/specs/schema/src/utils/generateSpec.ts b/packages/specs/schema/src/utils/generateSpec.ts index e7915b013ea..b653ded386a 100644 --- a/packages/specs/schema/src/utils/generateSpec.ts +++ b/packages/specs/schema/src/utils/generateSpec.ts @@ -5,8 +5,6 @@ import {mapOpenSpec} from "./mapOpenSpec"; import {getSpec, JsonTokenOptions, SpecSerializerOptions} from "./getSpec"; import {getSpecTypeFromSpec} from "./getSpecType"; import {mergeSpec} from "./mergeSpec"; -// @ts-ignore -import Converter from "api-spec-converter"; import {SpecTypes} from "../domain/SpecTypes"; export interface GenerateSpecOptions extends Omit { @@ -50,7 +48,9 @@ export async function generateSpec({tokens, ...options}: GenerateSpecOptions): P let controllersSpec = getSpec(tokens, options); if (specType === SpecTypes.SWAGGER) { - const {spec} = await Converter.convert({ + // @ts-ignore + const {convert} = await import("api-spec-converter"); + const {spec} = await convert({ from: "openapi_3", to: "swagger_2", source: {