UNPKG

@himenon/openapi-typescript-code-generator

Version:
574 lines (525 loc) 14.5 kB
import ts from 'typescript'; interface Params$Create$n { typeParameters: ts.TypeParameterDeclaration[] | undefined; parameters: ts.ParameterDeclaration[]; type?: ts.TypeNode; equalsGreaterThanToken?: ts.EqualsGreaterThanToken; body: ts.ConciseBody; } interface Factory$G { create: (params: Params$Create$n) => ts.ArrowFunction; } declare const operators: { readonly "+": ts.SyntaxKind.PlusToken; readonly "=": ts.SyntaxKind.EqualsToken; }; interface Params$i { left: ts.Expression; operator: keyof typeof operators; right: ts.Expression; } interface Factory$F { create: (params: Params$i) => ts.BinaryExpression; } interface Params$Create$m { statements: readonly ts.Statement[]; multiLine: boolean; } interface Factory$E { create: (params: Params$Create$m) => ts.Block; } interface Params$Create$l { expression: ts.Expression; typeArguments?: readonly ts.TypeNode[] | undefined; argumentsArray: readonly ts.Expression[]; } interface Factory$D { create: (params: Params$Create$l) => ts.CallExpression; } interface Params$Create$k { name: string; export?: true; members: readonly ts.ClassElement[]; typeParameterDeclaration: readonly ts.TypeParameterDeclaration[]; } interface Factory$C { create: (params: Params$Create$k) => ts.ClassDeclaration; } interface Params$Create$j { parameters?: ts.ParameterDeclaration[]; body?: ts.Block; } interface Factory$B { create: (params: Params$Create$j) => ts.ConstructorDeclaration; } interface Params$Create$i { expression: ts.Expression; index: number | string | ts.Expression; } interface Factory$A { create: (params: Params$Create$i) => ts.ElementAccessExpression; } interface Params$Create$h { expression: ts.Expression; } interface Factory$z { create: (params: Params$Create$h) => ts.ExpressionStatement; } interface Params$Create$g { typeParameters: readonly ts.TypeParameterDeclaration[] | undefined; parameters: readonly ts.ParameterDeclaration[]; type: ts.TypeNode; } interface Factory$y { create: (params: Params$Create$g) => ts.FunctionTypeNode; } interface Params$h { name: string; } interface Factory$x { create: (params: Params$h) => ts.Identifier; } interface Params$Create$f { name: string; type: ts.TypeNode; } interface Factory$w { create: (params: Params$Create$f) => ts.IndexSignatureDeclaration; } interface Params$Create$e { objectType: ts.TypeNode; indexType: ts.TypeNode; } interface Factory$v { create: (params: Params$Create$e) => ts.IndexedAccessTypeNode; } interface Params$Create$d { export?: true; deprecated?: boolean; name: string; members: readonly ts.TypeElement[]; typeParameters?: readonly ts.TypeParameterDeclaration[]; comment?: string; } interface Factory$u { create: (params: Params$Create$d) => ts.InterfaceDeclaration; } interface Params$g { typeNodes: ts.TypeNode[]; } interface Factory$t { create: (params: Params$g) => ts.IntersectionTypeNode; } interface Params$f { value: string | boolean | number; comment?: string; } interface Factory$s { create: (params: Params$f) => ts.LiteralTypeNode; } interface Params$Create$c { name: string; async?: boolean; private?: boolean; typeParameters?: readonly ts.TypeParameterDeclaration[]; parameters?: ts.ParameterDeclaration[]; type?: ts.TypeNode; body?: ts.Block; comment?: string; deprecated?: boolean; } interface Factory$r { create: (params: Params$Create$c) => ts.MethodDeclaration; } interface Params$FindStatement { node: ts.ModuleDeclaration; name: string; } interface Params$Create$b { export?: true; name: string; statements: ts.Statement[]; comment?: string; deprecated?: boolean; } interface Params$CreateMulti extends Omit<Params$Create$b, "name"> { names: string[]; } interface Params$Update { node: ts.ModuleDeclaration; statements: ts.Statement[]; } interface Factory$q { create: (params: Params$Create$b) => ts.ModuleDeclaration; findNamespace: (params: Params$FindStatement) => ts.Statement | undefined; createMultiple: (params: Params$CreateMulti) => ts.ModuleDeclaration; update: (params: Params$Update) => ts.ModuleDeclaration; addStatements: (params: Params$Update) => ts.ModuleDeclaration; } interface Params$e { text: string; rawText?: string; } interface Factory$p { create: (params: Params$e) => ts.NoSubstitutionTemplateLiteral; } interface Params$d { properties: ts.ObjectLiteralElementLike[]; multiLine?: boolean; } interface Factory$o { create: (params: Params$d) => ts.ObjectLiteralExpression; } interface Params$Create$a { name: string; optional?: true; modifiers?: "private" | "public"; type?: ts.TypeNode; } interface Factory$n { create: (params: Params$Create$a) => ts.ParameterDeclaration; } interface Params$Create$9 { expression: string | "this" | ts.Expression; name: string; } interface Factory$m { create: (params: Params$Create$9) => ts.PropertyAccessExpression; } interface Params$c { name: string; initializer: ts.Expression; comment?: string; deprecated?: boolean; } interface Factory$l { create: (params: Params$c) => ts.PropertyAssignment; } interface Params$b { modifiers: readonly ts.Modifier[] | undefined; name: string | ts.PropertyName; questionOrExclamationToken?: ts.QuestionToken | ts.ExclamationToken | undefined; type: ts.TypeNode | undefined; initializer?: ts.Expression | undefined; } interface Factory$k { create: (params: Params$b) => ts.PropertyDeclaration; } interface Params$a { name: string; readOnly: boolean; optional: boolean; type: ts.TypeNode; comment?: string; } interface Factory$j { create: (params: Params$a) => ts.PropertySignature; } interface Params$Create$8 { text: string; } interface Factory$i { create: (params: Params$Create$8) => ts.RegularExpressionLiteral; } interface Params$Create$7 { expression?: ts.Expression; } interface Factory$h { create: (params: Params$Create$7) => ts.ReturnStatement; } interface Params$Create$6 { name: string; } interface Factory$g { create: (params: Params$Create$6) => ts.ShorthandPropertyAssignment; } interface Params$9 { text: string; isSingleQuote?: boolean; } interface Factory$f { create: (params: Params$9) => ts.StringLiteral; } interface Params$8 { head: ts.TemplateHead; templateSpans: readonly ts.TemplateSpan[]; } interface Factory$e { create: (params: Params$8) => ts.TemplateExpression; } interface Params$7 { text: string; rawText?: string; } interface Factory$d { create: (params: Params$7) => ts.TemplateHead; } interface Params$6 { text: string; rawText?: string; } interface Factory$c { create: (params: Params$6) => ts.TemplateMiddle; } interface Params$5 { expression: ts.Expression; literal: ts.TemplateMiddle | ts.TemplateTail; } interface Factory$b { create: (params: Params$5) => ts.TemplateSpan; } interface Params$4 { text: string; rawText?: string; } interface Factory$a { create: (params: Params$4) => ts.TemplateTail; } interface Params$Create$5 { export?: true; name: string; type: ts.TypeNode; comment?: string; deprecated?: boolean; } interface Factory$9 { create: (params: Params$Create$5) => ts.TypeAliasDeclaration; } interface Params$Create$4 { members: readonly ts.TypeElement[] | undefined; } interface Factory$8 { create: (params: Params$Create$4) => ts.TypeLiteralNode; } interface StringParams { type: "string"; enum?: string[]; } interface IntegerParams { type: "integer"; enum?: number[]; } interface NumberParams { type: "number"; enum?: number[]; } interface BooleanParams { type: "boolean"; enum?: boolean[]; } interface ObjectParams { type: "object"; value: ts.TypeElement[]; } interface UndefinedParams { type: "undefined"; } interface ArrayParams { type: "array"; value: ts.TypeNode; } interface NullParams { type: "null"; } interface NeverParams { type: "never"; } interface AnyParams { type: "any"; } interface VoidParams { type: "void"; } type Params$Create$3 = StringParams | IntegerParams | NumberParams | BooleanParams | ObjectParams | ArrayParams | UndefinedParams | NullParams | VoidParams | NeverParams | AnyParams; interface Factory$7 { create: (params: Params$Create$3) => ts.TypeNode; } declare const syntaxKinds: { readonly keyof: ts.SyntaxKind.KeyOfKeyword; readonly unique: ts.SyntaxKind.UniqueKeyword; readonly readonly: ts.SyntaxKind.ReadonlyKeyword; }; interface Params$Create$2 { syntaxKind: keyof typeof syntaxKinds; type: ts.TypeNode; } interface Factory$6 { create: (params: Params$Create$2) => ts.TypeOperatorNode; } interface Params$Create$1 { name: string; constraint?: ts.TypeNode; defaultType?: ts.TypeNode; } interface Factory$5 { create: (params: Params$Create$1) => ts.TypeParameterDeclaration; } interface Params$Create { name: string; typeArguments?: readonly ts.TypeNode[]; } interface Factory$4 { create: (params: Params$Create) => ts.TypeReferenceNode; } interface Params$3 { typeNodes: ts.TypeNode[]; } interface Factory$3 { create: (params: Params$3) => ts.UnionTypeNode; } interface Params$2 { name: string | ts.BindingName; type?: ts.TypeNode; initializer?: ts.Expression; } interface Factory$2 { create: (params: Params$2) => ts.VariableDeclaration; } declare const flags: { readonly const: ts.NodeFlags.Const; }; interface Params$1 { declarations: readonly ts.VariableDeclaration[]; flag: keyof typeof flags; } interface Factory$1 { create: (params: Params$1) => ts.VariableDeclarationList; } interface Params { comment?: string; deprecated?: boolean; modifiers?: ts.Modifier[]; declarationList: ts.VariableDeclarationList | ts.VariableDeclaration[]; } interface Factory { create: (params: Params) => ts.VariableStatement; } interface Type { ArrowFunction: Factory$G; Block: Factory$E; ClassDeclaration: Factory$C; InterfaceDeclaration: Factory$u; ParameterDeclaration: Factory$n; IndexedAccessTypeNode: Factory$v; MethodDeclaration: Factory$r; TypeOperatorNode: Factory$6; Namespace: Factory$q; PropertySignature: Factory$j; PropertyDeclaration: Factory$k; RegularExpressionLiteral: Factory$i; TypeAliasDeclaration: Factory$9; TypeNode: Factory$7; LiteralTypeNode: Factory$s; IndexSignatureDeclaration: Factory$w; UnionTypeNode: Factory$3; IntersectionTypeNode: Factory$t; TypeReferenceNode: Factory$4; TypeParameterDeclaration: Factory$5; ConstructorDeclaration: Factory$B; ReturnStatement: Factory$h; VariableDeclaration: Factory$2; VariableDeclarationList: Factory$1; VariableStatement: Factory; BinaryExpression: Factory$F; PropertyAccessExpression: Factory$m; NoSubstitutionTemplateLiteral: Factory$p; TemplateSpan: Factory$b; TemplateExpression: Factory$e; TemplateHead: Factory$d; TemplateMiddle: Factory$c; TemplateTail: Factory$a; Identifier: Factory$x; PropertyAssignment: Factory$l; ObjectLiteralExpression: Factory$o; ElementAccessExpression: Factory$A; ExpressionStatement: Factory$z; CallExpression: Factory$D; StringLiteral: Factory$f; FunctionTypeNode: Factory$y; TypeLiteralNode: Factory$8; ShorthandPropertyAssignment: Factory$g; } declare const create$1: () => Type; type index_Type = Type; declare namespace index { export { type index_Type as Type, create$1 as create }; } interface FormatConversion { /** * Search parameters for the Schema to be converted */ selector: { /** * DataType format * * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#data-types */ format: string; }; /** * Output format */ output: { /** * The type after conversion. The input string will be output as a typedef. */ type: string[]; /** * How to handle typedefs when there is more than one. * * Default oneOf */ multiType?: "allOf" | "oneOf"; }; } /** * ユーザーが利用できる各種変換オプション */ interface Options { formatConversions?: FormatConversion[]; } interface Types { /** * operationIdに対するescape */ escapeOperationIdText: (operationId: string) => string; /** * interface/namespace/typeAliasのnameをescapeする * import/exportなどの予約語も裁く */ escapeDeclarationText: (text: string) => string; /** * Schemas.A.B.Cに対するEscape */ escapeReferenceDeclarationText: (text: string) => string; /** * 非破壊: PropertySignatureのname用のescape */ escapePropertySignatureName: (text: string) => string; /** * 破壊: TypeReferenceのname用のescape */ escapeTypeReferenceNodeName: (text: string) => string; generateResponseName: (operationId: string, statusCode: string) => string; generateArgumentParamsTypeDeclaration: (operationId: string) => string; generateRequestContentTypeName: (operationId: string) => string; generateResponseContentTypeName: (operationId: string) => string; generateParameterName: (operationId: string) => string; generateRequestBodyName: (operationId: string) => string; generateFunctionName: (operationId: string) => string; convertFormatTypeNode: (schema: { format?: string; }) => undefined | ts.TypeNode; } /** * ユーザーが利用できる各種変換オプション */ declare const create: (factory: Type, options?: Options) => Types; type ConverterContext_FormatConversion = FormatConversion; type ConverterContext_Options = Options; type ConverterContext_Types = Types; declare const ConverterContext_create: typeof create; declare namespace ConverterContext { export { type ConverterContext_FormatConversion as FormatConversion, type ConverterContext_Options as Options, type ConverterContext_Types as Types, ConverterContext_create as create }; } export { ConverterContext as C, type Options as O, index as i };