fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #1127 from hey-api/feat/zod-plugin-models

feat: zod plugin handles models

authored by

Lubos and committed by
GitHub
4ff2429c 41e42590

+9114 -1277
+2 -1
packages/openapi-ts/package.json
··· 116 116 "rxjs": "7.8.1", 117 117 "ts-node": "10.9.2", 118 118 "tslib": "2.6.3", 119 - "typescript": "5.5.3" 119 + "typescript": "5.5.3", 120 + "zod": "3.23.8" 120 121 } 121 122 }
+2 -155
packages/openapi-ts/src/compiler/index.ts
··· 1 - import { type PathLike, rmSync, writeFileSync } from 'node:fs'; 2 - import path from 'node:path'; 3 - 4 - import type ts from 'typescript'; 5 - 6 - import { ensureDirSync } from '../generate/utils'; 7 1 import * as classes from './classes'; 8 2 import * as convert from './convert'; 9 3 import * as module from './module'; ··· 18 12 export type { Comments } from './utils'; 19 13 export type { ClassElement, Node, TypeNode } from 'typescript'; 20 14 21 - const splitNameAndExtension = (fileName: string) => { 22 - const match = fileName.match(/\.[0-9a-z]+$/i); 23 - const extension = match ? match[0].slice(1) : ''; 24 - const name = fileName.slice( 25 - 0, 26 - fileName.length - (extension ? extension.length + 1 : 0), 27 - ); 28 - return { extension, name }; 29 - }; 30 - 31 - export class TypeScriptFile { 32 - private _headers: Array<string> = []; 33 - private _imports = new Map< 34 - string, 35 - Map<string, utils.ImportExportItemObject> 36 - >(); 37 - private _items: Array<ts.Node | string> = []; 38 - private _name: string; 39 - private _path: PathLike; 40 - 41 - public constructor({ 42 - dir, 43 - name, 44 - header = true, 45 - }: { 46 - dir: string; 47 - header?: boolean; 48 - name: string; 49 - }) { 50 - this._name = this._setName(name); 51 - this._path = path.resolve(dir, this.getName()); 52 - 53 - if (header) { 54 - this._headers = [ 55 - ...this._headers, 56 - '// This file is auto-generated by @hey-api/openapi-ts', 57 - ]; 58 - } 59 - } 60 - 61 - public add(...nodes: Array<ts.Node | string>) { 62 - this._items = [...this._items, ...nodes]; 63 - } 64 - 65 - /** 66 - * Adds an import to the provided module. Handles duplication, returns added import. 67 - */ 68 - public import({ 69 - module, 70 - ...importedItem 71 - }: utils.ImportExportItemObject & { 72 - module: string; 73 - }): utils.ImportExportItemObject { 74 - let moduleMap = this._imports.get(module); 75 - 76 - if (!moduleMap) { 77 - moduleMap = new Map<string, utils.ImportExportItemObject>(); 78 - this._imports.set(module, moduleMap); 79 - } 80 - 81 - const match = moduleMap.get(importedItem.name); 82 - if (match) { 83 - return match; 84 - } 85 - 86 - moduleMap.set(importedItem.name, importedItem); 87 - return importedItem; 88 - } 89 - 90 - public getName(withExtension = true) { 91 - if (withExtension) { 92 - return this._name; 93 - } 94 - 95 - const { name } = splitNameAndExtension(this._name); 96 - return name; 97 - } 98 - 99 - public isEmpty() { 100 - return !this._items.length; 101 - } 102 - 103 - public remove(options?: Parameters<typeof rmSync>[1]) { 104 - rmSync(this._path, options); 105 - } 106 - 107 - /** 108 - * Removes last node form the stack. Works as undo. 109 - */ 110 - public removeNode() { 111 - this._items = this._items.slice(0, this._items.length - 1); 112 - } 113 - 114 - private _setName(fileName: string) { 115 - if (fileName.includes('index')) { 116 - return fileName; 117 - } 118 - 119 - const { extension, name } = splitNameAndExtension(fileName); 120 - return [name, 'gen', extension].filter(Boolean).join('.'); 121 - } 122 - 123 - public toString(separator: string = '\n') { 124 - let output: string[] = []; 125 - if (this._headers.length) { 126 - output = [...output, this._headers.join('\n')]; 127 - } 128 - let importsStringArray: string[] = []; 129 - for (const [_module, moduleMap] of this._imports.entries()) { 130 - const imports = Array.from(moduleMap.values()); 131 - const node = compiler.namedImportDeclarations({ 132 - imports, 133 - module: _module, 134 - }); 135 - importsStringArray = [ 136 - ...importsStringArray, 137 - utils.tsNodeToString({ node }), 138 - ]; 139 - } 140 - if (importsStringArray.length) { 141 - output = [...output, importsStringArray.join('\n')]; 142 - } 143 - output = [ 144 - ...output, 145 - ...this._items.map((node) => 146 - typeof node === 'string' 147 - ? node 148 - : utils.tsNodeToString({ node, unescape: true }), 149 - ), 150 - ]; 151 - return output.join(separator); 152 - } 153 - 154 - public write(separator = '\n') { 155 - if (this.isEmpty()) { 156 - this.remove({ force: true }); 157 - return; 158 - } 159 - 160 - let dir = this._path; 161 - if (typeof this._path === 'string') { 162 - const parts = this._path.split(path.sep); 163 - dir = parts.slice(0, parts.length - 1).join(path.sep); 164 - } 165 - ensureDirSync(dir); 166 - writeFileSync(this._path, this.toString(separator)); 167 - } 168 - } 169 - 170 15 export const compiler = { 171 16 anonymousFunction: types.createAnonymousFunction, 172 17 arrayLiteralExpression: types.createArrayLiteralExpression, ··· 187 32 indexedAccessTypeNode: types.createIndexedAccessTypeNode, 188 33 isTsNode: utils.isTsNode, 189 34 keywordTypeNode: types.createKeywordTypeNode, 35 + literalTypeNode: types.createLiteralTypeNode, 190 36 methodDeclaration: classes.createMethodDeclaration, 191 37 namedImportDeclarations: module.createNamedImportDeclarations, 192 38 namespaceDeclaration: types.createNamespaceDeclaration, 193 39 nodeToString: utils.tsNodeToString, 40 + null: types.createNull, 194 41 objectExpression: types.createObjectType, 195 42 ots: utils.ots, 196 43 propertyAccessExpression: types.createPropertyAccessExpression,
+86 -27
packages/openapi-ts/src/compiler/typedef.ts
··· 1 1 import ts from 'typescript'; 2 2 3 - import { createTypeNode, createTypeReferenceNode } from './types'; 4 - import { addLeadingComments, type Comments, tsNodeToString } from './utils'; 3 + import { validTypescriptIdentifierRegExp } from '../utils/regexp'; 4 + import { 5 + createKeywordTypeNode, 6 + createStringLiteral, 7 + createTypeNode, 8 + createTypeReferenceNode, 9 + } from './types'; 10 + import { 11 + addLeadingComments, 12 + type Comments, 13 + createIdentifier, 14 + tsNodeToString, 15 + } from './utils'; 5 16 6 17 const nullNode = createTypeReferenceNode({ typeName: 'null' }); 7 18 ··· 38 49 * @returns ts.TypeLiteralNode | ts.TypeUnionNode 39 50 */ 40 51 export const createTypeInterfaceNode = ({ 52 + indexProperty, 41 53 isNullable, 42 54 properties, 55 + useLegacyResolution, 43 56 }: { 57 + /** 58 + * Adds an index signature if defined. 59 + * @example 60 + * ```ts 61 + * type IndexProperty = { 62 + * [key: string]: string 63 + * } 64 + * ``` 65 + */ 66 + indexProperty?: Property; 44 67 isNullable?: boolean; 45 68 properties: Property[]; 69 + useLegacyResolution: boolean; 46 70 }) => { 47 - const node = ts.factory.createTypeLiteralNode( 48 - properties.map((property) => { 49 - const modifiers: readonly ts.Modifier[] | undefined = property.isReadOnly 50 - ? [ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)] 51 - : undefined; 71 + const propertyTypes: Array<ts.TypeNode> = []; 52 72 53 - const questionToken: ts.QuestionToken | undefined = 54 - property.isRequired !== false 55 - ? undefined 56 - : ts.factory.createToken(ts.SyntaxKind.QuestionToken); 73 + const members: Array<ts.TypeElement> = properties.map((property) => { 74 + const modifiers: readonly ts.Modifier[] | undefined = property.isReadOnly 75 + ? [ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)] 76 + : undefined; 77 + 78 + const questionToken: ts.QuestionToken | undefined = 79 + property.isRequired !== false 80 + ? undefined 81 + : ts.factory.createToken(ts.SyntaxKind.QuestionToken); 82 + 83 + const type: ts.TypeNode | undefined = createTypeNode(property.type); 84 + propertyTypes.push(type); 85 + 86 + const signature = ts.factory.createPropertySignature( 87 + modifiers, 88 + useLegacyResolution || 89 + property.name.match(validTypescriptIdentifierRegExp) 90 + ? property.name 91 + : createStringLiteral({ text: property.name }), 92 + questionToken, 93 + type, 94 + ); 57 95 58 - const type: ts.TypeNode | undefined = createTypeNode(property.type); 96 + addLeadingComments({ 97 + comments: property.comment, 98 + node: signature, 99 + }); 59 100 60 - const signature = ts.factory.createPropertySignature( 61 - modifiers, 62 - property.name, 63 - questionToken, 64 - type, 65 - ); 101 + return signature; 102 + }); 66 103 67 - addLeadingComments({ 68 - comments: property.comment, 69 - node: signature, 70 - }); 104 + if (indexProperty) { 105 + const modifiers: readonly ts.Modifier[] | undefined = 106 + indexProperty.isReadOnly 107 + ? [ts.factory.createModifier(ts.SyntaxKind.ReadonlyKeyword)] 108 + : undefined; 109 + const indexSignature = ts.factory.createIndexSignature( 110 + modifiers, 111 + [ 112 + ts.factory.createParameterDeclaration( 113 + undefined, 114 + undefined, 115 + createIdentifier({ text: indexProperty.name }), 116 + undefined, 117 + createKeywordTypeNode({ 118 + keyword: 'string', 119 + }), 120 + undefined, 121 + ), 122 + ], 123 + createTypeNode(indexProperty.type), 124 + ); 125 + members.push(indexSignature); 126 + } 71 127 72 - return signature; 73 - }), 74 - ); 128 + const node = ts.factory.createTypeLiteralNode(members); 75 129 return maybeNullable({ isNullable, node }); 76 130 }; 77 131 ··· 140 194 keys: (any | ts.TypeNode)[], 141 195 values: (any | ts.TypeNode)[], 142 196 isNullable: boolean = false, 197 + useLegacyResolution: boolean = true, 143 198 ) => { 144 199 const keyNode = createTypeUnionNode({ 145 200 types: keys, ··· 157 212 type: valueNode, 158 213 }, 159 214 ], 215 + useLegacyResolution, 160 216 }); 161 217 return maybeNullable({ isNullable, node }); 162 218 }; ··· 168 224 * @returns ts.TypeReferenceNode | ts.UnionTypeNode 169 225 */ 170 226 export const createTypeArrayNode = ( 171 - types: (any | ts.TypeNode)[], 227 + types: (any | ts.TypeNode)[] | ts.TypeNode | string, 172 228 isNullable: boolean = false, 173 229 ) => { 174 230 const node = createTypeReferenceNode({ 175 - typeArguments: [createTypeUnionNode({ types })], 231 + typeArguments: [ 232 + // @ts-ignore 233 + Array.isArray(types) ? createTypeUnionNode({ types }) : types, 234 + ], 176 235 typeName: 'Array', 177 236 }); 178 237 return maybeNullable({ isNullable, node });
+78 -31
packages/openapi-ts/src/compiler/types.ts
··· 1 1 import ts from 'typescript'; 2 2 3 + import { escapeName } from '../utils/escape'; 3 4 import { validTypescriptIdentifierRegExp } from '../utils/regexp'; 4 5 import { 5 6 addLeadingComments, ··· 110 111 return node; 111 112 }; 112 113 114 + export const createNull = (): ts.NullLiteral => ts.factory.createNull(); 115 + 113 116 /** 114 117 * Convert an unknown value to an expression. 115 118 * @param identifiers - list of keys that are treated as identifiers. ··· 132 135 value: T; 133 136 }): ts.Expression | undefined => { 134 137 if (value === null) { 135 - return ts.factory.createNull(); 138 + return createNull(); 136 139 } 137 140 138 141 if (Array.isArray(value)) { ··· 252 255 export const createKeywordTypeNode = ({ 253 256 keyword, 254 257 }: { 255 - keyword: 'any' | 'boolean' | 'string'; 258 + keyword: 'any' | 'boolean' | 'number' | 'string' | 'undefined' | 'unknown'; 256 259 }) => { 257 260 let kind: ts.KeywordTypeSyntaxKind = ts.SyntaxKind.AnyKeyword; 258 261 switch (keyword) { 259 262 case 'boolean': 260 263 kind = ts.SyntaxKind.BooleanKeyword; 261 264 break; 265 + case 'number': 266 + kind = ts.SyntaxKind.NumberKeyword; 267 + break; 262 268 case 'string': 263 269 kind = ts.SyntaxKind.StringKeyword; 264 270 break; 271 + case 'undefined': 272 + kind = ts.SyntaxKind.UndefinedKeyword; 273 + break; 274 + case 'unknown': 275 + kind = ts.SyntaxKind.UnknownKeyword; 276 + break; 265 277 } 266 278 return ts.factory.createKeywordTypeNode(kind); 267 279 }; ··· 287 299 : undefined, 288 300 ), 289 301 ); 302 + 303 + export const createLiteralTypeNode = ({ 304 + literal, 305 + }: { 306 + literal: ts.LiteralTypeNode['literal']; 307 + }) => { 308 + const node = ts.factory.createLiteralTypeNode(literal); 309 + return node; 310 + }; 290 311 291 312 /** 292 313 * Create arrow function type expression. ··· 559 580 }) 560 581 .filter(isType<ObjectAssignment>); 561 582 562 - const expression = ts.factory.createObjectLiteralExpression( 583 + const node = ts.factory.createObjectLiteralExpression( 563 584 properties as any[], 564 585 multiLine, 565 586 ); 566 587 567 588 addLeadingComments({ 568 589 comments, 569 - node: expression, 590 + node, 570 591 }); 571 592 572 - return expression; 593 + return node; 573 594 }; 574 595 575 596 /** 576 597 * Create enum declaration. Example `export enum T = { X, Y };` 577 - * @param comments - comments to add to each property of enum. 598 + * @param comments - comments to add to each property. 578 599 * @param leadingComment - leading comment to add to enum. 579 600 * @param name - the name of the enum. 580 601 * @param obj - the object representing the enum. 581 - * @returns 602 + * @returns ts.EnumDeclaration 582 603 */ 583 - export const createEnumDeclaration = <T extends object>({ 584 - comments, 585 - leadingComment, 604 + export const createEnumDeclaration = < 605 + T extends Record<string, any> | Array<ObjectValue>, 606 + >({ 607 + comments: enumMemberComments = {}, 608 + leadingComment: comments, 586 609 name, 587 610 obj, 588 611 }: { ··· 591 614 name: string; 592 615 obj: T; 593 616 }): ts.EnumDeclaration => { 594 - const declaration = ts.factory.createEnumDeclaration( 595 - [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], 596 - createIdentifier({ text: name }), 597 - Object.entries(obj).map(([key, value]) => { 598 - const initializer = toExpression({ unescape: true, value }); 599 - const assignment = ts.factory.createEnumMember(key, initializer); 600 - const comment = comments?.[key]; 617 + const members: Array<ts.EnumMember> = Array.isArray(obj) 618 + ? obj.map((value) => { 619 + const enumMember = ts.factory.createEnumMember( 620 + escapeName(value.key), 621 + toExpression({ 622 + value: value.value, 623 + }), 624 + ); 625 + 626 + addLeadingComments({ 627 + comments: value.comments, 628 + node: enumMember, 629 + }); 630 + 631 + return enumMember; 632 + }) 633 + : Object.entries(obj).map(([key, value]) => { 634 + const initializer = toExpression({ unescape: true, value }); 635 + const enumMember = ts.factory.createEnumMember(key, initializer); 636 + 637 + addLeadingComments({ 638 + comments: enumMemberComments[key], 639 + node: enumMember, 640 + }); 601 641 602 - addLeadingComments({ 603 - comments: comment, 604 - node: assignment, 642 + return enumMember; 605 643 }); 606 644 607 - return assignment; 608 - }), 645 + const node = ts.factory.createEnumDeclaration( 646 + [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], 647 + createIdentifier({ text: name }), 648 + members, 609 649 ); 610 650 611 651 addLeadingComments({ 612 - comments: leadingComment, 613 - node: declaration, 652 + comments, 653 + node, 614 654 }); 615 655 616 - return declaration; 656 + return node; 617 657 }; 618 658 619 659 /** ··· 622 662 * @param nodes - the nodes in the namespace. 623 663 * @returns 624 664 */ 625 - export const createNamespaceDeclaration = < 626 - T extends Array<ts.EnumDeclaration>, 627 - >({ 665 + export const createNamespaceDeclaration = ({ 628 666 name, 629 667 statements, 630 668 }: { 631 669 name: string; 632 - statements: T; 670 + statements: Array<ts.Statement>; 633 671 }) => 634 672 ts.factory.createModuleDeclaration( 635 673 [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ··· 649 687 return node; 650 688 }; 651 689 652 - export const createStringLiteral = ({ text }: { text: string }) => { 653 - const node = ts.factory.createStringLiteral(text); 690 + export const createStringLiteral = ({ 691 + isSingleQuote, 692 + text, 693 + }: { 694 + isSingleQuote?: boolean; 695 + text: string; 696 + }) => { 697 + if (isSingleQuote === undefined) { 698 + isSingleQuote = !text.includes("'"); 699 + } 700 + const node = ts.factory.createStringLiteral(text, isSingleQuote); 654 701 return node; 655 702 }; 656 703
+5 -14
packages/openapi-ts/src/compiler/utils.ts
··· 2 2 3 3 import { getConfig } from '../utils/config'; 4 4 import { unescapeName } from '../utils/escape'; 5 + import { createStringLiteral } from './types'; 5 6 6 7 export interface ImportExportItemObject { 7 8 alias?: string; ··· 9 10 name: string; 10 11 } 11 12 12 - export const CONFIG = { 13 - newLine: ts.NewLineKind.LineFeed, 14 - scriptKind: ts.ScriptKind.TS, 15 - scriptTarget: ts.ScriptTarget.ES2015, 16 - useSingleQuotes: true, 17 - }; 18 - 19 - const printer = ts.createPrinter({ newLine: CONFIG.newLine }); 13 + const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); 20 14 21 15 export const createSourceFile = (sourceText: string) => 22 16 ts.createSourceFile( 23 17 '', 24 18 sourceText, 25 - CONFIG.scriptTarget, 19 + ts.ScriptTarget.ES2015, 26 20 undefined, 27 - CONFIG.scriptKind, 21 + ts.ScriptKind.TS, 28 22 ); 29 23 30 24 const blankSourceFile = createSourceFile(''); ··· 145 139 if (text.startsWith('`')) { 146 140 return createIdentifier({ text }); 147 141 } 148 - return ts.factory.createStringLiteral( 149 - text, 150 - text.includes("'") ? false : CONFIG.useSingleQuotes, 151 - ); 142 + return createStringLiteral({ text }); 152 143 }, 153 144 }; 154 145
+1 -1
packages/openapi-ts/src/generate/__tests__/index.spec.ts
··· 3 3 4 4 import { describe, expect, it, vi } from 'vitest'; 5 5 6 - import { TypeScriptFile } from '../../compiler'; 7 6 import { setConfig } from '../../utils/config'; 7 + import { TypeScriptFile } from '../files'; 8 8 import { generateIndexFile } from '../indexFile'; 9 9 10 10 vi.mock('node:fs');
+8 -2
packages/openapi-ts/src/generate/__tests__/output.spec.ts
··· 2 2 3 3 import { describe, expect, it, vi } from 'vitest'; 4 4 5 + import type { Client } from '../../types/client'; 5 6 import { setConfig } from '../../utils/config'; 6 7 import { generateOutput } from '../output'; 7 8 import { mockTemplates, openApi } from './mocks'; ··· 33 34 useOptions: false, 34 35 }); 35 36 36 - const client: Parameters<typeof generateOutput>[1] = { 37 + const client: Client = { 37 38 models: [], 38 39 server: 'http://localhost:8080', 39 40 services: [], ··· 41 42 version: 'v1', 42 43 }; 43 44 44 - await generateOutput(openApi, client, mockTemplates); 45 + await generateOutput({ 46 + client, 47 + context: undefined, 48 + openApi, 49 + templates: mockTemplates, 50 + }); 45 51 46 52 expect(rmSync).toHaveBeenCalled(); 47 53 expect(mkdirSync).toHaveBeenCalled();
+21 -5
packages/openapi-ts/src/generate/__tests__/services.spec.ts
··· 3 3 4 4 import { describe, expect, it, vi } from 'vitest'; 5 5 6 - import { TypeScriptFile } from '../../compiler'; 7 6 import type { Operation } from '../../types/client'; 8 7 import type { Files } from '../../types/utils'; 9 8 import { setConfig } from '../../utils/config'; 9 + import { TypeScriptFile } from '../files'; 10 10 import { generateServices } from '../services'; 11 11 12 12 vi.mock('node:fs'); ··· 80 80 name: 'types.ts', 81 81 }); 82 82 83 - await generateServices({ client, files }); 83 + await generateServices({ 84 + client, 85 + context: undefined, 86 + files, 87 + }); 84 88 85 89 files.services.write(); 86 90 ··· 162 166 name: 'types.ts', 163 167 }); 164 168 165 - await generateServices({ client, files }); 169 + await generateServices({ 170 + client, 171 + context: undefined, 172 + files, 173 + }); 166 174 167 175 files.services.write(); 168 176 ··· 206 214 name: 'types.ts', 207 215 }); 208 216 209 - await generateServices({ client, files }); 217 + await generateServices({ 218 + client, 219 + context: undefined, 220 + files, 221 + }); 210 222 211 223 files.services.write(); 212 224 ··· 252 264 name: 'types.ts', 253 265 }); 254 266 255 - await generateServices({ client, files }); 267 + await generateServices({ 268 + client, 269 + context: undefined, 270 + files, 271 + }); 256 272 257 273 files.services.write(); 258 274
+2 -1
packages/openapi-ts/src/generate/__tests__/types.spec.ts
··· 3 3 4 4 import { describe, expect, it, vi } from 'vitest'; 5 5 6 - import { TypeScriptFile } from '../../compiler'; 7 6 import { setConfig } from '../../utils/config'; 7 + import { TypeScriptFile } from '../files'; 8 8 import { generateTypes } from '../types'; 9 9 10 10 vi.mock('node:fs'); ··· 75 75 76 76 await generateTypes({ 77 77 client, 78 + context: undefined, 78 79 files, 79 80 }); 80 81
+176
packages/openapi-ts/src/generate/files/index.ts
··· 1 + import { type PathLike, rmSync, writeFileSync } from 'node:fs'; 2 + import path from 'node:path'; 3 + 4 + import type ts from 'typescript'; 5 + 6 + import { compiler } from '../../compiler'; 7 + import { 8 + type ImportExportItemObject, 9 + tsNodeToString, 10 + } from '../../compiler/utils'; 11 + import { ensureValidTypeScriptJavaScriptIdentifier } from '../../openApi'; 12 + import { reservedWordsRegExp } from '../../utils/regexp'; 13 + import { ensureDirSync } from '../utils'; 14 + import { ensureUniqueIdentifier, splitNameAndExtension } from './name'; 15 + import type { Namespaces } from './types'; 16 + 17 + export class TypeScriptFile { 18 + private _headers: Array<string> = []; 19 + private _imports = new Map<string, Map<string, ImportExportItemObject>>(); 20 + private _items: Array<ts.Node | string> = []; 21 + private _name: string; 22 + private _path: PathLike; 23 + 24 + public namespaces: Namespaces = { 25 + type: {}, 26 + value: {}, 27 + }; 28 + 29 + public constructor({ 30 + dir, 31 + header = true, 32 + name, 33 + }: { 34 + dir: string; 35 + header?: boolean; 36 + name: string; 37 + }) { 38 + this._name = this._setName(name); 39 + this._path = path.resolve(dir, this.getName()); 40 + 41 + if (header) { 42 + this._headers.push( 43 + '// This file is auto-generated by @hey-api/openapi-ts', 44 + ); 45 + } 46 + } 47 + 48 + public add(...nodes: Array<ts.Node | string>) { 49 + this._items = this._items.concat(nodes); 50 + } 51 + 52 + public identifier({ 53 + namespace, 54 + ...args 55 + }: Omit<Parameters<typeof ensureUniqueIdentifier>[0], 'namespace'> & { 56 + namespace: keyof Namespaces; 57 + }) { 58 + let validNameTransformer: ((name: string) => string) | undefined; 59 + switch (namespace) { 60 + // TODO: parser - add case transformers 61 + case 'type': 62 + case 'value': 63 + validNameTransformer = (name) => 64 + ensureValidTypeScriptJavaScriptIdentifier(name).replace( 65 + reservedWordsRegExp, 66 + '_$1', 67 + ); 68 + break; 69 + } 70 + return ensureUniqueIdentifier({ 71 + namespace: this.namespaces[namespace], 72 + validNameTransformer, 73 + ...args, 74 + }); 75 + } 76 + 77 + /** 78 + * Adds an import to the provided module. Handles duplication, returns added import. 79 + */ 80 + public import({ 81 + module, 82 + ...importedItem 83 + }: ImportExportItemObject & { 84 + module: string; 85 + }): ImportExportItemObject { 86 + let moduleMap = this._imports.get(module); 87 + 88 + if (!moduleMap) { 89 + moduleMap = new Map<string, ImportExportItemObject>(); 90 + this._imports.set(module, moduleMap); 91 + } 92 + 93 + const match = moduleMap.get(importedItem.name); 94 + if (match) { 95 + return match; 96 + } 97 + 98 + moduleMap.set(importedItem.name, importedItem); 99 + return importedItem; 100 + } 101 + 102 + public getName(withExtension = true) { 103 + if (withExtension) { 104 + return this._name; 105 + } 106 + 107 + const { name } = splitNameAndExtension(this._name); 108 + return name; 109 + } 110 + 111 + public isEmpty() { 112 + return !this._items.length; 113 + } 114 + 115 + public remove(options?: Parameters<typeof rmSync>[1]) { 116 + rmSync(this._path, options); 117 + } 118 + 119 + /** 120 + * Removes last node form the stack. Works as undo. 121 + */ 122 + public removeNode() { 123 + this._items = this._items.slice(0, this._items.length - 1); 124 + } 125 + 126 + private _setName(fileName: string) { 127 + if (fileName.includes('index')) { 128 + return fileName; 129 + } 130 + 131 + const { extension, name } = splitNameAndExtension(fileName); 132 + return [name, 'gen', extension].filter(Boolean).join('.'); 133 + } 134 + 135 + public toString(separator: string = '\n') { 136 + let output: string[] = []; 137 + if (this._headers.length) { 138 + output.push(this._headers.join('\n')); 139 + } 140 + const importsStringArray: string[] = []; 141 + for (const [_module, moduleMap] of this._imports.entries()) { 142 + const imports = Array.from(moduleMap.values()); 143 + const node = compiler.namedImportDeclarations({ 144 + imports, 145 + module: _module, 146 + }); 147 + importsStringArray.push(tsNodeToString({ node })); 148 + } 149 + if (importsStringArray.length) { 150 + output.push(importsStringArray.join('\n')); 151 + } 152 + output = output.concat( 153 + this._items.map((node) => 154 + typeof node === 'string' 155 + ? node 156 + : tsNodeToString({ node, unescape: true }), 157 + ), 158 + ); 159 + return output.join(separator); 160 + } 161 + 162 + public write(separator = '\n') { 163 + if (this.isEmpty()) { 164 + this.remove({ force: true }); 165 + return; 166 + } 167 + 168 + let dir = this._path; 169 + if (typeof this._path === 'string') { 170 + const parts = this._path.split(path.sep); 171 + dir = parts.slice(0, parts.length - 1).join(path.sep); 172 + } 173 + ensureDirSync(dir); 174 + writeFileSync(this._path, this.toString(separator)); 175 + } 176 + }
+84
packages/openapi-ts/src/generate/files/name.ts
··· 1 + import type { EnsureUniqueIdentifierResult, Namespace } from './types'; 2 + 3 + export const ensureUniqueIdentifier = ({ 4 + $ref, 5 + count = 1, 6 + create = false, 7 + namespace, 8 + validNameTransformer, 9 + }: { 10 + $ref: string; 11 + count?: number; 12 + create?: boolean; 13 + namespace: Namespace; 14 + validNameTransformer?: (value: string) => string; 15 + }): EnsureUniqueIdentifierResult => { 16 + const parts = $ref.split('/'); 17 + let name = parts[parts.length - 1] || ''; 18 + 19 + if (!name) { 20 + return { 21 + created: false, 22 + name: '', 23 + }; 24 + } 25 + 26 + const refValue = namespace[$ref]; 27 + if (refValue) { 28 + return { 29 + created: false, 30 + name: refValue.name, 31 + }; 32 + } 33 + 34 + if (count > 1) { 35 + name = `${name}${count}`; 36 + } 37 + 38 + let nameValue = namespace[name]; 39 + if (nameValue) { 40 + if (nameValue.$ref === $ref) { 41 + return { 42 + created: false, 43 + name: nameValue.name, 44 + }; 45 + } 46 + 47 + return ensureUniqueIdentifier({ 48 + $ref, 49 + count: count + 1, 50 + create, 51 + namespace, 52 + validNameTransformer, 53 + }); 54 + } 55 + 56 + if (!create) { 57 + return { 58 + created: false, 59 + name: '', 60 + }; 61 + } 62 + 63 + nameValue = { 64 + $ref, 65 + name: validNameTransformer ? validNameTransformer(name) : name, 66 + }; 67 + namespace[name] = nameValue; 68 + namespace[nameValue.$ref] = nameValue; 69 + 70 + return { 71 + created: true, 72 + name: nameValue.name, 73 + }; 74 + }; 75 + 76 + export const splitNameAndExtension = (fileName: string) => { 77 + const match = fileName.match(/\.[0-9a-z]+$/i); 78 + const extension = match ? match[0].slice(1) : ''; 79 + const name = fileName.slice( 80 + 0, 81 + fileName.length - (extension ? extension.length + 1 : 0), 82 + ); 83 + return { extension, name }; 84 + };
+33
packages/openapi-ts/src/generate/files/types.ts
··· 1 + import type { ModelMeta } from '../../openApi'; 2 + 3 + export type Namespace = Record<string, ModelMeta>; 4 + 5 + export interface Namespaces { 6 + /** 7 + * Type namespace. Types, interfaces, and type aliases exist here. 8 + * @example 9 + * ```ts 10 + * export type Foo = string; 11 + * ``` 12 + */ 13 + type: Namespace; 14 + /** 15 + * Value namespace. Variables, functions, classes, and constants exist here. 16 + * @example 17 + * ```js 18 + * export const foo = ''; 19 + * ``` 20 + */ 21 + value: Namespace; 22 + } 23 + 24 + export interface EnsureUniqueIdentifierResult { 25 + /** 26 + * Did this function add a new property to the file's `identifiers` map? 27 + */ 28 + created: boolean; 29 + /** 30 + * Unique name for the resource. 31 + */ 32 + name: string; 33 + }
+2 -1
packages/openapi-ts/src/generate/indexFile.ts
··· 1 - import { compiler, TypeScriptFile } from '../compiler'; 1 + import { compiler } from '../compiler'; 2 2 import type { Files } from '../types/utils'; 3 3 import { getConfig } from '../utils/config'; 4 + import { TypeScriptFile } from './files'; 4 5 5 6 export const generateIndexFile = async ({ 6 7 files,
+78 -37
packages/openapi-ts/src/generate/output.ts
··· 1 1 import path from 'node:path'; 2 2 3 + import type { IRContext } from '../ir/context'; 3 4 import type { OpenApi } from '../openApi'; 4 5 import type { Client } from '../types/client'; 5 6 import type { Files } from '../types/utils'; ··· 21 22 * @param client Client containing models, schemas, and services 22 23 * @param templates Templates wrapper with all loaded Handlebars templates 23 24 */ 24 - export const generateOutput = async ( 25 - openApi: OpenApi, 26 - client: Client, 27 - templates: Templates, 28 - ): Promise<void> => { 25 + export const generateOutput = async ({ 26 + client, 27 + context, 28 + openApi, 29 + templates, 30 + }: { 31 + client: Client | undefined; 32 + context: IRContext | undefined; 33 + openApi: OpenApi; 34 + templates: Templates; 35 + }): Promise<void> => { 29 36 const config = getConfig(); 30 37 31 - if (config.services.include && config.services.asClass) { 32 - const regexp = new RegExp(config.services.include); 33 - client.services = client.services.filter((service) => 34 - regexp.test(service.name), 35 - ); 36 - } 38 + // TODO: parser - handle IR 39 + if (client) { 40 + if (config.services.include && config.services.asClass) { 41 + const regexp = new RegExp(config.services.include); 42 + client.services = client.services.filter((service) => 43 + regexp.test(service.name), 44 + ); 45 + } 37 46 38 - if (config.types.include) { 39 - const regexp = new RegExp(config.types.include); 40 - client.models = client.models.filter((model) => regexp.test(model.name)); 47 + if (config.types.include) { 48 + const regexp = new RegExp(config.types.include); 49 + client.models = client.models.filter((model) => regexp.test(model.name)); 50 + } 41 51 } 42 52 43 53 const outputPath = path.resolve(config.output.path); ··· 47 57 await generateClient(outputPath, config.client.name); 48 58 49 59 // types.gen.ts 50 - await generateTypes({ client, files }); 60 + await generateTypes({ 61 + client, 62 + context, 63 + files, 64 + }); 51 65 52 66 // schemas.gen.ts 53 67 await generateSchemas({ files, openApi }); 54 68 55 69 // transformers 56 - if ( 57 - config.services.export && 58 - client.services.length && 59 - config.types.dates === 'types+transform' 60 - ) { 61 - await generateResponseTransformers({ 62 - client, 63 - onNode: (node) => { 64 - files.types?.add(node); 65 - }, 66 - onRemoveNode: () => { 67 - files.types?.removeNode(); 68 - }, 69 - }); 70 + // TODO: parser - handle IR 71 + if (client) { 72 + if ( 73 + config.services.export && 74 + client.services.length && 75 + config.types.dates === 'types+transform' 76 + ) { 77 + await generateResponseTransformers({ 78 + client, 79 + onNode: (node) => { 80 + files.types?.add(node); 81 + }, 82 + onRemoveNode: () => { 83 + files.types?.removeNode(); 84 + }, 85 + }); 86 + } 70 87 } 71 88 72 89 // services.gen.ts 73 - await generateServices({ client, files }); 90 + await generateServices({ 91 + client, 92 + context, 93 + files, 94 + }); 74 95 75 96 // deprecated files 76 - await generateClientClass(openApi, outputPath, client, templates); 77 - await generateCore( 78 - path.resolve(config.output.path, 'core'), 79 - client, 80 - templates, 81 - ); 97 + if (client) { 98 + await generateClientClass(openApi, outputPath, client, templates); 99 + await generateCore( 100 + path.resolve(config.output.path, 'core'), 101 + client, 102 + templates, 103 + ); 104 + } 82 105 83 106 // index.ts. Any files generated after this won't be included in exports 84 107 // from the index file. 85 108 await generateIndexFile({ files }); 86 109 87 110 // plugins 88 - await generatePlugins({ client, files }); 111 + await generatePlugins({ 112 + client, 113 + context, 114 + files, 115 + }); 89 116 90 117 Object.entries(files).forEach(([name, file]) => { 91 118 if (config.dryRun) { ··· 98 125 file.write('\n\n'); 99 126 } 100 127 }); 128 + 129 + if (context) { 130 + Object.entries(context.files).forEach(([name, file]) => { 131 + if (config.dryRun) { 132 + return; 133 + } 134 + 135 + if (name === 'index') { 136 + file.write(); 137 + } else { 138 + file.write('\n\n'); 139 + } 140 + }); 141 + } 101 142 };
+19 -7
packages/openapi-ts/src/generate/plugins.ts
··· 1 1 import path from 'node:path'; 2 2 3 - import { TypeScriptFile } from '../compiler'; 3 + import type { IRContext } from '../ir/context'; 4 4 import type { Client } from '../types/client'; 5 5 import type { Files } from '../types/utils'; 6 6 import { getConfig, isLegacyClient } from '../utils/config'; 7 + import { TypeScriptFile } from './files'; 7 8 8 9 export const generatePlugins = async ({ 9 10 client, 10 11 files, 12 + context, 11 13 }: { 12 - client: Client; 14 + client: Client | undefined; 15 + context: IRContext | undefined; 13 16 files: Files; 14 17 }) => { 15 18 const config = getConfig(); ··· 29 32 dir: outputDir, 30 33 name: `${outputParts[outputParts.length - 1]}.ts`, 31 34 }); 32 - plugin.handler({ 33 - client, 34 - files, 35 - plugin: plugin as never, 36 - }); 35 + 36 + if (context) { 37 + plugin.handler_experimental({ 38 + context, 39 + files, 40 + plugin: plugin as never, 41 + }); 42 + } else if (client) { 43 + plugin.handler({ 44 + client, 45 + files, 46 + plugin: plugin as never, 47 + }); 48 + } 37 49 } 38 50 };
+2 -1
packages/openapi-ts/src/generate/schemas.ts
··· 1 - import { compiler, TypeScriptFile } from '../compiler'; 1 + import { compiler } from '../compiler'; 2 2 import type { OpenApi, OpenApiV2Schema, OpenApiV3Schema } from '../openApi'; 3 3 import { ensureValidTypeScriptJavaScriptIdentifier } from '../openApi'; 4 4 import type { Files } from '../types/utils'; 5 5 import { getConfig } from '../utils/config'; 6 + import { TypeScriptFile } from './files'; 6 7 7 8 const ensureValidSchemaOutput = ( 8 9 schema: unknown,
+193 -40
packages/openapi-ts/src/generate/services.ts
··· 4 4 FunctionParameter, 5 5 Node, 6 6 } from '../compiler'; 7 - import { compiler, TypeScriptFile } from '../compiler'; 7 + import { compiler } from '../compiler'; 8 8 import type { FunctionTypeParameter, ObjectValue } from '../compiler/types'; 9 + import type { IRContext } from '../ir/context'; 10 + import type { 11 + IROperationObject, 12 + IRPathItemObject, 13 + IRPathsObject, 14 + } from '../ir/ir'; 9 15 import { isOperationParameterRequired } from '../openApi'; 10 16 import type { 11 17 Client, ··· 14 20 OperationParameter, 15 21 Service, 16 22 } from '../types/client'; 23 + import type { Config } from '../types/config'; 17 24 import type { Files } from '../types/utils'; 18 25 import { camelCase } from '../utils/camelCase'; 19 26 import { getConfig, isLegacyClient } from '../utils/config'; ··· 23 30 import { setUniqueTypeName } from '../utils/type'; 24 31 import { unique } from '../utils/unique'; 25 32 import { clientModulePath, clientOptionsTypeName } from './client'; 33 + import { TypeScriptFile } from './files'; 34 + import { irRef } from './types'; 26 35 27 36 type OnNode = (node: Node) => void; 28 37 type OnImport = (name: string) => void; ··· 58 67 export const modelResponseTransformerTypeName = (name: string) => 59 68 `${name}ModelResponseTransformer`; 60 69 70 + interface OperationIRRef { 71 + /** 72 + * Operation ID 73 + */ 74 + id: string; 75 + } 76 + 77 + const operationIrRef = ({ 78 + id, 79 + type, 80 + }: OperationIRRef & { 81 + type: 'data' | 'error' | 'response'; 82 + }): string => { 83 + let affix = ''; 84 + switch (type) { 85 + case 'data': 86 + affix = 'Data'; 87 + break; 88 + case 'error': 89 + affix = 'Error'; 90 + break; 91 + case 'response': 92 + affix = 'Response'; 93 + break; 94 + } 95 + return `${irRef}${camelCase({ 96 + input: id, 97 + pascalCase: true, 98 + })}${affix}`; 99 + }; 100 + 101 + export const operationDataRef = ({ id }: OperationIRRef): string => 102 + operationIrRef({ id, type: 'data' }); 103 + 61 104 export const operationDataTypeName = (name: string) => 62 105 `${camelCase({ 63 106 input: name, 64 107 pascalCase: true, 65 108 })}Data`; 66 109 110 + export const operationErrorRef = ({ id }: OperationIRRef): string => 111 + operationIrRef({ id, type: 'error' }); 112 + 67 113 export const operationErrorTypeName = (name: string) => 68 114 `${camelCase({ 69 115 input: name, ··· 73 119 // operation response type ends with "Response", it's enough to append "Transformer" 74 120 export const operationResponseTransformerTypeName = (name: string) => 75 121 `${name}Transformer`; 122 + 123 + export const operationResponseRef = ({ id }: OperationIRRef): string => 124 + operationIrRef({ id, type: 'response' }); 76 125 77 126 export const operationResponseTypeName = (name: string) => 78 127 `${camelCase({ ··· 463 512 }); 464 513 }; 465 514 466 - export const toOperationName = ( 467 - operation: Operation, 468 - handleIllegal: boolean, 469 - ) => { 470 - const config = getConfig(); 471 - 515 + export const toOperationName = ({ 516 + config, 517 + id, 518 + operation, 519 + handleIllegal, 520 + }: { 521 + config: Config; 522 + handleIllegal?: boolean; 523 + id: string; 524 + operation: IROperationObject | Operation; 525 + }) => { 472 526 if (config.services.methodNameBuilder) { 473 527 return config.services.methodNameBuilder(operation); 474 528 } 475 529 476 - if (handleIllegal && operation.name.match(reservedWordsRegExp)) { 477 - return `${operation.name}_`; 530 + if (handleIllegal && id.match(reservedWordsRegExp)) { 531 + return `${id}_`; 478 532 } 479 533 480 - return operation.name; 534 + return id; 481 535 }; 482 536 483 537 const toOperationStatements = ( ··· 651 705 comment: toOperationComment(operation), 652 706 exportConst: true, 653 707 expression, 654 - name: toOperationName(operation, true), 708 + name: toOperationName({ 709 + config, 710 + handleIllegal: true, 711 + id: operation.name, 712 + operation, 713 + }), 655 714 }); 656 715 onNode(statement); 657 716 } ··· 664 723 comment: toOperationComment(operation), 665 724 isStatic: 666 725 config.name === undefined && config.client.name !== 'legacy/angular', 667 - name: toOperationName(operation, false), 726 + name: toOperationName({ 727 + config, 728 + id: operation.name, 729 + operation, 730 + }), 668 731 parameters: toOperationParamType(client, operation), 669 732 returnType: !isLegacy 670 733 ? undefined ··· 723 786 ? { args: [{ providedIn: 'root' }], name: 'Injectable' } 724 787 : undefined, 725 788 members, 726 - name: transformServiceName(service.name), 789 + name: transformServiceName({ 790 + config, 791 + name: service.name, 792 + }), 727 793 }); 728 794 onNode(statement); 729 795 }; 730 796 731 - const checkPrerequisites = ({ files }: { files: Files }) => { 732 - const config = getConfig(); 797 + const checkPrerequisites = ({ 798 + context, 799 + files, 800 + }: { 801 + context: IRContext | undefined; 802 + files: Files; 803 + }) => { 804 + if (!context) { 805 + const config = getConfig(); 806 + 807 + if (!config.client.name) { 808 + throw new Error( 809 + '🚫 client needs to be set to generate services - which HTTP client do you want to use?', 810 + ); 811 + } 812 + 813 + if (!files.types) { 814 + throw new Error( 815 + '🚫 types need to be exported to generate services - enable type generation', 816 + ); 817 + } 818 + 819 + return; 820 + } 733 821 734 - if (!config.client.name) { 822 + if (!context.config.client.name) { 735 823 throw new Error( 736 824 '🚫 client needs to be set to generate services - which HTTP client do you want to use?', 737 825 ); 738 826 } 739 827 740 - if (!files.types) { 828 + if (!context.file({ id: 'types' })) { 741 829 throw new Error( 742 830 '🚫 types need to be exported to generate services - enable type generation', 743 831 ); ··· 746 834 747 835 export const generateServices = async ({ 748 836 client, 837 + context, 749 838 files, 750 839 }: { 751 - client: Client; 840 + client: Client | undefined; 841 + context: IRContext | undefined; 752 842 files: Files; 753 843 }): Promise<void> => { 754 844 const config = getConfig(); ··· 757 847 return; 758 848 } 759 849 760 - checkPrerequisites({ files }); 850 + checkPrerequisites({ context, files }); 761 851 762 852 const isLegacy = isLegacyClient(config); 763 853 ··· 854 944 files.services.add(statement); 855 945 } 856 946 857 - for (const service of client.services) { 858 - processService({ 859 - client, 860 - onClientImport: (imported) => { 861 - files.services.import({ 862 - module: clientModulePath({ sourceOutput: servicesOutput }), 863 - name: imported, 864 - }); 865 - }, 866 - onImport: (imported) => { 867 - files.services.import({ 868 - // this detection could be done safer, but it shouldn't cause any issues 869 - asType: !imported.endsWith('Transformer'), 870 - module: `./${files.types.getName(false)}`, 871 - name: imported, 947 + if (client) { 948 + for (const service of client.services) { 949 + processService({ 950 + client, 951 + onClientImport: (imported) => { 952 + files.services.import({ 953 + module: clientModulePath({ sourceOutput: servicesOutput }), 954 + name: imported, 955 + }); 956 + }, 957 + onImport: (imported) => { 958 + files.services.import({ 959 + // this detection could be done safer, but it shouldn't cause any issues 960 + asType: !imported.endsWith('Transformer'), 961 + module: `./${files.types.getName(false)}`, 962 + name: imported, 963 + }); 964 + }, 965 + onNode: (node) => { 966 + files.services.add(node); 967 + }, 968 + service, 969 + }); 970 + } 971 + return; 972 + } 973 + 974 + if (!context) { 975 + return; 976 + } 977 + 978 + // TODO: parser - generate services 979 + for (const path in context.ir.paths) { 980 + const pathItem = context.ir.paths[path as keyof IRPathsObject]; 981 + // console.warn(pathItem) 982 + 983 + for (const method in pathItem) { 984 + const operation = pathItem[method as keyof IRPathItemObject]!; 985 + 986 + if (operation.parameters) { 987 + const identifier = context.file({ id: 'types' })!.identifier({ 988 + $ref: operationDataRef({ id: operation.id }), 989 + namespace: 'type', 872 990 }); 873 - }, 874 - onNode: (node) => { 875 - files.services.add(node); 876 - }, 877 - service, 878 - }); 991 + if (identifier.name) { 992 + files.services.import({ 993 + // this detection could be done safer, but it shouldn't cause any issues 994 + asType: !identifier.name.endsWith('Transformer'), 995 + module: `./${context.file({ id: 'types' })!.getName(false)}`, 996 + name: identifier.name, 997 + }); 998 + } 999 + } 1000 + 1001 + // if (!isLegacy) { 1002 + // generateImport({ 1003 + // client, 1004 + // meta: { 1005 + // // TODO: this should be exact ref to operation for consistency, 1006 + // // but name should work too as operation ID is unique 1007 + // $ref: operation.name, 1008 + // name: operation.name, 1009 + // }, 1010 + // nameTransformer: operationErrorTypeName, 1011 + // onImport, 1012 + // }); 1013 + // } 1014 + 1015 + // const successResponses = operation.responses.filter((response) => 1016 + // response.responseTypes.includes('success'), 1017 + // ); 1018 + // if (successResponses.length) { 1019 + // generateImport({ 1020 + // client, 1021 + // meta: { 1022 + // // TODO: this should be exact ref to operation for consistency, 1023 + // // but name should work too as operation ID is unique 1024 + // $ref: operation.name, 1025 + // name: operation.name, 1026 + // }, 1027 + // nameTransformer: operationResponseTypeName, 1028 + // onImport, 1029 + // }); 1030 + // } 1031 + } 879 1032 } 880 1033 };
+1139 -21
packages/openapi-ts/src/generate/types.ts
··· 1 1 import type { EnumDeclaration } from 'typescript'; 2 + import type ts from 'typescript'; 2 3 4 + import type { Property } from '../compiler'; 5 + import { type Comments, compiler, type Node } from '../compiler'; 6 + import type { IRContext } from '../ir/context'; 7 + import type { 8 + IROperationObject, 9 + IRParameterObject, 10 + IRPathsObject, 11 + IRResponseObject, 12 + IRSchemaObject, 13 + } from '../ir/ir'; 14 + import { addItemsToSchema } from '../ir/utils'; 3 15 import { 4 - type Comments, 5 - compiler, 6 - type Node, 7 - TypeScriptFile, 8 - } from '../compiler'; 9 - import { isOperationParameterRequired } from '../openApi'; 10 - import type { Method, Model, OperationParameter } from '../types/client'; 11 - import type { Client } from '../types/client'; 16 + ensureValidTypeScriptJavaScriptIdentifier, 17 + isOperationParameterRequired, 18 + } from '../openApi'; 19 + import type { 20 + Client, 21 + Method, 22 + Model, 23 + OperationParameter, 24 + } from '../types/client'; 12 25 import type { Files } from '../types/utils'; 13 26 import { getConfig, isLegacyClient } from '../utils/config'; 14 27 import { enumEntry, enumUnionType } from '../utils/enum'; 15 28 import { escapeComment } from '../utils/escape'; 29 + import { isRefOpenApiComponent } from '../utils/ref'; 16 30 import { sortByName, sorterByName } from '../utils/sort'; 17 31 import { 18 32 setUniqueTypeName, 19 33 type SetUniqueTypeNameResult, 20 34 toType, 21 35 } from '../utils/type'; 36 + import { TypeScriptFile } from './files'; 22 37 import { 38 + operationDataRef, 23 39 operationDataTypeName, 40 + operationErrorRef, 24 41 operationErrorTypeName, 42 + operationResponseRef, 25 43 operationResponseTypeName, 26 44 } from './services'; 27 45 ··· 32 50 onRemoveNode?: VoidFunction; 33 51 } 34 52 53 + interface SchemaWithType<T extends Required<IRSchemaObject>['type']> 54 + extends Omit<IRSchemaObject, 'type'> { 55 + type: Extract<Required<IRSchemaObject>['type'], T>; 56 + } 57 + 35 58 const treeName = '$OpenApiTs'; 59 + 60 + export const irRef = '#/ir/'; 61 + const typesId = 'types'; 36 62 37 63 export const emptyModel: Model = { 38 64 $refs: [], ··· 600 626 } 601 627 }; 602 628 629 + const parseSchemaJsDoc = ({ schema }: { schema: IRSchemaObject }) => { 630 + const comments = [ 631 + schema.description && escapeComment(schema.description), 632 + schema.deprecated && '@deprecated', 633 + ]; 634 + return comments; 635 + }; 636 + 637 + const addJavaScriptEnum = ({ 638 + $ref, 639 + context, 640 + schema, 641 + }: { 642 + $ref: string; 643 + context: IRContext; 644 + schema: SchemaWithType<'enum'>; 645 + }) => { 646 + const identifier = context.file({ id: typesId })!.identifier({ 647 + $ref, 648 + create: true, 649 + namespace: 'value', 650 + }); 651 + 652 + // TODO: parser - this is the old parser behavior where we would NOT 653 + // print nested enum identifiers if they already exist. This is a 654 + // blocker for referencing these identifiers within the file as 655 + // we cannot guarantee just because they have a duplicate identifier, 656 + // they have a duplicate value. 657 + if (!identifier.created) { 658 + return; 659 + } 660 + 661 + const enumObject = schemaToEnumObject({ schema }); 662 + 663 + const expression = compiler.objectExpression({ 664 + multiLine: true, 665 + obj: enumObject.obj, 666 + }); 667 + const node = compiler.constVariable({ 668 + assertion: 'const', 669 + comment: parseSchemaJsDoc({ schema }), 670 + exportConst: true, 671 + expression, 672 + name: identifier.name, 673 + }); 674 + return node; 675 + }; 676 + 677 + const schemaToEnumObject = ({ schema }: { schema: IRSchemaObject }) => { 678 + const typeofItems: Array< 679 + | 'string' 680 + | 'number' 681 + | 'bigint' 682 + | 'boolean' 683 + | 'symbol' 684 + | 'undefined' 685 + | 'object' 686 + | 'function' 687 + > = []; 688 + 689 + const obj = (schema.items ?? []).map((item) => { 690 + const typeOfItemConst = typeof item.const; 691 + 692 + if (!typeofItems.includes(typeOfItemConst)) { 693 + typeofItems.push(typeOfItemConst); 694 + } 695 + 696 + let key; 697 + if (item.title) { 698 + key = item.title; 699 + } else if (typeOfItemConst === 'number') { 700 + key = `_${item.const}`; 701 + } else if (typeOfItemConst === 'boolean') { 702 + const valid = typeOfItemConst ? 'true' : 'false'; 703 + key = valid.toLocaleUpperCase(); 704 + } else { 705 + let valid = ensureValidTypeScriptJavaScriptIdentifier( 706 + item.const as string, 707 + ); 708 + if (!valid) { 709 + // TODO: parser - abstract empty string handling 710 + valid = 'empty_string'; 711 + } 712 + key = valid.toLocaleUpperCase(); 713 + } 714 + return { 715 + comments: parseSchemaJsDoc({ schema: item }), 716 + key, 717 + value: item.const, 718 + }; 719 + }); 720 + 721 + return { 722 + obj, 723 + typeofItems, 724 + }; 725 + }; 726 + 727 + const addTypeEnum = ({ 728 + $ref, 729 + context, 730 + schema, 731 + }: { 732 + $ref: string; 733 + context: IRContext; 734 + schema: SchemaWithType<'enum'>; 735 + }) => { 736 + const identifier = context.file({ id: typesId })!.identifier({ 737 + $ref, 738 + create: true, 739 + namespace: 'type', 740 + }); 741 + 742 + // TODO: parser - this is the old parser behavior where we would NOT 743 + // print nested enum identifiers if they already exist. This is a 744 + // blocker for referencing these identifiers within the file as 745 + // we cannot guarantee just because they have a duplicate identifier, 746 + // they have a duplicate value. 747 + if ( 748 + !identifier.created && 749 + context.config.types.enums !== 'typescript+namespace' 750 + ) { 751 + return; 752 + } 753 + 754 + const node = compiler.typeAliasDeclaration({ 755 + comment: parseSchemaJsDoc({ schema }), 756 + exportType: true, 757 + name: identifier.name, 758 + type: schemaToType({ 759 + context, 760 + schema: { 761 + ...schema, 762 + type: undefined, 763 + }, 764 + }), 765 + }); 766 + return node; 767 + }; 768 + 769 + const addTypeScriptEnum = ({ 770 + $ref, 771 + context, 772 + schema, 773 + }: { 774 + $ref: string; 775 + context: IRContext; 776 + schema: SchemaWithType<'enum'>; 777 + }) => { 778 + const identifier = context.file({ id: typesId })!.identifier({ 779 + $ref, 780 + create: true, 781 + namespace: 'value', 782 + }); 783 + 784 + // TODO: parser - this is the old parser behavior where we would NOT 785 + // print nested enum identifiers if they already exist. This is a 786 + // blocker for referencing these identifiers within the file as 787 + // we cannot guarantee just because they have a duplicate identifier, 788 + // they have a duplicate value. 789 + if ( 790 + !identifier.created && 791 + context.config.types.enums !== 'typescript+namespace' 792 + ) { 793 + return; 794 + } 795 + 796 + const enumObject = schemaToEnumObject({ schema }); 797 + 798 + // TypeScript enums support only string and number values so we need to fallback to types 799 + if ( 800 + enumObject.typeofItems.filter( 801 + (type) => type !== 'number' && type !== 'string', 802 + ).length 803 + ) { 804 + const node = addTypeEnum({ 805 + $ref, 806 + context, 807 + schema, 808 + }); 809 + return node; 810 + } 811 + 812 + const node = compiler.enumDeclaration({ 813 + leadingComment: parseSchemaJsDoc({ schema }), 814 + name: identifier.name, 815 + obj: enumObject.obj, 816 + }); 817 + return node; 818 + }; 819 + 820 + const arrayTypeToIdentifier = ({ 821 + context, 822 + namespace, 823 + schema, 824 + }: { 825 + context: IRContext; 826 + namespace: Array<ts.Statement>; 827 + schema: SchemaWithType<'array'>; 828 + }) => { 829 + if (!schema.items) { 830 + return compiler.typeArrayNode( 831 + compiler.keywordTypeNode({ 832 + keyword: 'unknown', 833 + }), 834 + ); 835 + } 836 + 837 + return compiler.typeArrayNode( 838 + schemaToType({ 839 + context, 840 + namespace, 841 + schema: { 842 + ...schema, 843 + type: undefined, 844 + }, 845 + }), 846 + ); 847 + }; 848 + 849 + const booleanTypeToIdentifier = ({ 850 + schema, 851 + }: { 852 + context: IRContext; 853 + namespace: Array<ts.Statement>; 854 + schema: SchemaWithType<'boolean'>; 855 + }) => { 856 + if (schema.const !== undefined) { 857 + return compiler.literalTypeNode({ 858 + literal: compiler.ots.boolean(schema.const as boolean), 859 + }); 860 + } 861 + 862 + return compiler.keywordTypeNode({ 863 + keyword: 'boolean', 864 + }); 865 + }; 866 + 867 + const enumTypeToIdentifier = ({ 868 + $ref, 869 + context, 870 + namespace, 871 + schema, 872 + }: { 873 + $ref?: string; 874 + context: IRContext; 875 + namespace: Array<ts.Statement>; 876 + schema: SchemaWithType<'enum'>; 877 + }): ts.TypeNode => { 878 + // TODO: parser - add option to inline enums 879 + if ($ref) { 880 + const isRefComponent = isRefOpenApiComponent($ref); 881 + 882 + // when enums are disabled (default), emit only reusable components 883 + // as types, otherwise the output would be broken if we skipped all enums 884 + if (!context.config.types.enums && isRefComponent) { 885 + const typeNode = addTypeEnum({ 886 + $ref, 887 + context, 888 + schema, 889 + }); 890 + if (typeNode) { 891 + context.file({ id: typesId })!.add(typeNode); 892 + } 893 + } 894 + 895 + if (context.config.types.enums === 'javascript') { 896 + const typeNode = addTypeEnum({ 897 + $ref, 898 + context, 899 + schema, 900 + }); 901 + if (typeNode) { 902 + context.file({ id: typesId })!.add(typeNode); 903 + } 904 + 905 + const objectNode = addJavaScriptEnum({ 906 + $ref, 907 + context, 908 + schema, 909 + }); 910 + if (objectNode) { 911 + context.file({ id: typesId })!.add(objectNode); 912 + } 913 + } 914 + 915 + if (context.config.types.enums === 'typescript') { 916 + const enumNode = addTypeScriptEnum({ 917 + $ref, 918 + context, 919 + schema, 920 + }); 921 + if (enumNode) { 922 + context.file({ id: typesId })!.add(enumNode); 923 + } 924 + } 925 + 926 + if (context.config.types.enums === 'typescript+namespace') { 927 + const enumNode = addTypeScriptEnum({ 928 + $ref, 929 + context, 930 + schema, 931 + }); 932 + if (enumNode) { 933 + if (isRefComponent) { 934 + context.file({ id: typesId })!.add(enumNode); 935 + } else { 936 + // emit enum inside TypeScript namespace 937 + namespace.push(enumNode); 938 + } 939 + } 940 + } 941 + } 942 + 943 + const type = schemaToType({ 944 + context, 945 + schema: { 946 + ...schema, 947 + type: undefined, 948 + }, 949 + }); 950 + return type; 951 + }; 952 + 953 + const numberTypeToIdentifier = ({ 954 + schema, 955 + }: { 956 + context: IRContext; 957 + namespace: Array<ts.Statement>; 958 + schema: SchemaWithType<'number'>; 959 + }) => { 960 + if (schema.const !== undefined) { 961 + return compiler.literalTypeNode({ 962 + literal: compiler.ots.number(schema.const as number), 963 + }); 964 + } 965 + 966 + return compiler.keywordTypeNode({ 967 + keyword: 'number', 968 + }); 969 + }; 970 + 971 + const objectTypeToIdentifier = ({ 972 + context, 973 + namespace, 974 + schema, 975 + }: { 976 + context: IRContext; 977 + namespace: Array<ts.Statement>; 978 + schema: SchemaWithType<'object'>; 979 + }) => { 980 + let indexProperty: Property | undefined; 981 + const schemaProperties: Array<Property> = []; 982 + const indexPropertyItems: Array<IRSchemaObject> = []; 983 + const required = schema.required ?? []; 984 + let hasOptionalProperties = false; 985 + 986 + for (const name in schema.properties) { 987 + const property = schema.properties[name]; 988 + const isRequired = required.includes(name); 989 + schemaProperties.push({ 990 + comment: parseSchemaJsDoc({ schema: property }), 991 + isReadOnly: property.accessScope === 'read', 992 + isRequired, 993 + name, 994 + type: schemaToType({ 995 + $ref: `${irRef}${name}`, 996 + context, 997 + namespace, 998 + schema: property, 999 + }), 1000 + }); 1001 + indexPropertyItems.push(property); 1002 + 1003 + if (!isRequired) { 1004 + hasOptionalProperties = true; 1005 + } 1006 + } 1007 + 1008 + if (schema.additionalProperties) { 1009 + indexPropertyItems.unshift(schema.additionalProperties); 1010 + 1011 + if (hasOptionalProperties) { 1012 + indexPropertyItems.push({ 1013 + type: 'void', 1014 + }); 1015 + } 1016 + 1017 + indexProperty = { 1018 + isRequired: true, 1019 + name: 'key', 1020 + type: schemaToType({ 1021 + context, 1022 + namespace, 1023 + schema: { 1024 + items: indexPropertyItems, 1025 + logicalOperator: 'or', 1026 + }, 1027 + }), 1028 + }; 1029 + } 1030 + 1031 + return compiler.typeInterfaceNode({ 1032 + indexProperty, 1033 + properties: schemaProperties, 1034 + useLegacyResolution: false, 1035 + }); 1036 + }; 1037 + 1038 + const stringTypeToIdentifier = ({ 1039 + schema, 1040 + }: { 1041 + context: IRContext; 1042 + namespace: Array<ts.Statement>; 1043 + schema: SchemaWithType<'string'>; 1044 + }) => { 1045 + if (schema.const !== undefined) { 1046 + return compiler.literalTypeNode({ 1047 + literal: compiler.stringLiteral({ text: schema.const as string }), 1048 + }); 1049 + } 1050 + 1051 + if (schema.format) { 1052 + if (schema.format === 'binary') { 1053 + return compiler.typeUnionNode({ 1054 + types: [ 1055 + compiler.typeReferenceNode({ 1056 + typeName: 'Blob', 1057 + }), 1058 + compiler.typeReferenceNode({ 1059 + typeName: 'File', 1060 + }), 1061 + ], 1062 + }); 1063 + } 1064 + } 1065 + 1066 + return compiler.keywordTypeNode({ 1067 + keyword: 'string', 1068 + }); 1069 + }; 1070 + 1071 + const tupleTypeToIdentifier = ({ 1072 + context, 1073 + namespace, 1074 + schema, 1075 + }: { 1076 + context: IRContext; 1077 + namespace: Array<ts.Statement>; 1078 + schema: SchemaWithType<'tuple'>; 1079 + }) => { 1080 + const itemTypes: Array<ts.TypeNode> = []; 1081 + 1082 + for (const item of schema.items ?? []) { 1083 + itemTypes.push( 1084 + schemaToType({ 1085 + context, 1086 + namespace, 1087 + schema: item, 1088 + }), 1089 + ); 1090 + } 1091 + 1092 + return compiler.typeTupleNode({ 1093 + types: itemTypes, 1094 + }); 1095 + }; 1096 + 1097 + const schemaTypeToIdentifier = ({ 1098 + $ref, 1099 + context, 1100 + namespace, 1101 + schema, 1102 + }: { 1103 + $ref?: string; 1104 + context: IRContext; 1105 + namespace: Array<ts.Statement>; 1106 + schema: IRSchemaObject; 1107 + }): ts.TypeNode => { 1108 + switch (schema.type as Required<IRSchemaObject>['type']) { 1109 + case 'array': 1110 + return arrayTypeToIdentifier({ 1111 + context, 1112 + namespace, 1113 + schema: schema as SchemaWithType<'array'>, 1114 + }); 1115 + case 'boolean': 1116 + return booleanTypeToIdentifier({ 1117 + context, 1118 + namespace, 1119 + schema: schema as SchemaWithType<'boolean'>, 1120 + }); 1121 + case 'enum': 1122 + return enumTypeToIdentifier({ 1123 + $ref, 1124 + context, 1125 + namespace, 1126 + schema: schema as SchemaWithType<'enum'>, 1127 + }); 1128 + case 'null': 1129 + return compiler.literalTypeNode({ 1130 + literal: compiler.null(), 1131 + }); 1132 + case 'number': 1133 + return numberTypeToIdentifier({ 1134 + context, 1135 + namespace, 1136 + schema: schema as SchemaWithType<'number'>, 1137 + }); 1138 + case 'object': 1139 + return objectTypeToIdentifier({ 1140 + context, 1141 + namespace, 1142 + schema: schema as SchemaWithType<'object'>, 1143 + }); 1144 + case 'string': 1145 + return stringTypeToIdentifier({ 1146 + context, 1147 + namespace, 1148 + schema: schema as SchemaWithType<'string'>, 1149 + }); 1150 + case 'tuple': 1151 + return tupleTypeToIdentifier({ 1152 + context, 1153 + namespace, 1154 + schema: schema as SchemaWithType<'tuple'>, 1155 + }); 1156 + case 'unknown': 1157 + return compiler.keywordTypeNode({ 1158 + keyword: 'unknown', 1159 + }); 1160 + case 'void': 1161 + return compiler.keywordTypeNode({ 1162 + keyword: 'undefined', 1163 + }); 1164 + } 1165 + }; 1166 + 1167 + /** 1168 + * Ensure we don't produce redundant types, e.g. string | string. 1169 + */ 1170 + const deduplicateSchema = ({ 1171 + schema, 1172 + }: { 1173 + schema: IRSchemaObject; 1174 + }): IRSchemaObject => { 1175 + if (!schema.items) { 1176 + return schema; 1177 + } 1178 + 1179 + const uniqueItems: Array<IRSchemaObject> = []; 1180 + const typeIds: Array<string> = []; 1181 + 1182 + for (const item of schema.items) { 1183 + // skip nested schemas for now, handle if necessary 1184 + if ( 1185 + item.type === 'boolean' || 1186 + item.type === 'null' || 1187 + item.type === 'number' || 1188 + item.type === 'string' || 1189 + item.type === 'unknown' || 1190 + item.type === 'void' 1191 + ) { 1192 + const typeId = `${item.$ref ?? ''}${item.type ?? ''}${item.const ?? ''}`; 1193 + if (!typeIds.includes(typeId)) { 1194 + typeIds.push(typeId); 1195 + uniqueItems.push(item); 1196 + } 1197 + continue; 1198 + } 1199 + 1200 + uniqueItems.push(item); 1201 + } 1202 + 1203 + schema.items = uniqueItems; 1204 + 1205 + if ( 1206 + schema.items.length <= 1 && 1207 + schema.type !== 'array' && 1208 + schema.type !== 'enum' && 1209 + schema.type !== 'tuple' 1210 + ) { 1211 + // bring the only item up to clean up the schema 1212 + const liftedSchema = schema.items[0]; 1213 + delete schema.logicalOperator; 1214 + delete schema.items; 1215 + schema = { 1216 + ...schema, 1217 + ...liftedSchema, 1218 + }; 1219 + } 1220 + 1221 + // exclude unknown if it's the only type left 1222 + if (schema.type === 'unknown') { 1223 + return {}; 1224 + } 1225 + 1226 + return schema; 1227 + }; 1228 + 1229 + const irParametersToIrSchema = ({ 1230 + parameters, 1231 + }: { 1232 + parameters: Record<string, IRParameterObject>; 1233 + }): IRSchemaObject => { 1234 + const irSchema: IRSchemaObject = { 1235 + type: 'object', 1236 + }; 1237 + 1238 + if (parameters) { 1239 + const properties: Record<string, IRSchemaObject> = {}; 1240 + const required: Array<string> = []; 1241 + 1242 + for (const name in parameters) { 1243 + const parameter = parameters[name]; 1244 + 1245 + properties[name] = deduplicateSchema({ 1246 + schema: parameter.schema, 1247 + }); 1248 + 1249 + if (parameter.required) { 1250 + required.push(name); 1251 + } 1252 + } 1253 + 1254 + irSchema.properties = properties; 1255 + 1256 + if (required.length) { 1257 + irSchema.required = required; 1258 + } 1259 + } 1260 + 1261 + return irSchema; 1262 + }; 1263 + 1264 + const operationToDataType = ({ 1265 + context, 1266 + operation, 1267 + }: { 1268 + context: IRContext; 1269 + operation: IROperationObject; 1270 + }) => { 1271 + const data: IRSchemaObject = { 1272 + type: 'object', 1273 + }; 1274 + const dataRequired: Array<string> = []; 1275 + 1276 + if (operation.body) { 1277 + if (!data.properties) { 1278 + data.properties = {}; 1279 + } 1280 + 1281 + data.properties.body = operation.body.schema; 1282 + 1283 + if (operation.body.required) { 1284 + dataRequired.push('body'); 1285 + } 1286 + } 1287 + 1288 + if (operation.parameters) { 1289 + if (!data.properties) { 1290 + data.properties = {}; 1291 + } 1292 + 1293 + // TODO: parser - handle cookie parameters 1294 + 1295 + if (operation.parameters.header) { 1296 + data.properties.headers = irParametersToIrSchema({ 1297 + parameters: operation.parameters.header, 1298 + }); 1299 + 1300 + if (data.properties.headers.required) { 1301 + dataRequired.push('headers'); 1302 + } 1303 + } 1304 + 1305 + if (operation.parameters.path) { 1306 + data.properties.path = irParametersToIrSchema({ 1307 + parameters: operation.parameters.path, 1308 + }); 1309 + 1310 + if (data.properties.path.required) { 1311 + dataRequired.push('path'); 1312 + } 1313 + } 1314 + 1315 + if (operation.parameters.query) { 1316 + data.properties.query = irParametersToIrSchema({ 1317 + parameters: operation.parameters.query, 1318 + }); 1319 + 1320 + if (data.properties.query.required) { 1321 + dataRequired.push('query'); 1322 + } 1323 + } 1324 + } 1325 + 1326 + data.required = dataRequired; 1327 + 1328 + if (data.properties) { 1329 + const identifier = context.file({ id: typesId })!.identifier({ 1330 + $ref: operationDataRef({ id: operation.id }), 1331 + create: true, 1332 + namespace: 'type', 1333 + }); 1334 + const node = compiler.typeAliasDeclaration({ 1335 + exportType: true, 1336 + name: identifier.name, 1337 + type: schemaToType({ 1338 + context, 1339 + schema: data, 1340 + }), 1341 + }); 1342 + context.file({ id: typesId })!.add(node); 1343 + } 1344 + }; 1345 + 1346 + type StatusGroup = '1XX' | '2XX' | '3XX' | '4XX' | '5XX' | 'default'; 1347 + 1348 + const statusCodeToGroup = ({ 1349 + statusCode, 1350 + }: { 1351 + statusCode: string; 1352 + }): StatusGroup => { 1353 + switch (statusCode) { 1354 + case '1XX': 1355 + return '1XX'; 1356 + case '2XX': 1357 + return '2XX'; 1358 + case '3XX': 1359 + return '3XX'; 1360 + case '4XX': 1361 + return '4XX'; 1362 + case '5XX': 1363 + return '5XX'; 1364 + case 'default': 1365 + return 'default'; 1366 + default: 1367 + return `${statusCode[0]}XX` as StatusGroup; 1368 + } 1369 + }; 1370 + 1371 + const operationToResponseTypes = ({ 1372 + context, 1373 + operation, 1374 + }: { 1375 + context: IRContext; 1376 + operation: IROperationObject; 1377 + }) => { 1378 + if (!operation.responses) { 1379 + return; 1380 + } 1381 + 1382 + const errors: IRSchemaObject = {}; 1383 + const errorsItems: Array<IRSchemaObject> = []; 1384 + 1385 + const responses: IRSchemaObject = {}; 1386 + const responsesItems: Array<IRSchemaObject> = []; 1387 + 1388 + let defaultResponse: IRResponseObject | undefined; 1389 + 1390 + for (const name in operation.responses) { 1391 + const response = operation.responses[name]!; 1392 + 1393 + switch (statusCodeToGroup({ statusCode: name })) { 1394 + case '1XX': 1395 + case '3XX': 1396 + // TODO: parser - handle informational and redirection status codes 1397 + break; 1398 + case '2XX': 1399 + responsesItems.push(response.schema); 1400 + break; 1401 + case '4XX': 1402 + case '5XX': 1403 + errorsItems.push(response.schema); 1404 + break; 1405 + case 'default': 1406 + // store default response to be evaluated last 1407 + defaultResponse = response; 1408 + break; 1409 + } 1410 + } 1411 + 1412 + // infer default response type 1413 + if (defaultResponse) { 1414 + let inferred = false; 1415 + 1416 + // assume default is intended for success if none exists yet 1417 + if (!responsesItems.length) { 1418 + responsesItems.push(defaultResponse.schema); 1419 + inferred = true; 1420 + } 1421 + 1422 + const description = ( 1423 + defaultResponse.schema.description ?? '' 1424 + ).toLocaleLowerCase(); 1425 + const $ref = (defaultResponse.schema.$ref ?? '').toLocaleLowerCase(); 1426 + 1427 + // TODO: parser - this could be rewritten using regular expressions 1428 + const successKeywords = ['success']; 1429 + if ( 1430 + successKeywords.some( 1431 + (keyword) => description.includes(keyword) || $ref.includes(keyword), 1432 + ) 1433 + ) { 1434 + responsesItems.push(defaultResponse.schema); 1435 + inferred = true; 1436 + } 1437 + 1438 + // TODO: parser - this could be rewritten using regular expressions 1439 + const errorKeywords = ['error', 'problem']; 1440 + if ( 1441 + errorKeywords.some( 1442 + (keyword) => description.includes(keyword) || $ref.includes(keyword), 1443 + ) 1444 + ) { 1445 + errorsItems.push(defaultResponse.schema); 1446 + inferred = true; 1447 + } 1448 + 1449 + // if no keyword match, assume default schema is intended for error 1450 + if (!inferred) { 1451 + errorsItems.push(defaultResponse.schema); 1452 + } 1453 + } 1454 + 1455 + addItemsToSchema({ 1456 + items: errorsItems, 1457 + schema: errors, 1458 + }); 1459 + 1460 + addItemsToSchema({ 1461 + items: responsesItems, 1462 + schema: responses, 1463 + }); 1464 + 1465 + if (errors.items) { 1466 + const deduplicatedSchema = deduplicateSchema({ 1467 + schema: errors, 1468 + }); 1469 + if (Object.keys(deduplicatedSchema).length) { 1470 + const identifier = context.file({ id: typesId })!.identifier({ 1471 + $ref: operationErrorRef({ id: operation.id }), 1472 + create: true, 1473 + namespace: 'type', 1474 + }); 1475 + const node = compiler.typeAliasDeclaration({ 1476 + exportType: true, 1477 + name: identifier.name, 1478 + type: schemaToType({ 1479 + context, 1480 + schema: deduplicatedSchema, 1481 + }), 1482 + }); 1483 + context.file({ id: typesId })!.add(node); 1484 + } 1485 + } 1486 + 1487 + if (responses.items) { 1488 + const deduplicatedSchema = deduplicateSchema({ 1489 + schema: responses, 1490 + }); 1491 + if (Object.keys(deduplicatedSchema).length) { 1492 + const identifier = context.file({ id: typesId })!.identifier({ 1493 + $ref: operationResponseRef({ id: operation.id }), 1494 + create: true, 1495 + namespace: 'type', 1496 + }); 1497 + const node = compiler.typeAliasDeclaration({ 1498 + exportType: true, 1499 + name: identifier.name, 1500 + type: schemaToType({ 1501 + context, 1502 + schema: deduplicatedSchema, 1503 + }), 1504 + }); 1505 + context.file({ id: typesId })!.add(node); 1506 + } 1507 + } 1508 + }; 1509 + 1510 + const operationToType = ({ 1511 + context, 1512 + operation, 1513 + }: { 1514 + context: IRContext; 1515 + operation: IROperationObject; 1516 + }) => { 1517 + operationToDataType({ 1518 + context, 1519 + operation, 1520 + }); 1521 + 1522 + operationToResponseTypes({ 1523 + context, 1524 + operation, 1525 + }); 1526 + }; 1527 + 1528 + const schemaToType = ({ 1529 + $ref, 1530 + context, 1531 + namespace = [], 1532 + schema, 1533 + }: { 1534 + $ref?: string; 1535 + context: IRContext; 1536 + namespace?: Array<ts.Statement>; 1537 + schema: IRSchemaObject; 1538 + }): ts.TypeNode => { 1539 + let type: ts.TypeNode | undefined; 1540 + 1541 + if (schema.$ref) { 1542 + const identifier = context.file({ id: typesId })!.identifier({ 1543 + $ref: schema.$ref, 1544 + create: true, 1545 + namespace: 'type', 1546 + }); 1547 + type = compiler.typeReferenceNode({ 1548 + typeName: identifier.name, 1549 + }); 1550 + } else if (schema.type) { 1551 + type = schemaTypeToIdentifier({ 1552 + $ref, 1553 + context, 1554 + namespace, 1555 + schema, 1556 + }); 1557 + } else if (schema.items) { 1558 + const itemTypes = schema.items.map((item) => 1559 + schemaToType({ 1560 + context, 1561 + namespace, 1562 + schema: item, 1563 + }), 1564 + ); 1565 + type = 1566 + schema.logicalOperator === 'and' 1567 + ? compiler.typeIntersectionNode({ types: itemTypes }) 1568 + : compiler.typeUnionNode({ types: itemTypes }); 1569 + } else { 1570 + // catch-all fallback for failed schemas 1571 + type = schemaTypeToIdentifier({ 1572 + context, 1573 + namespace, 1574 + schema: { 1575 + type: 'unknown', 1576 + }, 1577 + }); 1578 + } 1579 + 1580 + // emit nodes only if $ref points to a reusable component 1581 + if ($ref && isRefOpenApiComponent($ref)) { 1582 + // emit namespace if it has any members 1583 + if (namespace.length) { 1584 + const identifier = context.file({ id: typesId })!.identifier({ 1585 + $ref, 1586 + create: true, 1587 + namespace: 'value', 1588 + }); 1589 + const node = compiler.namespaceDeclaration({ 1590 + name: identifier.name, 1591 + statements: namespace, 1592 + }); 1593 + context.file({ id: typesId })!.add(node); 1594 + } 1595 + 1596 + // enum handler emits its own artifacts 1597 + if (schema.type !== 'enum') { 1598 + const identifier = context.file({ id: typesId })!.identifier({ 1599 + $ref, 1600 + create: true, 1601 + namespace: 'type', 1602 + }); 1603 + const node = compiler.typeAliasDeclaration({ 1604 + comment: parseSchemaJsDoc({ schema }), 1605 + exportType: true, 1606 + name: identifier.name, 1607 + type, 1608 + }); 1609 + context.file({ id: typesId })!.add(node); 1610 + } 1611 + } 1612 + 1613 + return type; 1614 + }; 1615 + 603 1616 export const generateTypes = async ({ 604 1617 client, 1618 + context, 605 1619 files, 606 1620 }: { 607 - client: Client; 1621 + client: Client | undefined; 1622 + context: IRContext | undefined; 608 1623 files: Files; 609 1624 }): Promise<void> => { 610 - const config = getConfig(); 1625 + if (client) { 1626 + const config = getConfig(); 1627 + 1628 + if (config.types.export) { 1629 + files.types = new TypeScriptFile({ 1630 + dir: config.output.path, 1631 + name: 'types.ts', 1632 + }); 1633 + } 1634 + 1635 + const onNode: TypesProps['onNode'] = (node) => { 1636 + files.types?.add(node); 1637 + }; 1638 + 1639 + for (const model of client.models) { 1640 + processModel({ client, model, onNode }); 1641 + } 1642 + 1643 + processServiceTypes({ client, onNode }); 1644 + return; 1645 + } 611 1646 612 - if (config.types.export) { 613 - files.types = new TypeScriptFile({ 614 - dir: config.output.path, 615 - name: 'types.ts', 616 - }); 1647 + if (!context) { 1648 + return; 617 1649 } 618 1650 619 - const onNode: TypesProps['onNode'] = (node) => { 620 - files.types?.add(node); 621 - }; 1651 + // TODO: parser - once types are a plugin, this logic can be simplified 1652 + if (!context.config.types.export) { 1653 + return; 1654 + } 1655 + 1656 + context.createFile({ 1657 + id: typesId, 1658 + path: 'types', 1659 + }); 1660 + 1661 + if (context.ir.components) { 1662 + for (const name in context.ir.components.schemas) { 1663 + const schema = context.ir.components.schemas[name]; 1664 + 1665 + schemaToType({ 1666 + $ref: `#/components/schemas/${name}`, 1667 + context, 1668 + schema, 1669 + }); 1670 + } 1671 + 1672 + for (const name in context.ir.components.parameters) { 1673 + const parameter = context.ir.components.parameters[name]; 622 1674 623 - for (const model of client.models) { 624 - processModel({ client, model, onNode }); 1675 + schemaToType({ 1676 + $ref: `#/components/parameters/${name}`, 1677 + context, 1678 + schema: parameter.schema, 1679 + }); 1680 + } 625 1681 } 626 1682 627 - processServiceTypes({ client, onNode }); 1683 + if (context.config.services.export || context.config.types.tree) { 1684 + for (const path in context.ir.paths) { 1685 + const pathItem = context.ir.paths[path as keyof IRPathsObject]; 1686 + 1687 + if (pathItem.delete) { 1688 + operationToType({ 1689 + context, 1690 + operation: pathItem.delete, 1691 + }); 1692 + } 1693 + 1694 + if (pathItem.get) { 1695 + operationToType({ 1696 + context, 1697 + operation: pathItem.get, 1698 + }); 1699 + } 1700 + 1701 + if (pathItem.head) { 1702 + operationToType({ 1703 + context, 1704 + operation: pathItem.head, 1705 + }); 1706 + } 1707 + 1708 + if (pathItem.options) { 1709 + operationToType({ 1710 + context, 1711 + operation: pathItem.options, 1712 + }); 1713 + } 1714 + 1715 + if (pathItem.patch) { 1716 + operationToType({ 1717 + context, 1718 + operation: pathItem.patch, 1719 + }); 1720 + } 1721 + 1722 + if (pathItem.post) { 1723 + operationToType({ 1724 + context, 1725 + operation: pathItem.post, 1726 + }); 1727 + } 1728 + 1729 + if (pathItem.put) { 1730 + operationToType({ 1731 + context, 1732 + operation: pathItem.put, 1733 + }); 1734 + } 1735 + 1736 + if (pathItem.trace) { 1737 + operationToType({ 1738 + context, 1739 + operation: pathItem.trace, 1740 + }); 1741 + } 1742 + } 1743 + 1744 + // TODO: parser - document removal of tree? migrate it? 1745 + } 628 1746 };
+51 -38
packages/openapi-ts/src/index.ts
··· 4 4 import { sync } from 'cross-spawn'; 5 5 6 6 import { generateOutput } from './generate/output'; 7 + import type { IRContext } from './ir/context'; 7 8 import { parse, parseExperimental } from './openApi'; 9 + import type { ParserConfig } from './openApi/config'; 10 + import { 11 + operationFilterFn, 12 + operationNameFn, 13 + operationParameterFilterFn, 14 + operationParameterNameFn, 15 + } from './openApi/config'; 8 16 import { defaultPluginConfigs } from './plugins'; 9 17 import type { Client } from './types/client'; 10 18 import type { ClientConfig, Config, UserConfig } from './types/config'; ··· 12 20 import { getConfig, isLegacyClient, setConfig } from './utils/config'; 13 21 import { getOpenApiSpec } from './utils/getOpenApiSpec'; 14 22 import { registerHandlebarTemplates } from './utils/handlebars'; 15 - import { 16 - operationFilterFn, 17 - operationNameFn, 18 - operationParameterFilterFn, 19 - operationParameterNameFn, 20 - } from './utils/parse'; 21 23 import { Performance, PerformanceReport } from './utils/performance'; 22 24 import { postProcessClient } from './utils/postprocess'; 23 25 ··· 339 341 >); 340 342 Performance.end('openapi'); 341 343 342 - if (config.experimental_parser) { 343 - Performance.start('experimental_parser'); 344 - parseExperimental({ 344 + let client: Client | undefined; 345 + let context: IRContext | undefined; 346 + 347 + Performance.start('parser'); 348 + const parserConfig: ParserConfig = { 349 + filterFn: { 350 + operation: operationFilterFn, 351 + operationParameter: operationParameterFilterFn, 352 + }, 353 + nameFn: { 354 + operation: operationNameFn, 355 + operationParameter: operationParameterNameFn, 356 + }, 357 + }; 358 + if (config.experimental_parser && !isLegacyClient(config)) { 359 + context = parseExperimental({ 360 + config, 361 + parserConfig, 345 362 spec: openApi, 346 363 }); 347 - Performance.end('experimental_parser'); 348 - } else { 349 - Performance.start('parser'); 364 + } 365 + 366 + if (!context) { 350 367 const parsed = parse({ 351 - config: { 352 - filterFn: { 353 - operation: operationFilterFn, 354 - operationParameter: operationParameterFilterFn, 355 - }, 356 - nameFn: { 357 - operation: operationNameFn, 358 - operationParameter: operationParameterNameFn, 359 - }, 360 - }, 361 368 openApi, 369 + parserConfig, 362 370 }); 363 - const client = postProcessClient(parsed); 364 - Performance.end('parser'); 371 + client = postProcessClient(parsed); 372 + } 373 + Performance.end('parser'); 365 374 366 - logClientMessage(); 375 + logClientMessage(); 367 376 368 - Performance.start('generator'); 369 - await generateOutput(openApi, client, templates); 370 - Performance.end('generator'); 377 + Performance.start('generator'); 378 + await generateOutput({ 379 + client, 380 + context, 381 + openApi, 382 + templates, 383 + }); 384 + Performance.end('generator'); 371 385 372 - Performance.start('postprocess'); 373 - if (!config.dryRun) { 374 - processOutput(); 386 + Performance.start('postprocess'); 387 + if (!config.dryRun) { 388 + processOutput(); 375 389 376 - console.log('✨ Done! Your client is located in:', config.output.path); 377 - } 378 - Performance.end('postprocess'); 390 + console.log('✨ Done! Your client is located in:', config.output.path); 391 + } 392 + Performance.end('postprocess'); 379 393 380 - return client; 381 - } 394 + return context || client; 382 395 }; 383 396 384 397 const clients: Array<Client> = []; ··· 386 399 const pClients = configs.map((config) => pCreateClient(config)); 387 400 for (const pClient of pClients) { 388 401 const client = await pClient(); 389 - if (client) { 402 + if (client && 'version' in client) { 390 403 clients.push(client); 391 404 } 392 405 } ··· 423 436 }; 424 437 425 438 export type { OpenApiV3_0_3 } from './openApi/3.0.3'; 426 - export type { OpenApiV3_1 } from './openApi/3.1'; 439 + export type { OpenApiV3_1_0 } from './openApi/3.1.0'; 427 440 export type { UserConfig } from './types/config';
+74
packages/openapi-ts/src/ir/context.ts
··· 1 + import path from 'node:path'; 2 + 3 + import { TypeScriptFile } from '../generate/files'; 4 + import type { ParserConfig } from '../openApi/config'; 5 + import type { Config } from '../types/config'; 6 + import type { Files } from '../types/utils'; 7 + import { resolveRef } from '../utils/ref'; 8 + import type { IR } from './ir'; 9 + 10 + interface ContextFile { 11 + /** 12 + * Unique file identifier. 13 + */ 14 + id: string; 15 + /** 16 + * Relative file path to the output path. 17 + * @example 18 + * 'bar/foo.ts' 19 + */ 20 + path: string; 21 + } 22 + 23 + export class IRContext<Spec extends Record<string, any> = any> { 24 + public config: Config; 25 + public files: Files; 26 + public ir: IR; 27 + public parserConfig: ParserConfig; 28 + public spec: Spec; 29 + 30 + constructor({ 31 + config, 32 + parserConfig, 33 + spec, 34 + }: { 35 + config: Config; 36 + parserConfig: ParserConfig; 37 + spec: Spec; 38 + }) { 39 + this.config = config; 40 + this.files = {}; 41 + this.ir = {}; 42 + this.parserConfig = parserConfig; 43 + this.spec = spec; 44 + } 45 + 46 + /** 47 + * Create and return a new TypeScript file. Also set the current file context 48 + * to the newly created file. 49 + */ 50 + public createFile(file: ContextFile): TypeScriptFile { 51 + const outputParts = file.path.split('/'); 52 + const outputDir = path.resolve( 53 + this.config.output.path, 54 + ...outputParts.slice(0, outputParts.length - 1), 55 + ); 56 + const createdFile = new TypeScriptFile({ 57 + dir: outputDir, 58 + name: `${outputParts[outputParts.length - 1]}.ts`, 59 + }); 60 + this.files[file.id] = createdFile; 61 + return createdFile; 62 + } 63 + 64 + public file({ id }: Pick<ContextFile, 'id'>): TypeScriptFile | undefined { 65 + return this.files[id]; 66 + } 67 + 68 + public resolveRef<T>($ref: string) { 69 + return resolveRef<T>({ 70 + $ref, 71 + spec: this.spec, 72 + }); 73 + } 74 + }
+129
packages/openapi-ts/src/ir/ir.d.ts
··· 1 + import type { JsonSchemaDraft2020_12 } from '../openApi/3.1.0/types/json-schema-draft-2020-12'; 2 + 3 + export interface IR { 4 + components?: IRComponentsObject; 5 + paths?: IRPathsObject; 6 + } 7 + 8 + interface IRComponentsObject { 9 + parameters?: Record<string, IRParameterObject>; 10 + schemas?: Record<string, IRSchemaObject>; 11 + } 12 + 13 + interface IRPathsObject { 14 + [path: `/${string}`]: IRPathItemObject; 15 + } 16 + 17 + interface IRPathItemObject { 18 + delete?: IROperationObject; 19 + get?: IROperationObject; 20 + head?: IROperationObject; 21 + options?: IROperationObject; 22 + patch?: IROperationObject; 23 + post?: IROperationObject; 24 + put?: IROperationObject; 25 + trace?: IROperationObject; 26 + } 27 + 28 + export interface IROperationObject { 29 + body?: IRBodyObject; 30 + deprecated?: boolean; 31 + description?: string; 32 + id: string; 33 + parameters?: IRParametersObject; 34 + responses?: IRResponsesObject; 35 + // TODO: parser - add more properties 36 + // security?: ReadonlyArray<SecurityRequirementObject>; 37 + // servers?: ReadonlyArray<ServerObject>; 38 + summary?: string; 39 + tags?: ReadonlyArray<string>; 40 + } 41 + 42 + export interface IRBodyObject { 43 + required?: boolean; 44 + schema: IRSchemaObject; 45 + } 46 + 47 + export interface IRParametersObject { 48 + cookie?: Record<string, IRParameterObject>; 49 + header?: Record<string, IRParameterObject>; 50 + path?: Record<string, IRParameterObject>; 51 + query?: Record<string, IRParameterObject>; 52 + } 53 + 54 + export interface IRParameterObject { 55 + /** 56 + * Endpoint parameters must specify their location. 57 + */ 58 + location: 'cookie' | 'header' | 'path' | 'query'; 59 + name: string; 60 + required?: boolean; 61 + schema: IRSchemaObject; 62 + } 63 + 64 + export interface IRResponsesObject { 65 + /** 66 + * Any {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#http-status-codes HTTP status code} can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character `X`. For example, `2XX` represents all response codes between `[200-299]`. Only the following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX`, and `5XX`. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. 67 + */ 68 + [statusCode: string]: IRResponseObject | undefined; 69 + /** 70 + * The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses. 71 + */ 72 + default?: IRResponseObject; 73 + } 74 + 75 + export interface IRResponseObject { 76 + // TODO: parser - handle headers, links, and possibly other media types? 77 + schema: IRSchemaObject; 78 + } 79 + 80 + export interface IRSchemaObject 81 + extends Pick< 82 + JsonSchemaDraft2020_12, 83 + '$ref' | 'const' | 'deprecated' | 'description' | 'required' | 'title' 84 + > { 85 + /** 86 + * If the schema is intended to be used as an object property, it can be 87 + * marked as read-only or write-only. 88 + */ 89 + accessScope?: 'read' | 'write'; 90 + /** 91 + * If type is `object`, `additionalProperties` can be used to either define 92 + * a schema for properties not included in `properties` or disallow such 93 + * properties altogether. 94 + */ 95 + additionalProperties?: IRSchemaObject | false; 96 + /** 97 + * Any string value is accepted as `format`. 98 + */ 99 + format?: JsonSchemaDraft2020_12['format'] | 'binary' | 'integer'; 100 + /** 101 + * If schema resolves into multiple items instead of a simple `type`, they 102 + * will be included in `items` array. 103 + */ 104 + items?: ReadonlyArray<IRSchemaObject>; 105 + /** 106 + * When resolving a list of items, we need to know the relationship between 107 + * them. `logicalOperator` specifies this logical relationship. 108 + * @default 'or' 109 + */ 110 + logicalOperator?: 'and' | 'or'; 111 + /** 112 + * When type is `object`, `properties` will contain a map of its properties. 113 + */ 114 + properties?: Record<string, IRSchemaObject>; 115 + /** 116 + * Each schema eventually resolves into `type`. 117 + */ 118 + type?: 119 + | 'array' 120 + | 'boolean' 121 + | 'enum' 122 + | 'null' 123 + | 'number' 124 + | 'object' 125 + | 'string' 126 + | 'tuple' 127 + | 'unknown' 128 + | 'void'; 129 + }
+35
packages/openapi-ts/src/ir/parameter.ts
··· 1 + import type { IRParametersObject } from './ir'; 2 + 3 + export const hasParametersObjectRequired = ( 4 + parameters: IRParametersObject | undefined, 5 + ): boolean => { 6 + if (!parameters) { 7 + return false; 8 + } 9 + 10 + for (const name in parameters.cookie) { 11 + if (parameters.cookie[name].required) { 12 + return true; 13 + } 14 + } 15 + 16 + for (const name in parameters.header) { 17 + if (parameters.header[name].required) { 18 + return true; 19 + } 20 + } 21 + 22 + for (const name in parameters.path) { 23 + if (parameters.path[name].required) { 24 + return true; 25 + } 26 + } 27 + 28 + for (const name in parameters.query) { 29 + if (parameters.query[name].required) { 30 + return true; 31 + } 32 + } 33 + 34 + return false; 35 + };
+25
packages/openapi-ts/src/ir/utils.ts
··· 1 + import type { IRSchemaObject } from './ir'; 2 + 3 + /** 4 + * Simply adds `items` to the schema. Also handles setting the logical operator 5 + * and avoids setting it for a single item or tuples. 6 + */ 7 + export const addItemsToSchema = ({ 8 + items, 9 + schema, 10 + }: { 11 + items: Array<IRSchemaObject>; 12 + schema: IRSchemaObject; 13 + }) => { 14 + if (!items.length) { 15 + return; 16 + } 17 + 18 + schema.items = items; 19 + 20 + if (items.length === 1 || schema.type === 'tuple') { 21 + return; 22 + } 23 + 24 + schema.logicalOperator = 'or'; 25 + };
+3 -2
packages/openapi-ts/src/openApi/3.0.3/parser/index.ts
··· 1 + import type { IRContext } from '../../../ir/context'; 1 2 import type { OpenApiV3_0_3 } from '../types/spec'; 2 3 3 - export const parseV3_0_3 = (spec: OpenApiV3_0_3) => { 4 + export const parseV3_0_3 = (context: IRContext<OpenApiV3_0_3>): undefined => { 4 5 // TODO 5 - console.log(spec); 6 + console.log(context.spec); 6 7 };
packages/openapi-ts/src/openApi/3.0.3/types/spec.ts packages/openapi-ts/src/openApi/3.0.3/types/spec.d.ts
+2
packages/openapi-ts/src/openApi/3.1.0/index.ts
··· 1 + export { parseV3_1_0 } from './parser'; 2 + export type { OpenApiV3_1_0 } from './types/spec';
+217
packages/openapi-ts/src/openApi/3.1.0/parser/index.ts
··· 1 + import type { IRContext } from '../../../ir/context'; 2 + import type { 3 + OpenApiV3_1_0, 4 + ParameterObject, 5 + PathItemObject, 6 + PathsObject, 7 + } from '../types/spec'; 8 + import { parseOperation } from './operation'; 9 + import { 10 + mergeParametersObjects, 11 + parametersArrayToObject, 12 + parseParameter, 13 + } from './parameter'; 14 + import { parseSchema } from './schema'; 15 + 16 + export const parseV3_1_0 = (context: IRContext<OpenApiV3_1_0>) => { 17 + const operationIds = new Map<string, string>(); 18 + 19 + for (const path in context.spec.paths) { 20 + const pathItem = context.spec.paths[path as keyof PathsObject]; 21 + 22 + const finalPathItem = pathItem.$ref 23 + ? { 24 + ...context.resolveRef<PathItemObject>(pathItem.$ref), 25 + ...pathItem, 26 + } 27 + : pathItem; 28 + 29 + const operationArgs: Omit<Parameters<typeof parseOperation>[0], 'method'> = 30 + { 31 + context, 32 + operation: { 33 + description: finalPathItem.description, 34 + id: '', 35 + parameters: parametersArrayToObject({ 36 + context, 37 + parameters: finalPathItem.parameters, 38 + }), 39 + servers: finalPathItem.servers, 40 + summary: finalPathItem.summary, 41 + }, 42 + operationIds, 43 + path: path as keyof PathsObject, 44 + }; 45 + 46 + if (finalPathItem.delete) { 47 + parseOperation({ 48 + ...operationArgs, 49 + method: 'delete', 50 + operation: { 51 + ...operationArgs.operation, 52 + ...finalPathItem.delete, 53 + parameters: mergeParametersObjects({ 54 + source: parametersArrayToObject({ 55 + context, 56 + parameters: finalPathItem.delete.parameters, 57 + }), 58 + target: operationArgs.operation.parameters, 59 + }), 60 + }, 61 + }); 62 + } 63 + 64 + if (finalPathItem.get) { 65 + parseOperation({ 66 + ...operationArgs, 67 + method: 'get', 68 + operation: { 69 + ...operationArgs.operation, 70 + ...finalPathItem.get, 71 + parameters: mergeParametersObjects({ 72 + source: parametersArrayToObject({ 73 + context, 74 + parameters: finalPathItem.get.parameters, 75 + }), 76 + target: operationArgs.operation.parameters, 77 + }), 78 + }, 79 + }); 80 + } 81 + 82 + if (finalPathItem.head) { 83 + parseOperation({ 84 + ...operationArgs, 85 + method: 'head', 86 + operation: { 87 + ...operationArgs.operation, 88 + ...finalPathItem.head, 89 + parameters: mergeParametersObjects({ 90 + source: parametersArrayToObject({ 91 + context, 92 + parameters: finalPathItem.head.parameters, 93 + }), 94 + target: operationArgs.operation.parameters, 95 + }), 96 + }, 97 + }); 98 + } 99 + 100 + if (finalPathItem.options) { 101 + parseOperation({ 102 + ...operationArgs, 103 + method: 'options', 104 + operation: { 105 + ...operationArgs.operation, 106 + ...finalPathItem.options, 107 + parameters: mergeParametersObjects({ 108 + source: parametersArrayToObject({ 109 + context, 110 + parameters: finalPathItem.options.parameters, 111 + }), 112 + target: operationArgs.operation.parameters, 113 + }), 114 + }, 115 + }); 116 + } 117 + 118 + if (finalPathItem.patch) { 119 + parseOperation({ 120 + ...operationArgs, 121 + method: 'patch', 122 + operation: { 123 + ...operationArgs.operation, 124 + ...finalPathItem.patch, 125 + parameters: mergeParametersObjects({ 126 + source: parametersArrayToObject({ 127 + context, 128 + parameters: finalPathItem.patch.parameters, 129 + }), 130 + target: operationArgs.operation.parameters, 131 + }), 132 + }, 133 + }); 134 + } 135 + 136 + if (finalPathItem.post) { 137 + parseOperation({ 138 + ...operationArgs, 139 + method: 'post', 140 + operation: { 141 + ...operationArgs.operation, 142 + ...finalPathItem.post, 143 + parameters: mergeParametersObjects({ 144 + source: parametersArrayToObject({ 145 + context, 146 + parameters: finalPathItem.post.parameters, 147 + }), 148 + target: operationArgs.operation.parameters, 149 + }), 150 + }, 151 + }); 152 + } 153 + 154 + if (finalPathItem.put) { 155 + parseOperation({ 156 + ...operationArgs, 157 + method: 'put', 158 + operation: { 159 + ...operationArgs.operation, 160 + ...finalPathItem.put, 161 + parameters: mergeParametersObjects({ 162 + source: parametersArrayToObject({ 163 + context, 164 + parameters: finalPathItem.put.parameters, 165 + }), 166 + target: operationArgs.operation.parameters, 167 + }), 168 + }, 169 + }); 170 + } 171 + 172 + if (finalPathItem.trace) { 173 + parseOperation({ 174 + ...operationArgs, 175 + method: 'trace', 176 + operation: { 177 + ...operationArgs.operation, 178 + ...finalPathItem.trace, 179 + parameters: mergeParametersObjects({ 180 + source: parametersArrayToObject({ 181 + context, 182 + parameters: finalPathItem.trace.parameters, 183 + }), 184 + target: operationArgs.operation.parameters, 185 + }), 186 + }, 187 + }); 188 + } 189 + } 190 + 191 + // TODO: parser - handle more component types, old parser handles only parameters and schemas 192 + if (context.spec.components) { 193 + for (const name in context.spec.components.parameters) { 194 + const parameterOrReference = context.spec.components.parameters[name]; 195 + const parameter = 196 + '$ref' in parameterOrReference 197 + ? context.resolveRef<ParameterObject>(parameterOrReference.$ref) 198 + : parameterOrReference; 199 + 200 + parseParameter({ 201 + context, 202 + name, 203 + parameter, 204 + }); 205 + } 206 + 207 + for (const name in context.spec.components.schemas) { 208 + const schema = context.spec.components.schemas[name]; 209 + 210 + parseSchema({ 211 + context, 212 + name, 213 + schema, 214 + }); 215 + } 216 + } 217 + };
+40
packages/openapi-ts/src/openApi/3.1.0/parser/mediaType.ts
··· 1 + import type { MediaTypeObject, SchemaObject } from '../types/spec'; 2 + 3 + const SUPPORTED_MEDIA_TYPES = [ 4 + 'application/json-patch+json', 5 + 'application/json', 6 + 'application/ld+json', 7 + 'application/x-www-form-urlencoded', 8 + 'audio/*', 9 + 'multipart/batch', 10 + 'multipart/form-data', 11 + 'multipart/mixed', 12 + 'multipart/related', 13 + 'text/json', 14 + 'text/plain', 15 + 'video/*', 16 + ] as const; 17 + 18 + type MediaType = (typeof SUPPORTED_MEDIA_TYPES)[number]; 19 + 20 + interface Content { 21 + mediaType: MediaType; 22 + schema: SchemaObject | undefined; 23 + } 24 + 25 + export const getMediaTypeSchema = ({ 26 + content, 27 + }: { 28 + content: Record<string, MediaTypeObject> | undefined; 29 + }): Content | undefined => { 30 + for (const rawMediaType in content) { 31 + const mediaTypeContent = content[rawMediaType]; 32 + const mediaType: MediaType = rawMediaType.split(';')[0].trim() as MediaType; 33 + if (SUPPORTED_MEDIA_TYPES.includes(mediaType)) { 34 + return { 35 + mediaType, 36 + schema: mediaTypeContent.schema, 37 + }; 38 + } 39 + } 40 + };
+199
packages/openapi-ts/src/openApi/3.1.0/parser/operation.ts
··· 1 + import type { IRContext } from '../../../ir/context'; 2 + import type { IROperationObject, IRPathsObject } from '../../../ir/ir'; 3 + import type { 4 + OperationObject, 5 + PathItemObject, 6 + RequestBodyObject, 7 + ResponseObject, 8 + } from '../types/spec'; 9 + import { getMediaTypeSchema } from './mediaType'; 10 + import { schemaToIrSchema } from './schema'; 11 + 12 + interface Operation 13 + extends Omit<OperationObject, 'parameters'>, 14 + Pick<IROperationObject, 'id' | 'parameters'> {} 15 + 16 + const parseOperationJsDoc = ({ 17 + irOperation, 18 + operation, 19 + }: { 20 + irOperation: IROperationObject; 21 + operation: Operation; 22 + }) => { 23 + if (operation.deprecated !== undefined) { 24 + irOperation.deprecated = operation.deprecated; 25 + } 26 + 27 + if (operation.description) { 28 + irOperation.description = operation.description; 29 + } 30 + 31 + if (operation.summary) { 32 + irOperation.summary = operation.summary; 33 + } 34 + 35 + if (operation.tags && operation.tags.length) { 36 + irOperation.tags = operation.tags; 37 + } 38 + }; 39 + 40 + const initIrOperation = ({ 41 + operation, 42 + }: { 43 + operation: Operation; 44 + }): IROperationObject => { 45 + const irOperation: IROperationObject = { 46 + id: operation.id, 47 + }; 48 + 49 + parseOperationJsDoc({ 50 + irOperation, 51 + operation, 52 + }); 53 + 54 + return irOperation; 55 + }; 56 + 57 + const operationToIrOperation = ({ 58 + context, 59 + operation, 60 + }: { 61 + context: IRContext; 62 + operation: Operation; 63 + }): IROperationObject => { 64 + const irOperation = initIrOperation({ operation }); 65 + 66 + if (operation.parameters) { 67 + irOperation.parameters = operation.parameters; 68 + } 69 + 70 + if (operation.requestBody) { 71 + const requestBodyObject = 72 + '$ref' in operation.requestBody 73 + ? context.resolveRef<RequestBodyObject>(operation.requestBody.$ref) 74 + : operation.requestBody; 75 + const content = getMediaTypeSchema({ 76 + content: requestBodyObject.content, 77 + }); 78 + if (content) { 79 + irOperation.body = { 80 + schema: schemaToIrSchema({ 81 + context, 82 + schema: { 83 + description: requestBodyObject.description, 84 + ...content.schema, 85 + }, 86 + }), 87 + }; 88 + 89 + if (requestBodyObject.required) { 90 + irOperation.body.required = requestBodyObject.required; 91 + } 92 + } 93 + } 94 + 95 + for (const name in operation.responses) { 96 + const response = operation.responses[name]!; 97 + const responseObject = 98 + '$ref' in response 99 + ? context.resolveRef<ResponseObject>(response.$ref) 100 + : response; 101 + const content = getMediaTypeSchema({ 102 + content: responseObject.content, 103 + }); 104 + if (content) { 105 + if (!irOperation.responses) { 106 + irOperation.responses = {}; 107 + } 108 + 109 + irOperation.responses[name] = { 110 + schema: schemaToIrSchema({ 111 + context, 112 + schema: { 113 + description: responseObject.description, 114 + ...content.schema, 115 + }, 116 + }), 117 + }; 118 + } else if (name === '204') { 119 + if (!irOperation.responses) { 120 + irOperation.responses = {}; 121 + } 122 + 123 + irOperation.responses[name] = { 124 + schema: { 125 + description: responseObject.description, 126 + type: 'void', 127 + }, 128 + }; 129 + } 130 + } 131 + 132 + // TODO: parser - handle security 133 + // baz: operation.security 134 + 135 + // TODO: parser - handle servers 136 + // qux: operation.servers 137 + 138 + return irOperation; 139 + }; 140 + 141 + export const parseOperation = ({ 142 + context, 143 + method, 144 + operation, 145 + operationIds, 146 + path, 147 + }: { 148 + context: IRContext; 149 + method: Extract< 150 + keyof PathItemObject, 151 + 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace' 152 + >; 153 + operation: Operation; 154 + operationIds: Map<string, string>; 155 + path: keyof IRPathsObject; 156 + }) => { 157 + const operationKey = `${method.toUpperCase()} ${path}`; 158 + 159 + // TODO: parser - move services to plugin, cleaner syntax 160 + if ( 161 + !context.parserConfig.filterFn.operation({ 162 + config: context.config, 163 + operationKey, 164 + }) 165 + ) { 166 + return; 167 + } 168 + 169 + // TODO: parser - support throw on duplicate 170 + if (operation.operationId) { 171 + if (operationIds.has(operation.operationId)) { 172 + console.warn( 173 + `❗️ Duplicate operationId: ${operation.operationId} in ${operationKey}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`, 174 + ); 175 + } else { 176 + operationIds.set(operation.operationId, operationKey); 177 + } 178 + } 179 + 180 + if (!context.ir.paths) { 181 + context.ir.paths = {}; 182 + } 183 + 184 + if (!context.ir.paths[path]) { 185 + context.ir.paths[path] = {}; 186 + } 187 + 188 + operation.id = context.parserConfig.nameFn.operation({ 189 + config: context.config, 190 + method, 191 + operationId: operation.operationId, 192 + path, 193 + }); 194 + 195 + context.ir.paths[path][method] = operationToIrOperation({ 196 + context, 197 + operation, 198 + }); 199 + };
+163
packages/openapi-ts/src/openApi/3.1.0/parser/parameter.ts
··· 1 + import type { IRContext } from '../../../ir/context'; 2 + import type { IRParameterObject, IRParametersObject } from '../../../ir/ir'; 3 + import type { ParameterObject, ReferenceObject } from '../types/spec'; 4 + import { getMediaTypeSchema } from './mediaType'; 5 + import { schemaToIrSchema } from './schema'; 6 + 7 + export const parametersArrayToObject = ({ 8 + context, 9 + parameters, 10 + }: { 11 + context: IRContext; 12 + parameters?: ReadonlyArray<ParameterObject | ReferenceObject>; 13 + }): IRParametersObject | undefined => { 14 + if (!parameters || !Object.keys(parameters).length) { 15 + return; 16 + } 17 + 18 + const parametersObject: IRParametersObject = {}; 19 + 20 + for (const parameterOrReference of parameters) { 21 + const parameter = 22 + '$ref' in parameterOrReference 23 + ? context.resolveRef<ParameterObject>(parameterOrReference.$ref) 24 + : parameterOrReference; 25 + 26 + if (!parametersObject[parameter.in]) { 27 + parametersObject[parameter.in] = {}; 28 + } 29 + 30 + parametersObject[parameter.in]![parameter.name] = parameterToIrParameter({ 31 + context, 32 + parameter, 33 + }); 34 + } 35 + 36 + return parametersObject; 37 + }; 38 + 39 + export const mergeParametersObjects = ({ 40 + source, 41 + target, 42 + }: { 43 + source: IRParametersObject | undefined; 44 + target: IRParametersObject | undefined; 45 + }): IRParametersObject | undefined => { 46 + const result = { ...target }; 47 + 48 + if (source) { 49 + if (source.cookie) { 50 + if (result.cookie) { 51 + result.cookie = { 52 + ...result.cookie, 53 + ...source.cookie, 54 + }; 55 + } else { 56 + result.cookie = source.cookie; 57 + } 58 + } 59 + 60 + if (source.header) { 61 + if (result.header) { 62 + result.header = { 63 + ...result.header, 64 + ...source.header, 65 + }; 66 + } else { 67 + result.header = source.header; 68 + } 69 + } 70 + 71 + if (source.path) { 72 + if (result.path) { 73 + result.path = { 74 + ...result.path, 75 + ...source.path, 76 + }; 77 + } else { 78 + result.path = source.path; 79 + } 80 + } 81 + 82 + if (source.query) { 83 + if (result.query) { 84 + result.query = { 85 + ...result.query, 86 + ...source.query, 87 + }; 88 + } else { 89 + result.query = source.query; 90 + } 91 + } 92 + } 93 + 94 + if (!Object.keys(result).length) { 95 + return; 96 + } 97 + 98 + return result; 99 + }; 100 + 101 + const parameterToIrParameter = ({ 102 + context, 103 + parameter, 104 + }: { 105 + context: IRContext; 106 + parameter: ParameterObject; 107 + }): IRParameterObject => { 108 + // TODO: parser - fix 109 + let schema = parameter.schema; 110 + 111 + if (!schema) { 112 + const content = getMediaTypeSchema({ 113 + content: parameter.content, 114 + }); 115 + if (content) { 116 + schema = content.schema; 117 + } 118 + } 119 + 120 + const irSchema = schemaToIrSchema({ 121 + context, 122 + schema: { 123 + deprecated: parameter.deprecated, 124 + description: parameter.description, 125 + ...schema, 126 + }, 127 + }); 128 + 129 + const irParameter: IRParameterObject = { 130 + location: parameter.in, 131 + name: parameter.name, 132 + schema: irSchema, 133 + }; 134 + 135 + if (parameter.required) { 136 + irParameter.required = parameter.required; 137 + } 138 + 139 + return irParameter; 140 + }; 141 + 142 + export const parseParameter = ({ 143 + context, 144 + name, 145 + parameter, 146 + }: { 147 + context: IRContext; 148 + name: string; 149 + parameter: ParameterObject; 150 + }) => { 151 + if (!context.ir.components) { 152 + context.ir.components = {}; 153 + } 154 + 155 + if (!context.ir.components.parameters) { 156 + context.ir.components.parameters = {}; 157 + } 158 + 159 + context.ir.components.parameters[name] = parameterToIrParameter({ 160 + context, 161 + parameter, 162 + }); 163 + };
+787
packages/openapi-ts/src/openApi/3.1.0/parser/schema.ts
··· 1 + import type { IRContext } from '../../../ir/context'; 2 + import type { IRSchemaObject } from '../../../ir/ir'; 3 + import { addItemsToSchema } from '../../../ir/utils'; 4 + import type { SchemaObject } from '../types/spec'; 5 + 6 + type SchemaWithRequired<K extends keyof Required<SchemaObject>> = Omit< 7 + SchemaObject, 8 + K 9 + > & 10 + Pick<Required<SchemaObject>, K>; 11 + 12 + type SchemaType = Extract<Required<SchemaObject>['type'], string>; 13 + 14 + const getSchemaTypes = ({ 15 + schema, 16 + }: { 17 + schema: SchemaObject; 18 + }): ReadonlyArray<SchemaType> => 19 + typeof schema.type === 'string' ? [schema.type] : schema.type ?? []; 20 + 21 + const parseSchemaMeta = ({ 22 + irSchema, 23 + schema, 24 + }: { 25 + irSchema: IRSchemaObject; 26 + schema: SchemaObject; 27 + }) => { 28 + if (schema.const !== undefined) { 29 + irSchema.const = schema.const; 30 + 31 + // try to infer schema type 32 + if (!schema.type) { 33 + if (schema.const === null) { 34 + irSchema.type = 'null'; 35 + } else { 36 + switch (typeof schema.const) { 37 + case 'bigint': 38 + case 'number': 39 + irSchema.type = 'number'; 40 + break; 41 + case 'boolean': 42 + irSchema.type = 'boolean'; 43 + break; 44 + case 'string': 45 + irSchema.type = 'string'; 46 + break; 47 + } 48 + } 49 + } 50 + } 51 + 52 + if (schema.format) { 53 + irSchema.format = schema.format; 54 + } 55 + 56 + if (schema.readOnly) { 57 + irSchema.accessScope = 'read'; 58 + } else if (schema.writeOnly) { 59 + irSchema.accessScope = 'write'; 60 + } 61 + 62 + if (schema.title) { 63 + irSchema.title = schema.title; 64 + } 65 + }; 66 + 67 + const parseArray = ({ 68 + context, 69 + irSchema = {}, 70 + schema, 71 + }: { 72 + context: IRContext; 73 + irSchema?: IRSchemaObject; 74 + schema: SchemaObject; 75 + }): IRSchemaObject => { 76 + if ( 77 + (schema.prefixItems && schema.prefixItems.length) || 78 + (schema.maxItems && schema.maxItems === schema.minItems) 79 + ) { 80 + irSchema.type = 'tuple'; 81 + } else { 82 + irSchema.type = 'array'; 83 + } 84 + 85 + let schemaItems: Array<IRSchemaObject> = []; 86 + 87 + for (const item of schema.prefixItems ?? []) { 88 + schemaItems.push( 89 + schemaToIrSchema({ 90 + context, 91 + schema: item, 92 + }), 93 + ); 94 + } 95 + 96 + if (schema.items) { 97 + const isComposedSchema = Boolean( 98 + schema.items.allOf || schema.items.anyOf || schema.items.oneOf, 99 + ); 100 + const irItemsSchema = schemaToIrSchema({ 101 + context, 102 + schema: schema.items, 103 + }); 104 + 105 + if ( 106 + !schemaItems.length && 107 + schema.maxItems && 108 + schema.maxItems === schema.minItems 109 + ) { 110 + schemaItems = Array(schema.maxItems).fill(irItemsSchema); 111 + } else { 112 + if (isComposedSchema) { 113 + // bring composition up to avoid incorrectly nested arrays 114 + irSchema = { 115 + ...irSchema, 116 + ...irItemsSchema, 117 + }; 118 + } else { 119 + schemaItems.push(irItemsSchema); 120 + } 121 + } 122 + } 123 + 124 + addItemsToSchema({ 125 + items: schemaItems, 126 + schema: irSchema, 127 + }); 128 + 129 + return irSchema; 130 + }; 131 + 132 + const parseBoolean = ({ 133 + irSchema = {}, 134 + }: { 135 + context: IRContext; 136 + irSchema?: IRSchemaObject; 137 + schema: SchemaObject; 138 + }): IRSchemaObject => { 139 + irSchema.type = 'boolean'; 140 + 141 + return irSchema; 142 + }; 143 + 144 + const parseNull = ({ 145 + irSchema = {}, 146 + }: { 147 + context: IRContext; 148 + irSchema?: IRSchemaObject; 149 + schema: SchemaObject; 150 + }) => { 151 + irSchema.type = 'null'; 152 + 153 + return irSchema; 154 + }; 155 + 156 + const parseNumber = ({ 157 + irSchema = {}, 158 + }: { 159 + context: IRContext; 160 + irSchema?: IRSchemaObject; 161 + schema: SchemaObject; 162 + }): IRSchemaObject => { 163 + irSchema.type = 'number'; 164 + 165 + return irSchema; 166 + }; 167 + 168 + const parseObject = ({ 169 + context, 170 + irSchema = {}, 171 + schema, 172 + }: { 173 + context: IRContext; 174 + irSchema?: IRSchemaObject; 175 + schema: SchemaObject; 176 + }): IRSchemaObject => { 177 + irSchema.type = 'object'; 178 + 179 + const schemaProperties: Record<string, IRSchemaObject> = {}; 180 + 181 + for (const name in schema.properties) { 182 + const property = schema.properties[name]; 183 + if (typeof property === 'boolean') { 184 + // TODO: parser - handle boolean properties 185 + } else { 186 + schemaProperties[name] = schemaToIrSchema({ 187 + context, 188 + schema: property, 189 + }); 190 + } 191 + } 192 + 193 + if (Object.keys(schemaProperties).length) { 194 + irSchema.properties = schemaProperties; 195 + } 196 + 197 + if (schema.additionalProperties !== undefined) { 198 + if (typeof schema.additionalProperties === 'boolean') { 199 + if (schema.additionalProperties) { 200 + // no need to add "any" additional properties if there are no defined properties 201 + if (irSchema.properties) { 202 + irSchema.additionalProperties = { 203 + type: 'unknown', 204 + }; 205 + } 206 + } else { 207 + // TODO: parser - handle additional properties: false 208 + } 209 + } else { 210 + const irAdditionalPropertiesSchema = schemaToIrSchema({ 211 + context, 212 + schema: schema.additionalProperties, 213 + }); 214 + // no need to add "any" additional properties if there are no defined properties 215 + if ( 216 + irSchema.properties || 217 + irAdditionalPropertiesSchema.type !== 'unknown' 218 + ) { 219 + irSchema.additionalProperties = irAdditionalPropertiesSchema; 220 + } 221 + } 222 + } 223 + 224 + if (schema.required) { 225 + irSchema.required = schema.required; 226 + } 227 + 228 + return irSchema; 229 + }; 230 + 231 + const parseString = ({ 232 + irSchema = {}, 233 + }: { 234 + context: IRContext; 235 + irSchema?: IRSchemaObject; 236 + schema: SchemaObject; 237 + }): IRSchemaObject => { 238 + irSchema.type = 'string'; 239 + 240 + return irSchema; 241 + }; 242 + 243 + const parseSchemaJsDoc = ({ 244 + irSchema, 245 + schema, 246 + }: { 247 + irSchema: IRSchemaObject; 248 + schema: SchemaObject; 249 + }) => { 250 + if (schema.deprecated !== undefined) { 251 + irSchema.deprecated = schema.deprecated; 252 + } 253 + 254 + if (schema.description) { 255 + irSchema.description = schema.description; 256 + } 257 + }; 258 + 259 + const initIrSchema = ({ schema }: { schema: SchemaObject }): IRSchemaObject => { 260 + const irSchema: IRSchemaObject = {}; 261 + 262 + parseSchemaJsDoc({ 263 + irSchema, 264 + schema, 265 + }); 266 + 267 + return irSchema; 268 + }; 269 + 270 + const parseAllOf = ({ 271 + context, 272 + schema, 273 + }: { 274 + context: IRContext; 275 + schema: SchemaWithRequired<'allOf'>; 276 + }): IRSchemaObject => { 277 + let irSchema = initIrSchema({ schema }); 278 + 279 + const schemaItems: Array<IRSchemaObject> = []; 280 + const schemaTypes = getSchemaTypes({ schema }); 281 + 282 + const compositionSchemas = schema.allOf; 283 + 284 + for (const compositionSchema of compositionSchemas) { 285 + schemaItems.push( 286 + schemaToIrSchema({ 287 + context, 288 + schema: compositionSchema, 289 + }), 290 + ); 291 + } 292 + 293 + if (schemaTypes.includes('object')) { 294 + const irObjectSchema = parseOneType({ 295 + context, 296 + schema: { 297 + ...schema, 298 + type: 'object', 299 + }, 300 + }); 301 + 302 + if (irObjectSchema.properties) { 303 + for (const requiredProperty of irObjectSchema.required ?? []) { 304 + if (!irObjectSchema.properties[requiredProperty]) { 305 + for (const compositionSchema of compositionSchemas) { 306 + // TODO: parser - this could be probably resolved more accurately 307 + const finalCompositionSchema = compositionSchema.$ref 308 + ? context.resolveRef<SchemaObject>(compositionSchema.$ref) 309 + : compositionSchema; 310 + 311 + if ( 312 + getSchemaTypes({ schema: finalCompositionSchema }).includes( 313 + 'object', 314 + ) 315 + ) { 316 + const irCompositionSchema = parseOneType({ 317 + context, 318 + schema: { 319 + ...finalCompositionSchema, 320 + type: 'object', 321 + }, 322 + }); 323 + 324 + if (irCompositionSchema.properties?.[requiredProperty]) { 325 + irObjectSchema.properties[requiredProperty] = 326 + irCompositionSchema.properties[requiredProperty]; 327 + break; 328 + } 329 + } 330 + } 331 + } 332 + } 333 + schemaItems.push(irObjectSchema); 334 + } 335 + } 336 + 337 + if (schemaItems.length) { 338 + irSchema.items = schemaItems; 339 + irSchema.logicalOperator = 'and'; 340 + } 341 + 342 + if (schemaTypes.includes('null')) { 343 + // nest composition to avoid producing an intersection with null 344 + const nestedItems: Array<IRSchemaObject> = [ 345 + { 346 + type: 'null', 347 + }, 348 + ]; 349 + 350 + if (schemaItems.length) { 351 + nestedItems.unshift(irSchema); 352 + } 353 + 354 + irSchema = { 355 + items: nestedItems, 356 + logicalOperator: 'or', 357 + }; 358 + } 359 + 360 + if (schema.discriminator) { 361 + // TODO: parser - support discriminator 362 + // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf 363 + } 364 + 365 + return irSchema; 366 + }; 367 + 368 + const parseAnyOf = ({ 369 + context, 370 + schema, 371 + }: { 372 + context: IRContext; 373 + schema: SchemaWithRequired<'anyOf'>; 374 + }): IRSchemaObject => { 375 + let irSchema = initIrSchema({ schema }); 376 + 377 + const schemaItems: Array<IRSchemaObject> = []; 378 + const schemaTypes = getSchemaTypes({ schema }); 379 + 380 + for (const anyOf of schema.anyOf) { 381 + schemaItems.push( 382 + schemaToIrSchema({ 383 + context, 384 + schema: anyOf, 385 + }), 386 + ); 387 + } 388 + 389 + if (schemaTypes.includes('null')) { 390 + schemaItems.push({ type: 'null' }); 391 + } 392 + 393 + addItemsToSchema({ 394 + items: schemaItems, 395 + schema: irSchema, 396 + }); 397 + 398 + if (schemaTypes.includes('object')) { 399 + // nest composition to avoid producing a union with object properties 400 + const irObjectSchema = parseOneType({ 401 + context, 402 + schema: { 403 + ...schema, 404 + type: 'object', 405 + }, 406 + }); 407 + 408 + if (irObjectSchema.properties) { 409 + irSchema = { 410 + items: [irSchema, irObjectSchema], 411 + logicalOperator: 'and', 412 + }; 413 + } 414 + } 415 + 416 + if (schema.discriminator) { 417 + // TODO: parser - support discriminator 418 + // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf 419 + } 420 + 421 + return irSchema; 422 + }; 423 + 424 + const parseEnum = ({ 425 + context, 426 + schema, 427 + }: { 428 + context: IRContext; 429 + schema: SchemaWithRequired<'enum'>; 430 + }): IRSchemaObject => { 431 + const irSchema = initIrSchema({ schema }); 432 + 433 + irSchema.type = 'enum'; 434 + 435 + const schemaItems: Array<IRSchemaObject> = []; 436 + 437 + for (const [index, enumValue] of schema.enum.entries()) { 438 + const typeOfEnumValue = typeof enumValue; 439 + if ( 440 + typeOfEnumValue === 'string' || 441 + typeOfEnumValue === 'number' || 442 + typeOfEnumValue === 'boolean' 443 + ) { 444 + schemaItems.push( 445 + parseOneType({ 446 + context, 447 + schema: { 448 + const: enumValue, 449 + description: schema['x-enum-descriptions']?.[index], 450 + title: 451 + schema['x-enum-varnames']?.[index] ?? 452 + schema['x-enumNames']?.[index], 453 + type: typeOfEnumValue, 454 + }, 455 + }), 456 + ); 457 + } else { 458 + console.warn( 459 + '🚨', 460 + `unhandled "${typeOfEnumValue}" typeof value "${enumValue}" for enum`, 461 + schema.enum, 462 + ); 463 + } 464 + } 465 + 466 + addItemsToSchema({ 467 + items: schemaItems, 468 + schema: irSchema, 469 + }); 470 + 471 + return irSchema; 472 + }; 473 + 474 + const parseOneOf = ({ 475 + context, 476 + schema, 477 + }: { 478 + context: IRContext; 479 + schema: SchemaWithRequired<'oneOf'>; 480 + }): IRSchemaObject => { 481 + let irSchema = initIrSchema({ schema }); 482 + 483 + let schemaItems: Array<IRSchemaObject> = []; 484 + const schemaTypes = getSchemaTypes({ schema }); 485 + 486 + for (const oneOf of schema.oneOf) { 487 + const irOneOfSchema = schemaToIrSchema({ 488 + context, 489 + schema: oneOf, 490 + }); 491 + 492 + // since we know oneOf will be using "or" logical operator, if the parsed 493 + // composition schema also has an "or" operator, we can bring it up 494 + // to avoid unnecessary brackets 495 + if (irOneOfSchema.logicalOperator === 'or' && irOneOfSchema.items) { 496 + schemaItems = schemaItems.concat(irOneOfSchema.items); 497 + } else { 498 + schemaItems.push(irOneOfSchema); 499 + } 500 + } 501 + 502 + if (schemaTypes.includes('null')) { 503 + schemaItems.push({ type: 'null' }); 504 + } 505 + 506 + addItemsToSchema({ 507 + items: schemaItems, 508 + schema: irSchema, 509 + }); 510 + 511 + if (schemaTypes.includes('object')) { 512 + // nest composition to avoid producing a union with object properties 513 + const irObjectSchema = parseOneType({ 514 + context, 515 + schema: { 516 + ...schema, 517 + type: 'object', 518 + }, 519 + }); 520 + 521 + if (irObjectSchema.properties) { 522 + irSchema = { 523 + items: [irSchema, irObjectSchema], 524 + logicalOperator: 'and', 525 + }; 526 + } 527 + } 528 + 529 + if (schema.discriminator) { 530 + // TODO: parser - support discriminator 531 + // TODO: parser - maybe abstract discriminator from oneOf, anyOf, and allOf 532 + } 533 + 534 + return irSchema; 535 + }; 536 + 537 + const parseRef = ({ 538 + schema, 539 + }: { 540 + context: IRContext; 541 + schema: SchemaWithRequired<'$ref'>; 542 + }): IRSchemaObject => { 543 + const irSchema = initIrSchema({ schema }); 544 + 545 + // refs using unicode characters become encoded, didn't investigate why 546 + // but the suspicion is this comes from `@apidevtools/json-schema-ref-parser` 547 + irSchema.$ref = decodeURI(schema.$ref); 548 + 549 + return irSchema; 550 + }; 551 + 552 + const parseOneType = ({ 553 + context, 554 + irSchema, 555 + schema, 556 + }: { 557 + context: IRContext; 558 + irSchema?: IRSchemaObject; 559 + schema: Omit<SchemaObject, 'type'> & { 560 + type: SchemaType; 561 + }; 562 + }): IRSchemaObject => { 563 + if (!irSchema) { 564 + irSchema = initIrSchema({ schema }); 565 + 566 + parseSchemaMeta({ 567 + irSchema, 568 + schema, 569 + }); 570 + } 571 + 572 + switch (schema.type) { 573 + case 'array': 574 + return parseArray({ 575 + context, 576 + irSchema, 577 + schema, 578 + }); 579 + case 'boolean': 580 + return parseBoolean({ 581 + context, 582 + irSchema, 583 + schema, 584 + }); 585 + case 'integer': 586 + case 'number': 587 + return parseNumber({ 588 + context, 589 + irSchema, 590 + schema, 591 + }); 592 + case 'null': 593 + return parseNull({ 594 + context, 595 + irSchema, 596 + schema, 597 + }); 598 + case 'object': 599 + return parseObject({ 600 + context, 601 + irSchema, 602 + schema, 603 + }); 604 + case 'string': 605 + return parseString({ 606 + context, 607 + irSchema, 608 + schema, 609 + }); 610 + } 611 + }; 612 + 613 + const parseManyTypes = ({ 614 + context, 615 + irSchema, 616 + schema, 617 + }: { 618 + context: IRContext; 619 + irSchema?: IRSchemaObject; 620 + schema: Omit<SchemaObject, 'type'> & { 621 + type: ReadonlyArray<SchemaType>; 622 + }; 623 + }): IRSchemaObject => { 624 + if (!irSchema) { 625 + irSchema = initIrSchema({ schema }); 626 + 627 + parseSchemaMeta({ 628 + irSchema, 629 + schema, 630 + }); 631 + } 632 + 633 + const schemaItems: Array<IRSchemaObject> = []; 634 + 635 + for (const type of schema.type) { 636 + schemaItems.push( 637 + parseOneType({ 638 + context, 639 + irSchema: {}, 640 + schema: { 641 + ...schema, 642 + type, 643 + }, 644 + }), 645 + ); 646 + } 647 + 648 + addItemsToSchema({ 649 + items: schemaItems, 650 + schema: irSchema, 651 + }); 652 + 653 + return irSchema; 654 + }; 655 + 656 + const parseType = ({ 657 + context, 658 + schema, 659 + }: { 660 + context: IRContext; 661 + schema: SchemaWithRequired<'type'>; 662 + }): IRSchemaObject => { 663 + const irSchema = initIrSchema({ schema }); 664 + 665 + parseSchemaMeta({ 666 + irSchema, 667 + schema, 668 + }); 669 + 670 + const schemaTypes = getSchemaTypes({ schema }); 671 + 672 + if (schemaTypes.length === 1) { 673 + return parseOneType({ 674 + context, 675 + irSchema, 676 + schema: { 677 + ...schema, 678 + type: schemaTypes[0], 679 + }, 680 + }); 681 + } 682 + 683 + return parseManyTypes({ 684 + context, 685 + irSchema, 686 + schema: { 687 + ...schema, 688 + type: schemaTypes, 689 + }, 690 + }); 691 + }; 692 + 693 + const parseUnknown = ({ 694 + schema, 695 + }: { 696 + context: IRContext; 697 + schema: SchemaObject; 698 + }): IRSchemaObject => { 699 + const irSchema = initIrSchema({ schema }); 700 + 701 + irSchema.type = 'unknown'; 702 + 703 + parseSchemaMeta({ 704 + irSchema, 705 + schema, 706 + }); 707 + 708 + return irSchema; 709 + }; 710 + 711 + export const schemaToIrSchema = ({ 712 + context, 713 + schema, 714 + }: { 715 + context: IRContext; 716 + schema: SchemaObject; 717 + }): IRSchemaObject => { 718 + if (schema.$ref) { 719 + return parseRef({ 720 + context, 721 + schema: schema as SchemaWithRequired<'$ref'>, 722 + }); 723 + } 724 + 725 + if (schema.enum) { 726 + return parseEnum({ 727 + context, 728 + schema: schema as SchemaWithRequired<'enum'>, 729 + }); 730 + } 731 + 732 + if (schema.allOf) { 733 + return parseAllOf({ 734 + context, 735 + schema: schema as SchemaWithRequired<'allOf'>, 736 + }); 737 + } 738 + 739 + if (schema.anyOf) { 740 + return parseAnyOf({ 741 + context, 742 + schema: schema as SchemaWithRequired<'anyOf'>, 743 + }); 744 + } 745 + 746 + if (schema.oneOf) { 747 + return parseOneOf({ 748 + context, 749 + schema: schema as SchemaWithRequired<'oneOf'>, 750 + }); 751 + } 752 + 753 + if (schema.type) { 754 + return parseType({ 755 + context, 756 + schema: schema as SchemaWithRequired<'type'>, 757 + }); 758 + } 759 + 760 + return parseUnknown({ 761 + context, 762 + schema, 763 + }); 764 + }; 765 + 766 + export const parseSchema = ({ 767 + context, 768 + name, 769 + schema, 770 + }: { 771 + context: IRContext; 772 + name: string; 773 + schema: SchemaObject; 774 + }) => { 775 + if (!context.ir.components) { 776 + context.ir.components = {}; 777 + } 778 + 779 + if (!context.ir.components.schemas) { 780 + context.ir.components.schemas = {}; 781 + } 782 + 783 + context.ir.components.schemas[name] = schemaToIrSchema({ 784 + context, 785 + schema, 786 + }); 787 + };
+366
packages/openapi-ts/src/openApi/3.1.0/types/json-schema-draft-2020-12.d.ts
··· 1 + import type { 2 + EnumExtensions, 3 + OpenApiSchemaExtensions, 4 + } from './spec-extensions'; 5 + 6 + // TODO: left out some keywords related to structuring a complex schema and declaring a dialect 7 + export interface JsonSchemaDraft2020_12 8 + extends ArrayKeywords, 9 + NumberKeywords, 10 + ObjectKeywords, 11 + StringKeywords, 12 + EnumExtensions, 13 + OpenApiSchemaExtensions { 14 + /** 15 + * The `$comment` {@link https://json-schema.org/learn/glossary#keyword keyword} is strictly intended for adding comments to a schema. Its value must always be a string. Unlike the annotations `title`, `description`, and `examples`, JSON schema {@link https://json-schema.org/learn/glossary#implementation implementations} aren't allowed to attach any meaning or behavior to it whatsoever, and may even strip them at any time. Therefore, they are useful for leaving notes to future editors of a JSON schema, but should not be used to communicate to users of the schema. 16 + */ 17 + $comment?: string; 18 + /** 19 + * A schema can reference another schema using the `$ref` keyword. The value of `$ref` is a URI-reference that is resolved against the schema's {@link https://json-schema.org/understanding-json-schema/structuring#base-uri Base URI}. When evaluating a `$ref`, an implementation uses the resolved identifier to retrieve the referenced schema and applies that schema to the {@link https://json-schema.org/learn/glossary#instance instance}. 20 + * 21 + * The `$ref` keyword may be used to create recursive schemas that refer to themselves. 22 + */ 23 + $ref?: string; 24 + /** 25 + * `allOf`: (AND) Must be valid against _all_ of the {@link https://json-schema.org/learn/glossary#subschema subschemas} 26 + * 27 + * To validate against `allOf`, the given data must be valid against all of the given subschemas. 28 + * 29 + * {@link https://json-schema.org/understanding-json-schema/reference/combining#allof allOf} can not be used to "extend" a schema to add more details to it in the sense of object-oriented inheritance. {@link https://json-schema.org/learn/glossary#instance Instances} must independently be valid against "all of" the schemas in the `allOf`. See the section on {@link https://json-schema.org/understanding-json-schema/reference/object#extending Extending Closed Schemas} for more information. 30 + */ 31 + allOf?: ReadonlyArray<JsonSchemaDraft2020_12>; 32 + /** 33 + * `anyOf`: (OR) Must be valid against _any_ of the subschemas 34 + * 35 + * To validate against `anyOf`, the given data must be valid against any (one or more) of the given subschemas. 36 + */ 37 + anyOf?: ReadonlyArray<JsonSchemaDraft2020_12>; 38 + /** 39 + * The `const` keyword is used to restrict a value to a single value. 40 + */ 41 + const?: unknown; 42 + /** 43 + * The `contentEncoding` keyword specifies the encoding used to store the contents, as specified in {@link https://tools.ietf.org/html/rfc2045 RFC 2054, part 6.1} and {@link https://datatracker.ietf.org/doc/html/rfc4648 RFC 4648}. 44 + * 45 + * The acceptable values are `quoted-printable`, `base16`, `base32`, and `base64`. If not specified, the encoding is the same as the containing JSON document. 46 + * 47 + * Without getting into the low-level details of each of these encodings, there are really only two options useful for modern usage: 48 + * - If the content is encoded in the same encoding as the enclosing JSON document (which for practical purposes, is almost always UTF-8), leave `contentEncoding` unspecified, and include the content in a string as-is. This includes text-based content types, such as `text/html` or `application/xml`. 49 + * - If the content is binary data, set `contentEncoding` to `base64` and encode the contents using {@link https://tools.ietf.org/html/rfc4648 Base64}. This would include many image types, such as `image/png` or audio types, such as `audio/mpeg`. 50 + */ 51 + contentEncoding?: 'base16' | 'base32' | 'base64' | 'quoted-printable'; 52 + /** 53 + * The `contentMediaType` keyword specifies the MIME type of the contents of a string, as described in {@link https://tools.ietf.org/html/rfc2046 RFC 2046}. There is a list of {@link http://www.iana.org/assignments/media-types/media-types.xhtml MIME types officially registered by the IANA}, but the set of types supported will be application and operating system dependent. Mozilla Developer Network also maintains a {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types shorter list of MIME types that are important for the web} 54 + */ 55 + contentMediaType?: string; 56 + /** 57 + * The `default` keyword specifies a default value. This value is not used to fill in missing values during the validation process. Non-validation tools such as documentation generators or form generators may use this value to give hints to users about how to use a value. However, `default` is typically used to express that if a value is missing, then the value is semantically the same as if the value was present with the default value. The value of `default` should validate against the schema in which it resides, but that isn't required. 58 + */ 59 + default?: unknown; 60 + /** 61 + * The `dependentRequired` {@link https://json-schema.org/learn/glossary#keyword keyword} conditionally requires that certain properties must be present if a given property is present in an object. For example, suppose we have a {@link https://json-schema.org/learn/glossary#schema schema} representing a customer. If you have their credit card number, you also want to ensure you have a billing address. If you don't have their credit card number, a billing address would not be required. We represent this dependency of one property on another using the `dependentRequired` keyword. The value of the `dependentRequired` keyword is an object. Each entry in the object maps from the name of a property, _p_, to an array of strings listing properties that are required if _p_ is present. 62 + */ 63 + dependentRequired?: Record<string, ReadonlyArray<string>>; 64 + /** 65 + * The `dependentSchemas` keyword conditionally applies a {@link https://json-schema.org/learn/glossary#subschema subschema} when a given property is present. This schema is applied in the same way {@link https://json-schema.org/understanding-json-schema/reference/combining#allof allOf} applies schemas. Nothing is merged or extended. Both schemas apply independently. 66 + */ 67 + dependentSchemas?: Record<string, JsonSchemaDraft2020_12>; 68 + /** 69 + * The `deprecated` keyword is a boolean that indicates that the {@link https://json-schema.org/learn/glossary#instance instance} value the keyword applies to should not be used and may be removed in the future. 70 + */ 71 + deprecated?: boolean; 72 + /** 73 + * The `title` and `description` keywords must be strings. A "title" will preferably be short, whereas a "description" will provide a more lengthy explanation about the purpose of the data described by the schema. 74 + */ 75 + description?: string; 76 + /** 77 + * The `if`, `then` and `else` keywords allow the application of a subschema based on the outcome of another schema, much like the `if`/`then`/`else` constructs you've probably seen in traditional programming languages. 78 + * 79 + * If `if` is valid, `then` must also be valid (and `else` is ignored.) If `if` is invalid, `else` must also be valid (and `then` is ignored). 80 + * 81 + * If `then` or `else` is not defined, `if` behaves as if they have a value of `true`. 82 + * 83 + * If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. 84 + */ 85 + else?: JsonSchemaDraft2020_12; 86 + /** 87 + * The `enum` {@link https://json-schema.org/learn/glossary#keyword keyword} is used to restrict a value to a fixed set of values. It must be an array with at least one element, where each element is unique. 88 + * 89 + * You can use `enum` even without a type, to accept values of different types. 90 + */ 91 + enum?: ReadonlyArray<unknown>; 92 + /** 93 + * The `examples` keyword is a place to provide an array of examples that validate against the schema. This isn't used for validation, but may help with explaining the effect and purpose of the schema to a reader. Each entry should validate against the schema in which it resides, but that isn't strictly required. There is no need to duplicate the `default` value in the `examples` array, since `default` will be treated as another example. 94 + */ 95 + examples?: ReadonlyArray<unknown>; 96 + /** 97 + * The `format` keyword allows for basic semantic identification of certain kinds of string values that are commonly used. For example, because JSON doesn't have a "DateTime" type, dates need to be encoded as strings. `format` allows the schema author to indicate that the string value should be interpreted as a date. By default, `format` is just an annotation and does not effect validation. 98 + * 99 + * Optionally, validator {@link https://json-schema.org/learn/glossary#implementation implementations} can provide a configuration option to enable `format` to function as an assertion rather than just an annotation. That means that validation will fail if, for example, a value with a `date` format isn't in a form that can be parsed as a date. This can allow values to be constrained beyond what the other tools in JSON Schema, including {@link https://json-schema.org/understanding-json-schema/reference/regular_expressions Regular Expressions} can do. 100 + * 101 + * There is a bias toward networking-related formats in the JSON Schema specification, most likely due to its heritage in web technologies. However, custom formats may also be used, as long as the parties exchanging the JSON documents also exchange information about the custom format types. A JSON Schema validator will ignore any format type that it does not understand. 102 + */ 103 + format?: JsonSchemaFormats; 104 + /** 105 + * The `if`, `then` and `else` keywords allow the application of a subschema based on the outcome of another schema, much like the `if`/`then`/`else` constructs you've probably seen in traditional programming languages. 106 + * 107 + * If `if` is valid, `then` must also be valid (and `else` is ignored.) If `if` is invalid, `else` must also be valid (and `then` is ignored). 108 + * 109 + * If `then` or `else` is not defined, `if` behaves as if they have a value of `true`. 110 + * 111 + * If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. 112 + */ 113 + if?: JsonSchemaDraft2020_12; 114 + /** 115 + * `not`: (NOT) Must _not_ be valid against the given schema 116 + * 117 + * The `not` keyword declares that an instance validates if it doesn't validate against the given subschema. 118 + */ 119 + not?: JsonSchemaDraft2020_12; 120 + /** 121 + * `oneOf`: (XOR) Must be valid against _exactly one_ of the subschemas 122 + * 123 + * To validate against `oneOf`, the given data must be valid against exactly one of the given subschemas. 124 + * 125 + * Careful consideration should be taken when using `oneOf` entries as the nature of it requires verification of _every_ sub-schema which can lead to increased processing times. Prefer `anyOf` where possible. 126 + */ 127 + oneOf?: ReadonlyArray<JsonSchemaDraft2020_12>; 128 + /** 129 + * The boolean keywords `readOnly` and `writeOnly` are typically used in an API context. `readOnly` indicates that a value should not be modified. It could be used to indicate that a `PUT` request that changes a value would result in a `400 Bad Request` response. `writeOnly` indicates that a value may be set, but will remain hidden. In could be used to indicate you can set a value with a `PUT` request, but it would not be included when retrieving that record with a `GET` request. 130 + */ 131 + readOnly?: boolean; 132 + /** 133 + * The `if`, `then` and `else` keywords allow the application of a subschema based on the outcome of another schema, much like the `if`/`then`/`else` constructs you've probably seen in traditional programming languages. 134 + * 135 + * If `if` is valid, `then` must also be valid (and `else` is ignored.) If `if` is invalid, `else` must also be valid (and `then` is ignored). 136 + * 137 + * If `then` or `else` is not defined, `if` behaves as if they have a value of `true`. 138 + * 139 + * If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. 140 + */ 141 + then?: JsonSchemaDraft2020_12; 142 + /** 143 + * The `title` and `description` keywords must be strings. A "title" will preferably be short, whereas a "description" will provide a more lengthy explanation about the purpose of the data described by the schema. 144 + */ 145 + title?: string; 146 + /** 147 + * If it is an array, it must be an array of strings, where each string is the name of one of the basic types, and each element is unique. In this case, the JSON snippet is valid if it matches any of the given types. 148 + */ 149 + type?: JsonSchemaTypes | ReadonlyArray<JsonSchemaTypes>; 150 + /** 151 + * The boolean keywords `readOnly` and `writeOnly` are typically used in an API context. `readOnly` indicates that a value should not be modified. It could be used to indicate that a `PUT` request that changes a value would result in a `400 Bad Request` response. `writeOnly` indicates that a value may be set, but will remain hidden. In could be used to indicate you can set a value with a `PUT` request, but it would not be included when retrieving that record with a `GET` request. 152 + */ 153 + writeOnly?: boolean; 154 + } 155 + 156 + interface ArrayKeywords { 157 + /** 158 + * While the `items` schema must be valid for every item in the array, the `contains` schema only needs to validate against one or more items in the array. 159 + */ 160 + contains?: JsonSchemaDraft2020_12; 161 + /** 162 + * List validation is useful for arrays of arbitrary length where each item matches the same schema. For this kind of array, set the `items` {@link https://json-schema.org/learn/glossary#keyword keyword} to a single schema that will be used to validate all of the items in the array. 163 + * 164 + * The `items` keyword can be used to control whether it's valid to have additional items in a tuple beyond what is defined in `prefixItems`. The value of the `items` keyword is a schema that all additional items must pass in order for the keyword to validate. 165 + * 166 + * Note that `items` doesn't "see inside" any {@link https://json-schema.org/learn/glossary#instance instances} of `allOf`, `anyOf`, or `oneOf` in the same {@link https://json-schema.org/learn/glossary#subschema subschema}. 167 + */ 168 + items?: JsonSchemaDraft2020_12 | false; 169 + /** 170 + * `minContains` and `maxContains` can be used with `contains` to further specify how many times a schema matches a `contains` constraint. These keywords can be any non-negative number including zero. 171 + */ 172 + maxContains?: number; 173 + /** 174 + * The length of the array can be specified using the `minItems` and `maxItems` keywords. The value of each keyword must be a non-negative number. These keywords work whether doing {@link https://json-schema.org/understanding-json-schema/reference/array#items list validation} or {@link https://json-schema.org/understanding-json-schema/reference/array#tupleValidation tuple-validation}. 175 + */ 176 + maxItems?: number; 177 + /** 178 + * `minContains` and `maxContains` can be used with `contains` to further specify how many times a schema matches a `contains` constraint. These keywords can be any non-negative number including zero. 179 + */ 180 + minContains?: number; 181 + /** 182 + * The length of the array can be specified using the `minItems` and `maxItems` keywords. The value of each keyword must be a non-negative number. These keywords work whether doing {@link https://json-schema.org/understanding-json-schema/reference/array#items list validation} or {@link https://json-schema.org/understanding-json-schema/reference/array#tupleValidation tuple-validation}. 183 + */ 184 + minItems?: number; 185 + /** 186 + * `prefixItems` is an array, where each item is a schema that corresponds to each index of the document's array. That is, an array where the first element validates the first element of the input array, the second element validates the second element of the input array, etc. 187 + */ 188 + prefixItems?: ReadonlyArray<JsonSchemaDraft2020_12>; 189 + /** 190 + * The `unevaluatedItems` keyword is useful mainly when you want to add or disallow extra items to an array. 191 + * 192 + * `unevaluatedItems` applies to any values not evaluated by an `items`, `prefixItems`, or `contains` keyword. Just as `unevaluatedProperties` affects only properties in an object, `unevaluatedItems` affects only items in an array. 193 + * 194 + * Watch out! The word "unevaluated" _does not mean_ "not evaluated by `items`, `prefixItems`, or `contains`." "Unevaluated" means "not successfully evaluated", or "does not evaluate to true". 195 + * 196 + * Like with `items`, if you set `unevaluatedItems` to false, you can disallow extra items in the array. 197 + */ 198 + unevaluatedItems?: JsonSchemaDraft2020_12 | false; 199 + /** 200 + * A schema can ensure that each of the items in an array is unique. Simply set the `uniqueItems` keyword to `true`. 201 + */ 202 + uniqueItems?: boolean; 203 + } 204 + 205 + interface NumberKeywords { 206 + /** 207 + * Ranges of numbers are specified using a combination of the `minimum` and `maximum` keywords, (or `exclusiveMinimum` and `exclusiveMaximum` for expressing exclusive range). 208 + * 209 + * If _x_ is the value being validated, the following must hold true: 210 + * 211 + * ``` 212 + * x ≥ minimum 213 + * x > exclusiveMinimum 214 + * x ≤ maximum 215 + * x < exclusiveMaximum 216 + * ``` 217 + * 218 + * While you can specify both of `minimum` and `exclusiveMinimum` or both of `maximum` and `exclusiveMaximum`, it doesn't really make sense to do so. 219 + */ 220 + exclusiveMaximum?: number; 221 + /** 222 + * Ranges of numbers are specified using a combination of the `minimum` and `maximum` keywords, (or `exclusiveMinimum` and `exclusiveMaximum` for expressing exclusive range). 223 + * 224 + * If _x_ is the value being validated, the following must hold true: 225 + * 226 + * ``` 227 + * x ≥ minimum 228 + * x > exclusiveMinimum 229 + * x ≤ maximum 230 + * x < exclusiveMaximum 231 + * ``` 232 + * 233 + * While you can specify both of `minimum` and `exclusiveMinimum` or both of `maximum` and `exclusiveMaximum`, it doesn't really make sense to do so. 234 + */ 235 + exclusiveMinimum?: number; 236 + /** 237 + * Ranges of numbers are specified using a combination of the `minimum` and `maximum` keywords, (or `exclusiveMinimum` and `exclusiveMaximum` for expressing exclusive range). 238 + * 239 + * If _x_ is the value being validated, the following must hold true: 240 + * 241 + * ``` 242 + * x ≥ minimum 243 + * x > exclusiveMinimum 244 + * x ≤ maximum 245 + * x < exclusiveMaximum 246 + * ``` 247 + * 248 + * While you can specify both of `minimum` and `exclusiveMinimum` or both of `maximum` and `exclusiveMaximum`, it doesn't really make sense to do so. 249 + */ 250 + maximum?: number; 251 + /** 252 + * Ranges of numbers are specified using a combination of the `minimum` and `maximum` keywords, (or `exclusiveMinimum` and `exclusiveMaximum` for expressing exclusive range). 253 + * 254 + * If _x_ is the value being validated, the following must hold true: 255 + * 256 + * ``` 257 + * x ≥ minimum 258 + * x > exclusiveMinimum 259 + * x ≤ maximum 260 + * x < exclusiveMaximum 261 + * ``` 262 + * 263 + * While you can specify both of `minimum` and `exclusiveMinimum` or both of `maximum` and `exclusiveMaximum`, it doesn't really make sense to do so. 264 + */ 265 + minimum?: number; 266 + /** 267 + * Numbers can be restricted to a multiple of a given number, using the `multipleOf` keyword. It may be set to any positive number. The multiple can be a floating point number. 268 + */ 269 + multipleOf?: number; 270 + } 271 + 272 + interface ObjectKeywords { 273 + /** 274 + * The `additionalProperties` keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the `properties` keyword or match any of the regular expressions in the `patternProperties` keyword. By default any additional properties are allowed. 275 + * 276 + * The value of the `additionalProperties` keyword is a schema that will be used to validate any properties in the {@link https://json-schema.org/learn/glossary#instance instance} that are not matched by `properties` or `patternProperties`. Setting the `additionalProperties` schema to `false` means no additional properties will be allowed. 277 + * 278 + * It's important to note that `additionalProperties` only recognizes properties declared in the same {@link https://json-schema.org/learn/glossary#subschema subschema} as itself. So, `additionalProperties` can restrict you from "extending" a schema using {@link https://json-schema.org/understanding-json-schema/reference/combining combining} keywords such as {@link https://json-schema.org/understanding-json-schema/reference/combining#allof allOf}. 279 + */ 280 + additionalProperties?: JsonSchemaDraft2020_12 | false; 281 + /** 282 + * The number of properties on an object can be restricted using the `minProperties` and `maxProperties` keywords. Each of these must be a non-negative integer. 283 + */ 284 + maxProperties?: number; 285 + /** 286 + * The number of properties on an object can be restricted using the `minProperties` and `maxProperties` keywords. Each of these must be a non-negative integer. 287 + */ 288 + minProperties?: number; 289 + /** 290 + * Sometimes you want to say that, given a particular kind of property name, the value should match a particular schema. That's where `patternProperties` comes in: it maps regular expressions to schemas. If a property name matches the given regular expression, the property value must validate against the corresponding schema. 291 + */ 292 + patternProperties?: Record<string, JsonSchemaDraft2020_12>; 293 + /** 294 + * The properties (key-value pairs) on an object are defined using the `properties` {@link https://json-schema.org/learn/glossary#keyword keyword}. The value of `properties` is an object, where each key is the name of a property and each value is a {@link https://json-schema.org/learn/glossary#schema schema} used to validate that property. Any property that doesn't match any of the property names in the `properties` keyword is ignored by this keyword. 295 + */ 296 + properties?: Record<string, JsonSchemaDraft2020_12 | true>; 297 + /** 298 + * The names of properties can be validated against a schema, irrespective of their values. This can be useful if you don't want to enforce specific properties, but you want to make sure that the names of those properties follow a specific convention. You might, for example, want to enforce that all names are valid ASCII tokens so they can be used as attributes in a particular programming language. 299 + * 300 + * Since object keys must always be strings anyway, it is implied that the schema given to `propertyNames` is always at least: 301 + * 302 + * ```json 303 + * { "type": "string" } 304 + * ``` 305 + */ 306 + propertyNames?: JsonSchemaDraft2020_12; 307 + /** 308 + * By default, the properties defined by the `properties` keyword are not required. However, one can provide a list of required properties using the `required` keyword. 309 + * 310 + * The `required` keyword takes an array of zero or more strings. Each of these strings must be unique. 311 + */ 312 + required?: ReadonlyArray<string>; 313 + /** 314 + * The `unevaluatedProperties` keyword is similar to `additionalProperties` except that it can recognize properties declared in subschemas. So, the example from the previous section can be rewritten without the need to redeclare properties. 315 + * 316 + * `unevaluatedProperties` works by collecting any properties that are successfully validated when processing the schemas and using those as the allowed list of properties. This allows you to do more complex things like conditionally adding properties. 317 + */ 318 + unevaluatedProperties?: JsonSchemaDraft2020_12 | false; 319 + } 320 + 321 + interface StringKeywords { 322 + /** 323 + * The length of a string can be constrained using the `minLength` and `maxLength` {@link https://json-schema.org/learn/glossary#keyword keywords}. For both keywords, the value must be a non-negative number. 324 + */ 325 + maxLength?: number; 326 + /** 327 + * The length of a string can be constrained using the `minLength` and `maxLength` {@link https://json-schema.org/learn/glossary#keyword keywords}. For both keywords, the value must be a non-negative number. 328 + */ 329 + minLength?: number; 330 + /** 331 + * The `pattern` keyword is used to restrict a string to a particular regular expression. The regular expression syntax is the one defined in JavaScript ({@link https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ ECMA 262} specifically) with Unicode support. See {@link https://json-schema.org/understanding-json-schema/reference/regular_expressions Regular Expressions} for more information. 332 + */ 333 + pattern?: string; 334 + } 335 + 336 + type JsonSchemaFormats = 337 + | 'date' 338 + | 'date-time' 339 + | 'duration' 340 + | 'email' 341 + | 'hostname' 342 + | 'idn-email' 343 + | 'idn-hostname' 344 + | 'ipv4' 345 + | 'ipv6' 346 + | 'iri' 347 + | 'iri-reference' 348 + | 'json-pointer' 349 + | 'regex' 350 + | 'relative-json-pointer' 351 + | 'time' 352 + | 'uri' 353 + | 'uri-reference' 354 + | 'uri-template' 355 + | 'uuid' 356 + // eslint-disable-next-line @typescript-eslint/ban-types 357 + | (string & {}); 358 + 359 + type JsonSchemaTypes = 360 + | 'array' 361 + | 'boolean' 362 + | 'integer' 363 + | 'null' 364 + | 'number' 365 + | 'object' 366 + | 'string';
+41
packages/openapi-ts/src/openApi/3.1.0/types/spec-extensions.d.ts
··· 1 + import type { 2 + DiscriminatorObject, 3 + ExternalDocumentationObject, 4 + XMLObject, 5 + } from './spec'; 6 + 7 + export interface EnumExtensions { 8 + /** 9 + * `x-enum-descriptions` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator. 10 + */ 11 + 'x-enum-descriptions'?: ReadonlyArray<string>; 12 + /** 13 + * `x-enum-varnames` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator. 14 + */ 15 + 'x-enum-varnames'?: ReadonlyArray<string>; 16 + /** 17 + * {@link https://github.com/RicoSuter/NSwag NSwag} generates `x-enumNames` field containing custom enum names. 18 + */ 19 + 'x-enumNames'?: ReadonlyArray<string>; 20 + } 21 + 22 + export interface OpenApiSchemaExtensions { 23 + /** 24 + * Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description. See {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#composition-and-inheritance-polymorphism Composition and Inheritance} for more details. 25 + */ 26 + discriminator?: DiscriminatorObject; 27 + /** 28 + * A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary. 29 + * 30 + * **Deprecated**: The `example` property has been deprecated in favor of the JSON Schema `examples` keyword. Use of `example` is discouraged, and later versions of this specification may remove it. 31 + */ 32 + example?: unknown; 33 + /** 34 + * Additional external documentation for this schema. 35 + */ 36 + externalDocs?: ExternalDocumentationObject; 37 + /** 38 + * This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. 39 + */ 40 + xml?: XMLObject; 41 + }
-2
packages/openapi-ts/src/openApi/3.1/index.ts
··· 1 - export { parseV3_1 } from './parser'; 2 - export type { OpenApiV3_1 } from './types/spec';
-82
packages/openapi-ts/src/openApi/3.1/parser/index.ts
··· 1 - import type { OpenApiV3_1, PathsObject } from '../types/spec'; 2 - import { parseOperation } from './operation'; 3 - 4 - export const parseV3_1 = (spec: OpenApiV3_1) => { 5 - const operationIds = new Map<string, string>(); 6 - 7 - for (const path in spec.paths) { 8 - const pathItem = spec.paths[path as keyof PathsObject]; 9 - 10 - if (pathItem.delete) { 11 - parseOperation({ 12 - method: 'DELETE', 13 - operation: pathItem.delete, 14 - operationIds, 15 - path, 16 - }); 17 - } 18 - 19 - if (pathItem.get) { 20 - parseOperation({ 21 - method: 'GET', 22 - operation: pathItem.get, 23 - operationIds, 24 - path, 25 - }); 26 - } 27 - 28 - if (pathItem.head) { 29 - parseOperation({ 30 - method: 'HEAD', 31 - operation: pathItem.head, 32 - operationIds, 33 - path, 34 - }); 35 - } 36 - 37 - if (pathItem.options) { 38 - parseOperation({ 39 - method: 'OPTIONS', 40 - operation: pathItem.options, 41 - operationIds, 42 - path, 43 - }); 44 - } 45 - 46 - if (pathItem.patch) { 47 - parseOperation({ 48 - method: 'PATCH', 49 - operation: pathItem.patch, 50 - operationIds, 51 - path, 52 - }); 53 - } 54 - 55 - if (pathItem.post) { 56 - parseOperation({ 57 - method: 'POST', 58 - operation: pathItem.post, 59 - operationIds, 60 - path, 61 - }); 62 - } 63 - 64 - if (pathItem.put) { 65 - parseOperation({ 66 - method: 'PUT', 67 - operation: pathItem.put, 68 - operationIds, 69 - path, 70 - }); 71 - } 72 - 73 - if (pathItem.trace) { 74 - parseOperation({ 75 - method: 'TRACE', 76 - operation: pathItem.trace, 77 - operationIds, 78 - path, 79 - }); 80 - } 81 - } 82 - };
-39
packages/openapi-ts/src/openApi/3.1/parser/operation.ts
··· 1 - import { getConfig } from '../../../utils/config'; 2 - import type { OperationObject } from '../types/spec'; 3 - 4 - export const parseOperation = ({ 5 - method, 6 - operation, 7 - operationIds, 8 - path, 9 - }: { 10 - method: string; 11 - operation: OperationObject; 12 - operationIds: Map<string, string>; 13 - path: string; 14 - }) => { 15 - const operationKey = `${method} ${path}`; 16 - 17 - const config = getConfig(); 18 - 19 - // TODO: filter function, move services to plugin, cleaner syntax 20 - const regexp = config.services.filter 21 - ? new RegExp(config.services.filter) 22 - : undefined; 23 - if (regexp && !regexp.test(operationKey)) { 24 - return; 25 - } 26 - 27 - // TODO: support throw on duplicate 28 - if (operation.operationId) { 29 - if (operationIds.has(operation.operationId)) { 30 - console.warn( 31 - `❗️ Duplicate operationId: ${operation.operationId} in ${operationKey}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`, 32 - ); 33 - } else { 34 - operationIds.set(operation.operationId, operationKey); 35 - } 36 - } 37 - 38 - console.log(operation); 39 - };
+4 -21
packages/openapi-ts/src/openApi/3.1/types/spec.ts packages/openapi-ts/src/openApi/3.1.0/types/spec.d.ts
··· 1 + import type { JsonSchemaDraft2020_12 } from './json-schema-draft-2020-12'; 2 + 1 3 /** 2 4 * This is the root object of the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-document OpenAPI document}. 3 5 * 4 6 * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}. 5 7 */ 6 - export interface OpenApiV3_1 { 8 + export interface OpenApiV3_1_0 { 7 9 /** 8 10 * An element to hold various schemas for the document. 9 11 */ ··· 1651 1653 * 1652 1654 * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}, though as noted, additional properties MAY omit the `x-` prefix within this object. 1653 1655 */ 1654 - export interface SchemaObject { 1655 - /** 1656 - * Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description. See {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#composition-and-inheritance-polymorphism Composition and Inheritance} for more details. 1657 - */ 1658 - discriminator?: DiscriminatorObject; 1659 - /** 1660 - * A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary. 1661 - * 1662 - * **Deprecated**: The `example` property has been deprecated in favor of the JSON Schema `examples` keyword. Use of `example` is discouraged, and later versions of this specification may remove it. 1663 - */ 1664 - example?: unknown; 1665 - /** 1666 - * Additional external documentation for this schema. 1667 - */ 1668 - externalDocs?: ExternalDocumentationObject; 1669 - /** 1670 - * This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. 1671 - */ 1672 - xml?: XMLObject; 1673 - } 1656 + export interface SchemaObject extends JsonSchemaDraft2020_12 {} 1674 1657 1675 1658 /** 1676 1659 * Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#componentsSecuritySchemes Security Schemes} under the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#components-object Components Object}.
+12 -8
packages/openapi-ts/src/openApi/__tests__/index.spec.ts
··· 1 1 import { afterEach, describe, expect, it, vi } from 'vitest'; 2 2 3 3 import { type OpenApi, parse } from '..'; 4 - import type { Config } from '../common/interfaces/config'; 4 + import type { ParserConfig } from '../config'; 5 5 import * as parseV2 from '../v2'; 6 6 import * as parseV3 from '../v3'; 7 7 8 - const config: Config = { 8 + const parserConfig: ParserConfig = { 9 + filterFn: { 10 + operation: () => true, 11 + operationParameter: () => true, 12 + }, 9 13 nameFn: { 10 14 operation: () => 'operation', 11 15 operationParameter: () => 'operationParameter', ··· 28 32 paths: {}, 29 33 swagger: '2', 30 34 }; 31 - parse({ config, openApi: spec }); 35 + parse({ openApi: spec, parserConfig }); 32 36 expect(spy).toHaveBeenCalledWith(spec); 33 37 34 38 const spec2: OpenApi = { ··· 39 43 paths: {}, 40 44 swagger: '2.0', 41 45 }; 42 - parse({ config, openApi: spec2 }); 46 + parse({ openApi: spec2, parserConfig }); 43 47 expect(spy).toHaveBeenCalledWith(spec2); 44 48 }); 45 49 ··· 54 58 openapi: '3', 55 59 paths: {}, 56 60 }; 57 - parse({ config, openApi: spec }); 61 + parse({ openApi: spec, parserConfig }); 58 62 expect(spy).toHaveBeenCalledWith(spec); 59 63 60 64 const spec2: OpenApi = { ··· 65 69 openapi: '3.0', 66 70 paths: {}, 67 71 }; 68 - parse({ config, openApi: spec2 }); 72 + parse({ openApi: spec2, parserConfig }); 69 73 expect(spy).toHaveBeenCalledWith(spec2); 70 74 71 75 const spec3: OpenApi = { ··· 76 80 openapi: '3.1.0', 77 81 paths: {}, 78 82 }; 79 - parse({ config, openApi: spec3 }); 83 + parse({ openApi: spec3, parserConfig }); 80 84 expect(spy).toHaveBeenCalledWith(spec3); 81 85 }); 82 86 83 87 it('throws on unknown version', () => { 84 88 // @ts-expect-error 85 - expect(() => parse({ config, openApi: { foo: 'bar' } })).toThrow( 89 + expect(() => parse({ openApi: { foo: 'bar' }, parserConfig })).toThrow( 86 90 `Unsupported OpenAPI specification: ${JSON.stringify({ foo: 'bar' }, null, 2)}`, 87 91 ); 88 92 });
-13
packages/openapi-ts/src/openApi/common/interfaces/config.ts
··· 1 - import type { Operation, OperationParameter } from './client'; 2 - 3 - export interface Config { 4 - debug?: boolean; 5 - filterFn?: { 6 - operation?: (operationKey: string) => boolean; 7 - operationParameter?: (parameter: OperationParameter) => boolean; 8 - }; 9 - nameFn: { 10 - operation: (operation: Omit<Operation, 'name'>) => string; 11 - operationParameter: (parameter: Omit<OperationParameter, 'name'>) => string; 12 - }; 13 - }
+1 -1
packages/openapi-ts/src/openApi/common/parser/operation.ts
··· 7 7 method: string; 8 8 path: string; 9 9 }) => { 10 - const operationKey = `${operation.method} ${operation.path}`; 10 + const operationKey = `${operation.method.toUpperCase()} ${operation.path}`; 11 11 return operationKey; 12 12 }; 13 13
+5 -22
packages/openapi-ts/src/openApi/common/parser/sanitize.ts
··· 1 1 import { illegalStartCharactersRegExp } from '../../../utils/regexp'; 2 2 3 - /** 4 - * Sanitizes names of types, so they are valid TypeScript identifiers of a certain form. 5 - * 6 - * 1: Remove any leading characters that are illegal as starting character of a TypeScript identifier. 7 - * 2: Replace illegal characters in remaining part of type name with underscore (_). 8 - * 9 - * Step 1 should perhaps instead also replace illegal characters with underscore, or prefix with it, like sanitizeEnumName 10 - * does. The way this is now one could perhaps end up removing all characters, if all are illegal start characters. It 11 - * would be sort of a breaking change to do so, though, previously generated code might change then. 12 - * 13 - * JavaScript identifier regexp pattern retrieved from https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers 14 - */ 15 - const replaceInvalidTypeScriptJavaScriptIdentifier = (name: string) => 16 - name 17 - .replace(illegalStartCharactersRegExp, '') 18 - .replace(/[^$\u200c\u200d\p{ID_Continue}]/gu, '_'); 19 - 20 3 export const ensureValidTypeScriptJavaScriptIdentifier = (name: string) => { 21 4 illegalStartCharactersRegExp.lastIndex = 0; 22 - const startsWithIllegalCharacter = illegalStartCharactersRegExp.test(name); 23 - // avoid removing all characters in case they're all illegal 24 - const input = startsWithIllegalCharacter ? `_${name}` : name; 25 - const cleaned = replaceInvalidTypeScriptJavaScriptIdentifier(input); 26 - return cleaned; 5 + const replaced = name.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu, '_'); 6 + const startsWithIllegalCharacter = 7 + illegalStartCharactersRegExp.test(replaced); 8 + const valid = startsWithIllegalCharacter ? `_${replaced}` : replaced; 9 + return valid; 27 10 }; 28 11 29 12 /**
+98 -5
packages/openapi-ts/src/openApi/config.ts
··· 1 - import type { Config } from './common/interfaces/config'; 1 + import type { Config } from '../types/config'; 2 + import { camelCase } from '../utils/camelCase'; 3 + import { getConfig, isLegacyClient } from '../utils/config'; 4 + import { transformTypeKeyName } from '../utils/type'; 5 + import type { OperationParameter } from './common/interfaces/client'; 6 + import { sanitizeNamespaceIdentifier } from './common/parser/sanitize'; 2 7 3 - let _config: Config; 8 + export interface ParserConfig { 9 + debug?: boolean; 10 + filterFn: { 11 + operation: typeof operationFilterFn; 12 + operationParameter: typeof operationParameterFilterFn; 13 + }; 14 + nameFn: { 15 + operation: typeof operationNameFn; 16 + operationParameter: typeof operationParameterNameFn; 17 + }; 18 + } 4 19 5 - export const getConfig = () => _config; 20 + let _config: ParserConfig; 6 21 7 - export const setConfig = (config: Config) => { 22 + export const getParserConfig = () => _config; 23 + 24 + export const setParserConfig = (config: ParserConfig) => { 8 25 _config = config; 9 - return getConfig(); 26 + return getParserConfig(); 27 + }; 28 + 29 + export const operationFilterFn = ({ 30 + config, 31 + operationKey, 32 + }: { 33 + config: Config; 34 + operationKey: string; 35 + }): boolean => { 36 + const regexp = config.services.filter 37 + ? new RegExp(config.services.filter) 38 + : undefined; 39 + return !regexp || regexp.test(operationKey); 40 + }; 41 + 42 + export const operationParameterFilterFn = ( 43 + parameter: OperationParameter, 44 + ): boolean => { 45 + const config = getConfig(); 46 + 47 + // legacy clients ignore the "api-version" param since we do not want to 48 + // add it as the first/default parameter for each of the service calls 49 + return !isLegacyClient(config) || parameter.prop !== 'api-version'; 50 + }; 51 + 52 + /** 53 + * Convert the input value to a correct operation (method) class name. 54 + * This will use the operation ID - if available - and otherwise fallback 55 + * on a generated name from the URL 56 + */ 57 + export const operationNameFn = ({ 58 + config, 59 + method, 60 + operationId, 61 + path, 62 + }: { 63 + config: Config; 64 + method: string; 65 + operationId: string | undefined; 66 + path: string; 67 + }): string => { 68 + if (config.services.operationId && operationId) { 69 + return camelCase({ 70 + input: sanitizeNamespaceIdentifier(operationId), 71 + }); 72 + } 73 + 74 + let urlWithoutPlaceholders = path; 75 + 76 + // legacy clients ignore the "api-version" param since we do not want to 77 + // add it as the first/default parameter for each of the service calls 78 + if (isLegacyClient(config)) { 79 + urlWithoutPlaceholders = urlWithoutPlaceholders.replace( 80 + /[^/]*?{api-version}.*?\//g, 81 + '', 82 + ); 83 + } 84 + 85 + urlWithoutPlaceholders = urlWithoutPlaceholders 86 + .replace(/{(.*?)}/g, 'by-$1') 87 + // replace slashes with hyphens for camelcase method at the end 88 + .replace(/[/:]/g, '-'); 89 + 90 + return camelCase({ 91 + input: `${method}-${urlWithoutPlaceholders}`, 92 + }); 93 + }; 94 + 95 + export const operationParameterNameFn = ( 96 + parameter: Omit<OperationParameter, 'name'>, 97 + ): string => { 98 + const config = getConfig(); 99 + 100 + return !isLegacyClient(config) 101 + ? parameter.prop 102 + : transformTypeKeyName(parameter.prop); 10 103 };
+35 -13
packages/openapi-ts/src/openApi/index.ts
··· 1 + import { IRContext } from '../ir/context'; 2 + import type { Config } from '../types/config'; 1 3 import { type OpenApiV3_0_3, parseV3_0_3 } from './3.0.3'; 2 - import { type OpenApiV3_1, parseV3_1 } from './3.1'; 4 + import { type OpenApiV3_1_0, parseV3_1_0 } from './3.1.0'; 3 5 import type { Client } from './common/interfaces/client'; 4 - import type { Config } from './common/interfaces/config'; 5 6 import type { OpenApi } from './common/interfaces/OpenApi'; 6 - import { setConfig } from './config'; 7 + import type { ParserConfig } from './config'; 8 + import { setParserConfig } from './config'; 7 9 import { parse as parseV2 } from './v2'; 8 10 import { parse as parseV3 } from './v3'; 9 11 ··· 17 19 OperationParameter, 18 20 OperationResponse, 19 21 } from './common/interfaces/client'; 20 - export type { Config } from './common/interfaces/config'; 21 22 export type { OpenApi } from './common/interfaces/OpenApi'; 22 23 export { isOperationParameterRequired } from './common/parser/operation'; 23 24 export { ··· 36 37 */ 37 38 export function parse({ 38 39 openApi, 39 - config, 40 + parserConfig, 40 41 }: { 41 - config: Config; 42 42 openApi: OpenApi; 43 + parserConfig: ParserConfig; 43 44 }): Client { 44 - setConfig(config); 45 + setParserConfig(parserConfig); 45 46 46 47 if ('openapi' in openApi) { 47 48 return parseV3(openApi); ··· 56 57 ); 57 58 } 58 59 59 - export const parseExperimental = ({ spec }: { spec: unknown }) => { 60 - const s = spec as OpenApiV3_0_3 | OpenApiV3_1; 60 + // TODO: parser - add JSDoc comment 61 + export const parseExperimental = ({ 62 + config, 63 + parserConfig, 64 + spec, 65 + }: { 66 + config: Config; 67 + parserConfig: ParserConfig; 68 + spec: unknown; 69 + }) => { 70 + const context = new IRContext({ 71 + config, 72 + parserConfig, 73 + spec: spec as OpenApiV3_0_3 | OpenApiV3_1_0, 74 + }); 61 75 62 - switch (s.openapi) { 76 + switch (context.spec.openapi) { 63 77 case '3.0.3': 64 - return parseV3_0_3(s); 78 + parseV3_0_3(context as IRContext<OpenApiV3_0_3>); 79 + break; 65 80 case '3.1.0': 66 - return parseV3_1(s); 81 + parseV3_1_0(context as IRContext<OpenApiV3_1_0>); 82 + break; 67 83 default: 68 - throw new Error('Unsupported OpenAPI specification'); 84 + // TODO: parser - uncomment after removing legacy parser. 85 + // For now, we fall back to legacy parser if spec version 86 + // is not supported 87 + break; 88 + // throw new Error('Unsupported OpenAPI specification'); 69 89 } 90 + 91 + return context; 70 92 };
+2 -2
packages/openapi-ts/src/openApi/v2/parser/getOperationParameter.ts
··· 5 5 import { getPattern } from '../../common/parser/getPattern'; 6 6 import { getRef } from '../../common/parser/getRef'; 7 7 import { getType } from '../../common/parser/type'; 8 - import { getConfig } from '../../config'; 8 + import { getParserConfig } from '../../config'; 9 9 import type { OpenApi } from '../interfaces/OpenApi'; 10 10 import type { OpenApiParameter } from '../interfaces/OpenApiParameter'; 11 11 import type { OpenApiSchema } from '../interfaces/OpenApiSchema'; ··· 20 20 parameter: OpenApiParameter; 21 21 types: Client['types']; 22 22 }): OperationParameter => { 23 - const config = getConfig(); 23 + const config = getParserConfig(); 24 24 25 25 const operationParameterWithoutName: Omit<OperationParameter, 'name'> = { 26 26 $refs: [],
+3 -5
packages/openapi-ts/src/openApi/v2/parser/getOperationParameters.ts
··· 1 1 import type { Client } from '../../../types/client'; 2 2 import type { OperationParameters } from '../../common/interfaces/client'; 3 3 import { getRef } from '../../common/parser/getRef'; 4 - import { getConfig } from '../../config'; 4 + import { getParserConfig } from '../../config'; 5 5 import type { OpenApi } from '../interfaces/OpenApi'; 6 6 import type { OpenApiParameter } from '../interfaces/OpenApiParameter'; 7 7 import { getOperationParameter } from './getOperationParameter'; ··· 17 17 parameters: OpenApiParameter[]; 18 18 types: Client['types']; 19 19 }): OperationParameters => { 20 - const config = getConfig(); 20 + const config = getParserConfig(); 21 21 22 22 const operationParameters: OperationParameters = { 23 23 $refs: [], ··· 42 42 types, 43 43 }); 44 44 45 - const skip = 46 - config.filterFn?.operationParameter && 47 - !config.filterFn?.operationParameter(parameter); 45 + const skip = !config.filterFn.operationParameter(parameter); 48 46 if (!allowedIn.includes(parameterDef.in) || skip) { 49 47 return; 50 48 }
+10 -7
packages/openapi-ts/src/openApi/v2/parser/getOperations.ts
··· 1 + import { getConfig } from '../../../utils/config'; 1 2 import type { Client, Operation } from '../../common/interfaces/client'; 2 3 import { getOperationKey } from '../../common/parser/operation'; 3 4 import { allowedServiceMethods } from '../../common/parser/service'; 4 - import { getConfig } from '../../config'; 5 + import { getParserConfig } from '../../config'; 5 6 import type { OpenApi } from '../interfaces/OpenApi'; 6 7 import { getOperationParameters } from './getOperationParameters'; 7 8 import { getOperation } from './operation'; ··· 13 14 openApi: OpenApi; 14 15 types: Client['types']; 15 16 }): Operation[] => { 16 - const config = getConfig(); 17 + const config = getParserConfig(); 17 18 18 19 const operationIds = new Map<string, string>(); 19 20 const operations: Operation[] = []; ··· 26 27 types, 27 28 }); 28 29 29 - for (const key in pathItem) { 30 - const method = key as Lowercase<Operation['method']>; 30 + for (const name in pathItem) { 31 + const method = name as Lowercase<Operation['method']>; 31 32 32 33 const operationKey = getOperationKey({ 33 - method: method.toUpperCase(), 34 + method, 34 35 path, 35 36 }); 36 37 ··· 48 49 } 49 50 50 51 if ( 51 - !config.filterFn?.operation || 52 - config.filterFn?.operation(operationKey) 52 + config.filterFn.operation({ 53 + config: getConfig(), 54 + operationKey, 55 + }) 53 56 ) { 54 57 const operation = getOperation({ 55 58 method,
+9 -3
packages/openapi-ts/src/openApi/v2/parser/operation.ts
··· 1 1 import type { Client } from '../../../types/client'; 2 + import { getConfig } from '../../../utils/config'; 2 3 import type { 3 4 Operation, 4 5 OperationParameters, 5 6 } from '../../common/interfaces/client'; 6 7 import { getOperationResponseHeader } from '../../common/parser/operation'; 7 8 import { toSortedByRequired } from '../../common/parser/sort'; 8 - import { getConfig } from '../../config'; 9 + import { getParserConfig } from '../../config'; 9 10 import type { OpenApi } from '../interfaces/OpenApi'; 10 11 import type { OpenApiOperation } from '../interfaces/OpenApiOperation'; 11 12 import { getOperationParameters } from './getOperationParameters'; ··· 26 27 types: Client['types']; 27 28 url: string; 28 29 }): Operation => { 29 - const config = getConfig(); 30 + const config = getParserConfig(); 30 31 31 32 const operationWithoutName: Omit<Operation, 'name'> = { 32 33 $refs: [], ··· 50 51 }; 51 52 const operation = { 52 53 ...operationWithoutName, 53 - name: config.nameFn.operation(operationWithoutName), 54 + name: config.nameFn.operation({ 55 + config: getConfig(), 56 + method: operationWithoutName.method, 57 + operationId: op.operationId, 58 + path: operationWithoutName.path, 59 + }), 54 60 }; 55 61 56 62 if (op.parameters) {
+2 -2
packages/openapi-ts/src/openApi/v3/parser/discriminator.ts
··· 6 6 7 7 const inverseDictionary = (map: Dictionary<string>): Dictionary<string> => { 8 8 const m2: Dictionary<string> = {}; 9 - for (const key in map) { 10 - m2[map[key]] = key; 9 + for (const name in map) { 10 + m2[map[name]] = name; 11 11 } 12 12 return m2; 13 13 };
+2 -2
packages/openapi-ts/src/openApi/v3/parser/getModels.ts
··· 1 1 import type { Client } from '../../../types/client'; 2 2 import { getParametersMeta, getSchemasMeta } from '../../../utils/meta'; 3 - import { getConfig } from '../../config'; 3 + import { getParserConfig } from '../../config'; 4 4 import type { OpenApi } from '../interfaces/OpenApi'; 5 5 import { getModel } from './getModel'; 6 6 import { getParameterSchema } from './parameter'; ··· 8 8 export const getModels = ( 9 9 openApi: OpenApi, 10 10 ): Pick<Client, 'models' | 'types'> => { 11 - const config = getConfig(); 11 + const config = getParserConfig(); 12 12 13 13 const types: Client['types'] = {}; 14 14 let models: Client['models'] = [];
+2 -2
packages/openapi-ts/src/openApi/v3/parser/getOperationParameter.ts
··· 6 6 import { getPattern } from '../../common/parser/getPattern'; 7 7 import { getRef } from '../../common/parser/getRef'; 8 8 import { getType } from '../../common/parser/type'; 9 - import { getConfig } from '../../config'; 9 + import { getParserConfig } from '../../config'; 10 10 import type { OpenApi } from '../interfaces/OpenApi'; 11 11 import type { OpenApiParameter } from '../interfaces/OpenApiParameter'; 12 12 import type { OpenApiSchema } from '../interfaces/OpenApiSchema'; ··· 23 23 parameter: OpenApiParameter; 24 24 types: Client['types']; 25 25 }): OperationParameter => { 26 - const config = getConfig(); 26 + const config = getParserConfig(); 27 27 28 28 const operationParameterWithoutName: Omit<OperationParameter, 'name'> = { 29 29 $refs: [],
+3 -5
packages/openapi-ts/src/openApi/v3/parser/getOperationParameters.ts
··· 1 1 import type { Client } from '../../../types/client'; 2 2 import type { OperationParameters } from '../../common/interfaces/client'; 3 3 import { getRef } from '../../common/parser/getRef'; 4 - import { getConfig } from '../../config'; 4 + import { getParserConfig } from '../../config'; 5 5 import type { OpenApi } from '../interfaces/OpenApi'; 6 6 import type { OpenApiParameter } from '../interfaces/OpenApiParameter'; 7 7 import { getOperationParameter } from './getOperationParameter'; ··· 17 17 parameters: OpenApiParameter[]; 18 18 types: Client['types']; 19 19 }): OperationParameters => { 20 - const config = getConfig(); 20 + const config = getParserConfig(); 21 21 22 22 const operationParameters: OperationParameters = { 23 23 $refs: [], ··· 42 42 types, 43 43 }); 44 44 45 - const skip = 46 - config.filterFn?.operationParameter && 47 - !config.filterFn?.operationParameter(parameter); 45 + const skip = !config.filterFn.operationParameter(parameter); 48 46 if (!allowedIn.includes(parameterDef.in) || skip) { 49 47 return; 50 48 }
+10 -7
packages/openapi-ts/src/openApi/v3/parser/getOperations.ts
··· 1 + import { getConfig } from '../../../utils/config'; 1 2 import type { Client, Operation } from '../../common/interfaces/client'; 2 3 import { getOperationKey } from '../../common/parser/operation'; 3 4 import { allowedServiceMethods } from '../../common/parser/service'; 4 - import { getConfig } from '../../config'; 5 + import { getParserConfig } from '../../config'; 5 6 import type { OpenApi } from '../interfaces/OpenApi'; 6 7 import { getOperationParameters } from './getOperationParameters'; 7 8 import { getOperation } from './operation'; ··· 13 14 openApi: OpenApi; 14 15 types: Client['types']; 15 16 }): Operation[] => { 16 - const config = getConfig(); 17 + const config = getParserConfig(); 17 18 18 19 const operationIds = new Map<string, string>(); 19 20 const operations: Operation[] = []; ··· 26 27 types, 27 28 }); 28 29 29 - for (const key in pathItem) { 30 - const method = key as Lowercase<Operation['method']>; 30 + for (const name in pathItem) { 31 + const method = name as Lowercase<Operation['method']>; 31 32 32 33 const operationKey = getOperationKey({ 33 - method: method.toUpperCase(), 34 + method, 34 35 path, 35 36 }); 36 37 ··· 48 49 } 49 50 50 51 if ( 51 - !config.filterFn?.operation || 52 - config.filterFn?.operation(operationKey) 52 + config.filterFn.operation({ 53 + config: getConfig(), 54 + operationKey, 55 + }) 53 56 ) { 54 57 const operation = getOperation({ 55 58 method,
+9 -3
packages/openapi-ts/src/openApi/v3/parser/operation.ts
··· 1 1 import type { Client } from '../../../types/client'; 2 + import { getConfig } from '../../../utils/config'; 2 3 import type { 3 4 Operation, 4 5 OperationParameter, ··· 7 8 import { getRef } from '../../common/parser/getRef'; 8 9 import { getOperationResponseHeader } from '../../common/parser/operation'; 9 10 import { toSortedByRequired } from '../../common/parser/sort'; 10 - import { getConfig } from '../../config'; 11 + import { getParserConfig } from '../../config'; 11 12 import type { OpenApi } from '../interfaces/OpenApi'; 12 13 import type { OpenApiOperation } from '../interfaces/OpenApiOperation'; 13 14 import type { OpenApiRequestBody } from '../interfaces/OpenApiRequestBody'; ··· 53 54 types: Client['types']; 54 55 url: string; 55 56 }): Operation => { 56 - const config = getConfig(); 57 + const config = getParserConfig(); 57 58 58 59 const operationWithoutName: Omit<Operation, 'name'> = { 59 60 $refs: [], ··· 77 78 }; 78 79 const operation = { 79 80 ...operationWithoutName, 80 - name: config.nameFn.operation(operationWithoutName), 81 + name: config.nameFn.operation({ 82 + config: getConfig(), 83 + method: operationWithoutName.method, 84 + operationId: op.operationId, 85 + path: operationWithoutName.path, 86 + }), 81 87 }; 82 88 83 89 if (op.parameters) {
+1
packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts
··· 2 2 3 3 export const defaultConfig: Required<PluginConfig> = { 4 4 handler: () => {}, 5 + handler_experimental: () => {}, 5 6 name: '@hey-api/schemas', 6 7 output: 'schemas', 7 8 };
+2 -1
packages/openapi-ts/src/plugins/@hey-api/schemas/types.ts
··· 1 - import type { PluginHandler } from '../../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 2 2 3 3 interface Config { 4 4 /** ··· 14 14 15 15 export interface PluginConfig extends Config { 16 16 handler: PluginHandler<Config>; 17 + handler_experimental?: PluginHandlerExperimental<Config>; 17 18 } 18 19 19 20 export interface UserConfig extends Omit<Config, 'output'> {}
+1
packages/openapi-ts/src/plugins/@hey-api/services/config.ts
··· 2 2 3 3 export const defaultConfig: Required<PluginConfig> = { 4 4 handler: () => {}, 5 + handler_experimental: () => {}, 5 6 name: '@hey-api/services', 6 7 output: 'services', 7 8 };
+2 -1
packages/openapi-ts/src/plugins/@hey-api/services/types.ts
··· 1 - import type { PluginHandler } from '../../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 2 2 3 3 interface Config { 4 4 /** ··· 14 14 15 15 export interface PluginConfig extends Config { 16 16 handler: PluginHandler<Config>; 17 + handler_experimental?: PluginHandlerExperimental<Config>; 17 18 } 18 19 19 20 export interface UserConfig extends Omit<Config, 'output'> {}
+1
packages/openapi-ts/src/plugins/@hey-api/types/config.ts
··· 2 2 3 3 export const defaultConfig: Required<PluginConfig> = { 4 4 handler: () => {}, 5 + handler_experimental: () => {}, 5 6 name: '@hey-api/types', 6 7 output: 'types', 7 8 };
+2 -1
packages/openapi-ts/src/plugins/@hey-api/types/types.ts
··· 1 - import type { PluginHandler } from '../../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 2 2 3 3 interface Config { 4 4 /** ··· 14 14 15 15 export interface PluginConfig extends Config { 16 16 handler: PluginHandler<Config>; 17 + handler_experimental?: PluginHandlerExperimental<Config>; 17 18 } 18 19 19 20 export interface UserConfig extends Omit<Config, 'output'> {}
+331 -23
packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts
··· 16 16 toOperationName, 17 17 } from '../../../generate/services'; 18 18 import { relativeModulePath } from '../../../generate/utils'; 19 + import type { IROperationObject, IRPathsObject } from '../../../ir/ir'; 20 + import { hasParametersObjectRequired } from '../../../ir/parameter'; 19 21 import { isOperationParameterRequired } from '../../../openApi'; 20 22 import { getOperationKey } from '../../../openApi/common/parser/operation'; 21 23 import type { ··· 25 27 Operation, 26 28 OperationParameter, 27 29 } from '../../../types/client'; 30 + import type { Config } from '../../../types/config'; 28 31 import type { Files } from '../../../types/utils'; 29 32 import { getConfig } from '../../../utils/config'; 33 + import { getServiceName } from '../../../utils/postprocess'; 30 34 import { transformServiceName } from '../../../utils/transform'; 31 - import type { PluginHandler } from '../../types'; 35 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 32 36 import type { PluginConfig as ReactQueryPluginConfig } from '../react-query'; 33 37 import type { PluginConfig as SolidQueryPluginConfig } from '../solid-query'; 34 38 import type { PluginConfig as SvelteQueryPluginConfig } from '../svelte-query'; 35 39 import type { PluginConfig as VueQueryPluginConfig } from '../vue-query'; 36 40 37 41 const toInfiniteQueryOptionsName = (operation: Operation) => 38 - `${toOperationName(operation, false)}InfiniteOptions`; 42 + `${toOperationName({ 43 + config: getConfig(), 44 + id: operation.name, 45 + operation, 46 + })}InfiniteOptions`; 39 47 40 48 const toMutationOptionsName = (operation: Operation) => 41 - `${toOperationName(operation, false)}Mutation`; 49 + `${toOperationName({ 50 + config: getConfig(), 51 + id: operation.name, 52 + operation, 53 + })}Mutation`; 42 54 43 - const toQueryOptionsName = (operation: Operation) => 44 - `${toOperationName(operation, false)}Options`; 55 + const toQueryOptionsName = ({ 56 + config, 57 + id, 58 + operation, 59 + }: { 60 + config: Config; 61 + id: string; 62 + operation: IROperationObject | Operation; 63 + }) => 64 + `${toOperationName({ 65 + config, 66 + id, 67 + operation, 68 + })}Options`; 45 69 46 - const toQueryKeyName = (operation: Operation, isInfinite?: boolean) => 47 - `${toOperationName(operation, false)}${isInfinite ? 'Infinite' : ''}QueryKey`; 70 + const toQueryKeyName = ({ 71 + config, 72 + id, 73 + operation, 74 + isInfinite, 75 + }: { 76 + config: Config; 77 + id: string; 78 + isInfinite?: boolean; 79 + operation: IROperationObject | Operation; 80 + }) => 81 + `${toOperationName({ 82 + config, 83 + id, 84 + operation, 85 + })}${isInfinite ? 'Infinite' : ''}QueryKey`; 48 86 49 87 const checkPrerequisites = ({ files }: { files: Files }) => { 50 88 if (!files.services) { ··· 473 511 compiler.typeReferenceNode({ 474 512 typeName: `Pick<${TOptionsType}, '${getClientBaseUrlKey()}' | 'body' | 'headers' | 'path' | 'query'>`, 475 513 }), 476 - compiler.typeInterfaceNode({ properties }), 514 + compiler.typeInterfaceNode({ 515 + properties, 516 + useLegacyResolution: true, 517 + }), 477 518 ], 478 519 }), 479 520 ], ··· 624 665 625 666 const createQueryKeyLiteral = ({ 626 667 isInfinite, 627 - operation, 668 + id, 628 669 }: { 670 + id: string; 629 671 isInfinite?: boolean; 630 - operation: Operation; 631 672 }) => { 632 673 const queryKeyLiteral = compiler.arrayLiteralExpression({ 633 674 elements: [ 634 675 compiler.callExpression({ 635 676 functionName: createQueryKeyFn, 636 677 parameters: [ 637 - compiler.stringLiteral({ text: operation.name }), 678 + compiler.ots.string(id), 638 679 'options', 639 680 isInfinite ? compiler.ots.boolean(true) : undefined, 640 681 ], ··· 692 733 processedOperations.set(operationKey, true); 693 734 694 735 const queryFn = [ 695 - config.services.asClass && transformServiceName(service.name), 696 - toOperationName(operation, !config.services.asClass), 736 + config.services.asClass && 737 + transformServiceName({ 738 + config, 739 + name: service.name, 740 + }), 741 + toOperationName({ 742 + config, 743 + handleIllegal: !config.services.asClass, 744 + id: operation.name, 745 + operation, 746 + }), 697 747 ] 698 748 .filter(Boolean) 699 749 .join('.'); ··· 741 791 }, 742 792 ], 743 793 statements: createQueryKeyLiteral({ 744 - operation, 794 + id: operation.name, 745 795 }), 746 796 }), 747 - name: toQueryKeyName(operation), 797 + name: toQueryKeyName({ 798 + config, 799 + id: operation.name, 800 + operation, 801 + }), 748 802 }); 749 803 file.add(queryKeyStatement); 750 804 ··· 811 865 { 812 866 key: 'queryKey', 813 867 value: compiler.callExpression({ 814 - functionName: toQueryKeyName(operation), 868 + functionName: toQueryKeyName({ 869 + config, 870 + id: operation.name, 871 + operation, 872 + }), 815 873 parameters: ['options'], 816 874 }), 817 875 }, ··· 827 885 comment: [], 828 886 exportConst: true, 829 887 expression, 830 - name: toQueryOptionsName(operation), 888 + name: toQueryOptionsName({ 889 + config, 890 + id: operation.name, 891 + operation, 892 + }), 831 893 // TODO: add type error 832 894 // TODO: AxiosError<PutSubmissionMetaError> 833 895 }); ··· 943 1005 ], 944 1006 returnType: typeQueryKey, 945 1007 statements: createQueryKeyLiteral({ 1008 + id: operation.name, 946 1009 isInfinite: true, 947 - operation, 948 1010 }), 949 1011 }), 950 - name: toQueryKeyName(operation, true), 1012 + name: toQueryKeyName({ 1013 + config, 1014 + id: operation.name, 1015 + isInfinite: true, 1016 + operation, 1017 + }), 951 1018 }); 952 1019 file.add(queryKeyStatement); 953 1020 ··· 1001 1068 text: 'pageParam', 1002 1069 }), 1003 1070 operator: '===', 1004 - right: compiler.stringLiteral({ 1005 - text: 'object', 1006 - }), 1071 + right: compiler.ots.string('object'), 1007 1072 }), 1008 1073 whenFalse: compiler.objectExpression({ 1009 1074 multiLine: true, ··· 1073 1138 { 1074 1139 key: 'queryKey', 1075 1140 value: compiler.callExpression({ 1076 - functionName: toQueryKeyName(operation, true), 1141 + functionName: toQueryKeyName({ 1142 + config, 1143 + id: operation.name, 1144 + isInfinite: true, 1145 + operation, 1146 + }), 1077 1147 parameters: ['options'], 1078 1148 }), 1079 1149 }, ··· 1239 1309 } 1240 1310 } 1241 1311 }; 1312 + 1313 + export const handler_experimental: PluginHandlerExperimental< 1314 + | ReactQueryPluginConfig 1315 + | SolidQueryPluginConfig 1316 + | SvelteQueryPluginConfig 1317 + | VueQueryPluginConfig 1318 + > = ({ context, files, plugin }) => { 1319 + checkPrerequisites({ files }); 1320 + 1321 + const file = files[plugin.name]; 1322 + 1323 + // file.import({ 1324 + // asType: true, 1325 + // module: clientModulePath({ sourceOutput: plugin.output }), 1326 + // name: clientOptionsTypeName(), 1327 + // }); 1328 + 1329 + // const typesModulePath = relativeModulePath({ 1330 + // moduleOutput: files.types.getName(false), 1331 + // sourceOutput: plugin.output, 1332 + // }); 1333 + 1334 + // @ts-ignore 1335 + // eslint-disable-next-line @typescript-eslint/no-unused-vars 1336 + const mutationsType = 1337 + plugin.name === '@tanstack/svelte-query' || 1338 + plugin.name === '@tanstack/solid-query' 1339 + ? 'MutationOptions' 1340 + : 'UseMutationOptions'; 1341 + 1342 + // @ts-ignore 1343 + // eslint-disable-next-line @typescript-eslint/no-unused-vars 1344 + let typeInfiniteData!: ImportExportItem; 1345 + // let hasCreateInfiniteParamsFunction = false; 1346 + let hasCreateQueryKeyParamsFunction = false; 1347 + // eslint-disable-next-line prefer-const 1348 + let hasInfiniteQueries = false; 1349 + // let hasMutations = false; 1350 + let hasQueries = false; 1351 + 1352 + for (const path in context.ir.paths) { 1353 + const pathItem = context.ir.paths[path as keyof IRPathsObject]; 1354 + 1355 + const queryOperations: ReadonlyArray<IROperationObject> = [ 1356 + pathItem.get, 1357 + pathItem.post, 1358 + ].filter(Boolean) as ReadonlyArray<IROperationObject>; 1359 + 1360 + // console.warn(pathItem) 1361 + let hasUsedQueryFn = false; 1362 + 1363 + // queries 1364 + if (plugin.queryOptions) { 1365 + for (const operation of queryOperations) { 1366 + const queryFn = [ 1367 + context.config.services.asClass && 1368 + transformServiceName({ 1369 + config: context.config, 1370 + // TODO: parser - handle import from services, it will be enough to 1371 + // know one service that contains this operation 1372 + // name: service.name, 1373 + name: getServiceName('TODO'), 1374 + }), 1375 + toOperationName({ 1376 + config: context.config, 1377 + handleIllegal: !context.config.services.asClass, 1378 + id: operation.id, 1379 + operation, 1380 + }), 1381 + ] 1382 + .filter(Boolean) 1383 + .join('.'); 1384 + 1385 + if (!hasQueries) { 1386 + hasQueries = true; 1387 + 1388 + if (!hasCreateQueryKeyParamsFunction) { 1389 + createQueryKeyType({ file }); 1390 + createQueryKeyFunction({ file }); 1391 + hasCreateQueryKeyParamsFunction = true; 1392 + } 1393 + 1394 + file.import({ 1395 + module: plugin.name, 1396 + name: queryOptionsFn, 1397 + }); 1398 + } 1399 + 1400 + hasUsedQueryFn = true; 1401 + 1402 + // TODO: parser - update this after rewriting services 1403 + const typeData = 'TODO'; 1404 + // const { typeData } = createTypeData({ 1405 + // client, 1406 + // file, 1407 + // operation, 1408 + // typesModulePath, 1409 + // }); 1410 + 1411 + const isRequired = hasParametersObjectRequired(operation.parameters); 1412 + 1413 + const queryKeyStatement = compiler.constVariable({ 1414 + exportConst: true, 1415 + expression: compiler.arrowFunction({ 1416 + parameters: [ 1417 + { 1418 + isRequired, 1419 + name: 'options', 1420 + type: typeData, 1421 + }, 1422 + ], 1423 + statements: createQueryKeyLiteral({ 1424 + id: operation.id, 1425 + }), 1426 + }), 1427 + name: toQueryKeyName({ 1428 + config: context.config, 1429 + id: operation.id, 1430 + operation, 1431 + }), 1432 + }); 1433 + file.add(queryKeyStatement); 1434 + 1435 + const expression = compiler.arrowFunction({ 1436 + parameters: [ 1437 + { 1438 + isRequired, 1439 + name: 'options', 1440 + type: typeData, 1441 + }, 1442 + ], 1443 + statements: [ 1444 + compiler.returnFunctionCall({ 1445 + args: [ 1446 + compiler.objectExpression({ 1447 + obj: [ 1448 + { 1449 + key: 'queryFn', 1450 + value: compiler.arrowFunction({ 1451 + async: true, 1452 + multiLine: true, 1453 + parameters: [ 1454 + { 1455 + destructure: [ 1456 + { 1457 + name: 'queryKey', 1458 + }, 1459 + ], 1460 + }, 1461 + ], 1462 + statements: [ 1463 + compiler.constVariable({ 1464 + destructure: true, 1465 + expression: compiler.awaitExpression({ 1466 + expression: compiler.callExpression({ 1467 + functionName: queryFn, 1468 + parameters: [ 1469 + compiler.objectExpression({ 1470 + multiLine: true, 1471 + obj: [ 1472 + { 1473 + spread: 'options', 1474 + }, 1475 + { 1476 + spread: 'queryKey[0]', 1477 + }, 1478 + { 1479 + key: 'throwOnError', 1480 + value: true, 1481 + }, 1482 + ], 1483 + }), 1484 + ], 1485 + }), 1486 + }), 1487 + name: 'data', 1488 + }), 1489 + compiler.returnVariable({ 1490 + expression: 'data', 1491 + }), 1492 + ], 1493 + }), 1494 + }, 1495 + { 1496 + key: 'queryKey', 1497 + value: compiler.callExpression({ 1498 + functionName: toQueryKeyName({ 1499 + config: context.config, 1500 + id: operation.id, 1501 + operation, 1502 + }), 1503 + parameters: ['options'], 1504 + }), 1505 + }, 1506 + ], 1507 + }), 1508 + ], 1509 + name: queryOptionsFn, 1510 + }), 1511 + ], 1512 + }); 1513 + const statement = compiler.constVariable({ 1514 + // TODO: describe options, same as the actual function call 1515 + comment: [], 1516 + exportConst: true, 1517 + expression, 1518 + name: toQueryOptionsName({ 1519 + config: context.config, 1520 + id: operation.id, 1521 + operation, 1522 + }), 1523 + // TODO: add type error 1524 + // TODO: AxiosError<PutSubmissionMetaError> 1525 + }); 1526 + file.add(statement); 1527 + } 1528 + } 1529 + 1530 + // const servicesModulePath = relativeModulePath({ 1531 + // moduleOutput: files.services.getName(false), 1532 + // sourceOutput: plugin.output, 1533 + // }); 1534 + 1535 + if (hasQueries || hasInfiniteQueries) { 1536 + // file.import({ 1537 + // module: servicesModulePath, 1538 + // name: 'client', 1539 + // }); 1540 + } 1541 + 1542 + if (hasUsedQueryFn) { 1543 + // file.import({ 1544 + // module: servicesModulePath, 1545 + // name: queryFn.split('.')[0], 1546 + // }); 1547 + } 1548 + } 1549 + };
+2 -1
packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts
··· 1 - import { handler } from '../query-core/plugin'; 1 + import { handler, handler_experimental } from '../query-core/plugin'; 2 2 import type { PluginConfig } from './types'; 3 3 4 4 export const defaultConfig: Required<PluginConfig> = { 5 5 handler, 6 + handler_experimental, 6 7 infiniteQueryOptions: true, 7 8 mutationOptions: true, 8 9 name: '@tanstack/react-query',
+2 -1
packages/openapi-ts/src/plugins/@tanstack/react-query/types.ts
··· 1 - import type { PluginHandler } from '../../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 2 2 3 3 interface Config { 4 4 /** ··· 30 30 31 31 export interface PluginConfig extends Config { 32 32 handler: PluginHandler<Config>; 33 + handler_experimental?: PluginHandlerExperimental<Config>; 33 34 } 34 35 35 36 export interface UserConfig extends Omit<Config, 'output'> {}
+2 -1
packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts
··· 1 - import { handler } from '../query-core/plugin'; 1 + import { handler, handler_experimental } from '../query-core/plugin'; 2 2 import type { PluginConfig } from './types'; 3 3 4 4 export const defaultConfig: Required<PluginConfig> = { 5 5 handler, 6 + handler_experimental, 6 7 infiniteQueryOptions: true, 7 8 mutationOptions: true, 8 9 name: '@tanstack/solid-query',
+2 -1
packages/openapi-ts/src/plugins/@tanstack/solid-query/types.ts
··· 1 - import type { PluginHandler } from '../../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 2 2 3 3 interface Config { 4 4 /** ··· 30 30 31 31 export interface PluginConfig extends Config { 32 32 handler: PluginHandler<Config>; 33 + handler_experimental?: PluginHandlerExperimental<Config>; 33 34 } 34 35 35 36 export interface UserConfig extends Omit<Config, 'output'> {}
+2 -1
packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts
··· 1 - import { handler } from '../query-core/plugin'; 1 + import { handler, handler_experimental } from '../query-core/plugin'; 2 2 import type { PluginConfig } from './types'; 3 3 4 4 export const defaultConfig: Required<PluginConfig> = { 5 5 handler, 6 + handler_experimental, 6 7 infiniteQueryOptions: true, 7 8 mutationOptions: true, 8 9 name: '@tanstack/svelte-query',
+2 -1
packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.ts
··· 1 - import type { PluginHandler } from '../../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 2 2 3 3 interface Config { 4 4 /** ··· 30 30 31 31 export interface PluginConfig extends Config { 32 32 handler: PluginHandler<Config>; 33 + handler_experimental?: PluginHandlerExperimental<Config>; 33 34 } 34 35 35 36 export interface UserConfig extends Omit<Config, 'output'> {}
+2 -1
packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts
··· 1 - import { handler } from '../query-core/plugin'; 1 + import { handler, handler_experimental } from '../query-core/plugin'; 2 2 import type { PluginConfig } from './types'; 3 3 4 4 export const defaultConfig: Required<PluginConfig> = { 5 5 handler, 6 + handler_experimental, 6 7 infiniteQueryOptions: true, 7 8 mutationOptions: true, 8 9 name: '@tanstack/vue-query',
+2 -1
packages/openapi-ts/src/plugins/@tanstack/vue-query/types.ts
··· 1 - import type { PluginHandler } from '../../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../../types'; 2 2 3 3 interface Config { 4 4 /** ··· 30 30 31 31 export interface PluginConfig extends Config { 32 32 handler: PluginHandler<Config>; 33 + handler_experimental?: PluginHandlerExperimental<Config>; 33 34 } 34 35 35 36 export interface UserConfig extends Omit<Config, 'output'> {}
+11 -1
packages/openapi-ts/src/plugins/types.ts
··· 1 + import type { IRContext } from '../ir/context'; 1 2 import type { Client } from '../types/client'; 2 3 import type { Files } from '../types/utils'; 3 4 4 5 export type PluginHandler<PluginConfig> = (args: { 5 6 client: Client; 6 7 files: Files; 7 - plugin: Omit<Required<PluginConfig>, 'handler'>; 8 + plugin: Omit<Required<PluginConfig>, 'handler' | 'handler_experimental'>; 9 + }) => void; 10 + 11 + export type PluginHandlerExperimental<PluginConfig> = (args: { 12 + context: IRContext; 13 + files: Files; 14 + plugin: Omit<Required<PluginConfig>, 'handler' | 'handler_experimental'>; 8 15 }) => void; 9 16 10 17 type KeyTypes = string | number | symbol; ··· 21 28 > = { 22 29 [K in U]: { 23 30 handler: PluginHandler<Required<Extract<T, { name: K }>>>; 31 + handler_experimental?: PluginHandlerExperimental< 32 + Required<Extract<T, { name: K }>> 33 + >; 24 34 name: string; 25 35 output?: string; 26 36 };
+1
packages/openapi-ts/src/plugins/zod/config.ts
··· 3 3 4 4 export const defaultConfig: Required<PluginConfig> = { 5 5 handler, 6 + handler_experimental: () => {}, 6 7 name: 'zod', 7 8 output: 'zod', 8 9 };
+207 -2
packages/openapi-ts/src/plugins/zod/plugin.ts
··· 1 + import { compiler } from '../../compiler'; 2 + import type { TypeScriptFile } from '../../generate/files'; 3 + import type { Client, Model } from '../../types/client'; 1 4 import type { PluginHandler } from '../types'; 2 5 import type { PluginConfig } from './types'; 3 6 4 - export const handler: PluginHandler<PluginConfig> = ({ plugin }) => { 5 - console.warn(plugin); 7 + interface TypesProps { 8 + client: Client; 9 + file: TypeScriptFile; 10 + model: Model; 11 + onRemoveNode?: VoidFunction; 12 + } 13 + 14 + const processArray = ({ file, model }: TypesProps) => { 15 + const identifier = file.identifier({ 16 + $ref: model.meta?.$ref || '', 17 + create: true, 18 + namespace: 'value', 19 + }); 20 + 21 + if (!identifier.created) { 22 + return; 23 + } 24 + 25 + const zArrayExpression = compiler.callExpression({ 26 + functionName: compiler.propertyAccessExpression({ 27 + expression: 'z', 28 + name: 'array', 29 + }), 30 + parameters: [ 31 + compiler.callExpression({ 32 + functionName: compiler.propertyAccessExpression({ 33 + expression: 'z', 34 + name: model.base, 35 + }), 36 + }), 37 + ], 38 + }); 39 + 40 + if (model.base === 'string' || model.base === 'boolean') { 41 + const statement = compiler.constVariable({ 42 + exportConst: true, 43 + expression: zArrayExpression, 44 + name: identifier.name, 45 + }); 46 + file.add(statement); 47 + return; 48 + } 49 + 50 + if (model.base === 'number') { 51 + let expression = zArrayExpression; 52 + 53 + if (model.minItems && model.maxItems && model.minItems === model.maxItems) { 54 + expression = compiler.callExpression({ 55 + functionName: compiler.propertyAccessExpression({ 56 + expression, 57 + name: 'length', 58 + }), 59 + parameters: [compiler.ots.number(model.minItems)], 60 + }); 61 + } else { 62 + if (model.minItems) { 63 + expression = compiler.callExpression({ 64 + functionName: compiler.propertyAccessExpression({ 65 + expression, 66 + name: 'min', 67 + }), 68 + parameters: [compiler.ots.number(model.minItems)], 69 + }); 70 + } 71 + 72 + if (model.maxItems) { 73 + expression = compiler.callExpression({ 74 + functionName: compiler.propertyAccessExpression({ 75 + expression, 76 + name: 'max', 77 + }), 78 + parameters: [compiler.ots.number(model.maxItems)], 79 + }); 80 + } 81 + } 82 + 83 + const statement = compiler.constVariable({ 84 + exportConst: true, 85 + expression, 86 + name: identifier.name, 87 + }); 88 + file.add(statement); 89 + return; 90 + } 91 + 92 + // console.warn('array!', model.base, model.name) 93 + const statement = compiler.constVariable({ 94 + exportConst: true, 95 + expression: compiler.callExpression({ 96 + functionName: compiler.propertyAccessExpression({ 97 + expression: 'z', 98 + name: 'object', 99 + }), 100 + parameters: [ 101 + compiler.objectExpression({ 102 + multiLine: true, 103 + obj: [], 104 + }), 105 + ], 106 + }), 107 + name: identifier.name, 108 + }); 109 + file.add(statement); 110 + }; 111 + 112 + const processGeneric = ({ file, model }: TypesProps) => { 113 + const identifier = file.identifier({ 114 + $ref: model.meta?.$ref || '', 115 + create: true, 116 + namespace: 'value', 117 + }); 118 + 119 + if (!identifier.created) { 120 + return; 121 + } 122 + 123 + if (model.base === 'string') { 124 + const statement = compiler.constVariable({ 125 + exportConst: true, 126 + expression: compiler.callExpression({ 127 + functionName: compiler.propertyAccessExpression({ 128 + expression: 'z', 129 + name: 'string', 130 + }), 131 + }), 132 + name: identifier.name, 133 + }); 134 + file.add(statement); 135 + return; 136 + } 137 + 138 + if (model.base === 'boolean') { 139 + // console.warn(model) 140 + const statement = compiler.constVariable({ 141 + exportConst: true, 142 + expression: compiler.callExpression({ 143 + functionName: compiler.propertyAccessExpression({ 144 + expression: 'z', 145 + name: 'boolean', 146 + }), 147 + }), 148 + name: identifier.name, 149 + }); 150 + file.add(statement); 151 + return; 152 + } 153 + 154 + // console.warn(model.base) 155 + const statement = compiler.constVariable({ 156 + exportConst: true, 157 + expression: compiler.callExpression({ 158 + functionName: compiler.propertyAccessExpression({ 159 + expression: 'z', 160 + name: 'object', 161 + }), 162 + parameters: [ 163 + compiler.objectExpression({ 164 + multiLine: true, 165 + obj: [], 166 + }), 167 + ], 168 + }), 169 + name: identifier.name, 170 + }); 171 + file.add(statement); 172 + }; 173 + 174 + const processModel = (props: TypesProps) => { 175 + switch (props.model.export) { 176 + case 'all-of': 177 + case 'any-of': 178 + case 'one-of': 179 + case 'interface': 180 + // return processComposition(props); 181 + return; 182 + case 'array': 183 + return processArray(props); 184 + case 'enum': 185 + // return processEnum(props); 186 + return; 187 + default: 188 + return processGeneric(props); 189 + } 190 + }; 191 + 192 + export const handler: PluginHandler<PluginConfig> = ({ 193 + client, 194 + files, 195 + plugin, 196 + }) => { 197 + const file = files[plugin.name]; 198 + 199 + file.import({ 200 + module: 'zod', 201 + name: 'z', 202 + }); 203 + 204 + for (const model of client.models) { 205 + processModel({ 206 + client, 207 + file, 208 + model, 209 + }); 210 + } 6 211 };
+2 -1
packages/openapi-ts/src/plugins/zod/types.ts
··· 1 - import type { PluginHandler } from '../types'; 1 + import type { PluginHandler, PluginHandlerExperimental } from '../types'; 2 2 3 3 interface Config { 4 4 /** ··· 14 14 15 15 export interface PluginConfig extends Config { 16 16 handler: PluginHandler<Config>; 17 + handler_experimental?: PluginHandlerExperimental<Config>; 17 18 } 18 19 19 20 export interface UserConfig extends Omit<Config, 'output'> {}
+6 -2
packages/openapi-ts/src/types/config.ts
··· 1 + import type { IROperationObject } from '../ir/ir'; 1 2 import type { OpenApiV2Schema, OpenApiV3Schema } from '../openApi'; 2 3 import type { ClientPlugins, UserPlugins } from '../plugins/'; 3 4 import type { Operation } from '../types/client'; ··· 175 176 */ 176 177 include?: string; 177 178 /** 178 - * Customise the name of methods within the service. By default, {@link Operation.name} is used. 179 + * Customise the name of methods within the service. By default, {@link IROperationObject.id} or {@link Operation.name} is used. 179 180 */ 180 - methodNameBuilder?: (operation: Operation) => string; 181 + methodNameBuilder?: ( 182 + operation: IROperationObject | Operation, 183 + ) => string; 181 184 /** 182 185 * Customize the generated service class names. The name variable is 183 186 * obtained from your OpenAPI specification tags. ··· 186 189 * @default '{{name}}Service' 187 190 */ 188 191 name?: string; 192 + // TODO: parser - rename operationId option to something like inferId?: boolean 189 193 /** 190 194 * Use operation ID to generate operation names? 191 195 * @default true
+1 -1
packages/openapi-ts/src/types/utils.ts
··· 1 - import type { TypeScriptFile } from '../compiler'; 1 + import type { TypeScriptFile } from '../generate/files'; 2 2 3 3 type ExtractFromArray<T, Discriminator> = T extends Discriminator 4 4 ? Required<T>
+7 -3
packages/openapi-ts/src/utils/__tests__/parse.spec.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 - import type { Operation } from '../../openApi'; 3 + import { operationNameFn } from '../../openApi/config'; 4 4 import { setConfig } from '../config'; 5 - import { operationNameFn } from '../parse'; 6 5 7 6 describe('operationNameFn', () => { 8 7 const optionsCommon: Parameters<typeof setConfig>[0] = { ··· 277 276 ({ url, method, options, operationId, expected }) => { 278 277 setConfig(options); 279 278 expect( 280 - operationNameFn({ id: operationId, method, path: url } as Operation), 279 + operationNameFn({ 280 + config: options, 281 + method, 282 + operationId, 283 + path: url, 284 + }), 281 285 ).toBe(expected); 282 286 }, 283 287 );
+9 -4
packages/openapi-ts/src/utils/__tests__/postprocess.spec.ts
··· 1 1 import { describe, expect, it } from 'vitest'; 2 2 3 - import { type Config, parse } from '../../openApi'; 3 + import { parse } from '../../openApi'; 4 + import type { ParserConfig } from '../../openApi/config'; 4 5 import { getServiceName, postProcessClient } from '../postprocess'; 5 6 6 - const config: Config = { 7 + const parserConfig: ParserConfig = { 8 + filterFn: { 9 + operation: () => true, 10 + operationParameter: () => true, 11 + }, 7 12 nameFn: { 8 13 operation: () => 'operation', 9 14 operationParameter: () => 'operationParameter', ··· 31 36 describe('getServices', () => { 32 37 it('should create a unnamed service if tags are empty', () => { 33 38 const parserClient = parse({ 34 - config, 35 39 openApi: { 36 40 info: { 37 41 title: 'x', ··· 54 58 }, 55 59 }, 56 60 }, 61 + parserConfig, 57 62 }); 58 63 const { services } = postProcessClient(parserClient); 59 64 ··· 65 70 describe('getServices', () => { 66 71 it('should create a unnamed service if tags are empty', () => { 67 72 const parserClient = parse({ 68 - config, 69 73 openApi: { 70 74 info: { 71 75 title: 'x', ··· 88 92 }, 89 93 }, 90 94 }, 95 + parserConfig, 91 96 }); 92 97 const { services } = postProcessClient(parserClient); 93 98
+10 -1
packages/openapi-ts/src/utils/handlebars.ts
··· 89 89 // @ts-ignore 90 90 import xhrSendRequest from '../legacy/handlebars/compiled/core/xhr/sendRequest.js'; 91 91 import { camelCase } from './camelCase'; 92 + import { getConfig } from './config'; 92 93 import { transformServiceName } from './transform'; 93 94 94 95 export const registerHandlebarHelpers = (): void => { ··· 133 134 }, 134 135 ); 135 136 136 - Handlebars.registerHelper('transformServiceName', transformServiceName); 137 + Handlebars.registerHelper( 138 + 'transformServiceName', 139 + function (this: unknown, name: string) { 140 + return transformServiceName({ 141 + config: getConfig(), 142 + name, 143 + }); 144 + }, 145 + ); 137 146 }; 138 147 139 148 export interface Templates {
-68
packages/openapi-ts/src/utils/parse.ts
··· 1 - import type { Operation, OperationParameter } from '../openApi'; 2 - import { sanitizeNamespaceIdentifier } from '../openApi'; 3 - import { camelCase } from './camelCase'; 4 - import { getConfig, isLegacyClient } from './config'; 5 - import { transformTypeKeyName } from './type'; 6 - 7 - export const operationFilterFn = (operationKey: string): boolean => { 8 - const config = getConfig(); 9 - const regexp = config.services.filter 10 - ? new RegExp(config.services.filter) 11 - : undefined; 12 - return !regexp || regexp.test(operationKey); 13 - }; 14 - 15 - export const operationParameterFilterFn = ( 16 - parameter: OperationParameter, 17 - ): boolean => { 18 - const config = getConfig(); 19 - 20 - // legacy clients ignore the "api-version" param since we do not want to 21 - // add it as the first/default parameter for each of the service calls 22 - return !isLegacyClient(config) || parameter.prop !== 'api-version'; 23 - }; 24 - 25 - /** 26 - * Convert the input value to a correct operation (method) class name. 27 - * This will use the operation ID - if available - and otherwise fallback 28 - * on a generated name from the URL 29 - */ 30 - export const operationNameFn = (operation: Omit<Operation, 'name'>): string => { 31 - const config = getConfig(); 32 - 33 - if (config.services.operationId && operation.id) { 34 - return camelCase({ 35 - input: sanitizeNamespaceIdentifier(operation.id), 36 - }); 37 - } 38 - 39 - let urlWithoutPlaceholders = operation.path; 40 - 41 - // legacy clients ignore the "api-version" param since we do not want to 42 - // add it as the first/default parameter for each of the service calls 43 - if (isLegacyClient(config)) { 44 - urlWithoutPlaceholders = urlWithoutPlaceholders.replace( 45 - /[^/]*?{api-version}.*?\//g, 46 - '', 47 - ); 48 - } 49 - 50 - urlWithoutPlaceholders = urlWithoutPlaceholders 51 - .replace(/{(.*?)}/g, 'by-$1') 52 - // replace slashes with hyphens for camelcase method at the end 53 - .replace(/[/:]/g, '-'); 54 - 55 - return camelCase({ 56 - input: `${operation.method}-${urlWithoutPlaceholders}`, 57 - }); 58 - }; 59 - 60 - export const operationParameterNameFn = ( 61 - parameter: Omit<OperationParameter, 'name'>, 62 - ): string => { 63 - const config = getConfig(); 64 - 65 - return !isLegacyClient(config) 66 - ? parameter.prop 67 - : transformTypeKeyName(parameter.prop); 68 - };
+35
packages/openapi-ts/src/utils/ref.ts
··· 1 + export const irRef = '#/ir/'; 2 + 3 + export const isRefOpenApiComponent = ($ref: string): boolean => { 4 + const parts = refToParts($ref); 5 + // reusable components are nested within components/<namespace>/<name> 6 + return parts.length === 3 && parts[0] === 'components'; 7 + }; 8 + 9 + const refToParts = ($ref: string): string[] => { 10 + // Remove the leading `#` and split by `/` to traverse the object 11 + const parts = $ref.replace(/^#\//, '').split('/'); 12 + return parts; 13 + }; 14 + 15 + export const resolveRef = <T>({ 16 + $ref, 17 + spec, 18 + }: { 19 + $ref: string; 20 + spec: Record<string, any>; 21 + }): T => { 22 + const parts = refToParts($ref); 23 + 24 + let current = spec; 25 + 26 + for (const part of parts) { 27 + const p = part as keyof typeof current; 28 + if (current[p] === undefined) { 29 + throw new Error(`Reference not found: ${$ref}`); 30 + } 31 + current = current[p]; 32 + } 33 + 34 + return current as T; 35 + };
+9 -2
packages/openapi-ts/src/utils/transform.ts
··· 1 1 import { ensureValidTypeScriptJavaScriptIdentifier } from '../openApi'; 2 + import type { Config } from '../types/config'; 2 3 import { camelCase } from './camelCase'; 3 4 import { getConfig } from './config'; 4 5 import { reservedWordsRegExp } from './regexp'; 5 6 6 - export const transformServiceName = (name: string) => { 7 - const config = getConfig(); 7 + export const transformServiceName = ({ 8 + config, 9 + name, 10 + }: { 11 + config: Config; 12 + name: string; 13 + }) => { 8 14 if (config.services.name) { 9 15 return config.services.name.replace('{{name}}', name); 10 16 } 17 + 11 18 return name; 12 19 }; 13 20
+2 -1
packages/openapi-ts/src/utils/type.ts
··· 98 98 const typeDict = (model: Model) => { 99 99 const type = 100 100 model.link && !Array.isArray(model.link) ? toType(model.link) : base(model); 101 - return compiler.typeRecordNode(['string'], [type], model.isNullable); 101 + return compiler.typeRecordNode(['string'], [type], model.isNullable, true); 102 102 }; 103 103 104 104 const typeUnionOrIntersection = ({ ··· 187 187 return compiler.typeInterfaceNode({ 188 188 isNullable: model.isNullable, 189 189 properties, 190 + useLegacyResolution: !config.experimental_parser, 190 191 }); 191 192 }; 192 193
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts
··· 33 33 }; 34 34 35 35 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 36 - createQueryKey("collectionFormat", options) 36 + createQueryKey('collectionFormat', options) 37 37 ]; 38 38 39 39 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 52 - createQueryKey("complexTypes", options) 52 + createQueryKey('complexTypes', options) 53 53 ]; 54 54 55 55 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const exportQueryKey = (options?: Options) => [ 79 - createQueryKey("export", options) 79 + createQueryKey('export', options) 80 80 ]; 81 81 82 82 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const importQueryKey = (options: Options<ImportData>) => [ 95 - createQueryKey("import", options) 95 + createQueryKey('import', options) 96 96 ]; 97 97 98 98 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 119 119 }; return mutationOptions; }; 120 120 121 121 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 122 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 122 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 123 123 ]; 124 124 125 125 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 135 135 }); }; 136 136 137 137 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 138 - createQueryKey("callWithDefaultParameters", options) 138 + createQueryKey('callWithDefaultParameters', options) 139 139 ]; 140 140 141 141 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 151 151 }); }; 152 152 153 153 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 154 - createQueryKey("callWithDefaultOptionalParameters", options) 154 + createQueryKey('callWithDefaultOptionalParameters', options) 155 155 ]; 156 156 157 157 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 189 189 }; return mutationOptions; }; 190 190 191 191 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 192 - createQueryKey("deprecatedCall", options) 192 + createQueryKey('deprecatedCall', options) 193 193 ]; 194 194 195 195 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 216 216 }; return mutationOptions; }; 217 217 218 218 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 219 - createQueryKey("callWithDescriptions", options) 219 + createQueryKey('callWithDescriptions', options) 220 220 ]; 221 221 222 222 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 243 243 }; return mutationOptions; }; 244 244 245 245 export const duplicateNameQueryKey = (options?: Options) => [ 246 - createQueryKey("duplicateName", options) 246 + createQueryKey('duplicateName', options) 247 247 ]; 248 248 249 249 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 259 259 }); }; 260 260 261 261 export const duplicateName1QueryKey = (options?: Options) => [ 262 - createQueryKey("duplicateName1", options) 262 + createQueryKey('duplicateName1', options) 263 263 ]; 264 264 265 265 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 308 308 }; return mutationOptions; }; 309 309 310 310 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 311 - createQueryKey("testErrorCode", options) 311 + createQueryKey('testErrorCode', options) 312 312 ]; 313 313 314 314 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 335 335 }; return mutationOptions; }; 336 336 337 337 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 338 - createQueryKey("fileResponse", options) 338 + createQueryKey('fileResponse', options) 339 339 ]; 340 340 341 341 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 351 351 }); }; 352 352 353 353 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 354 - createQueryKey("postApiVbyApiVersionFormData", options) 354 + createQueryKey('postApiVbyApiVersionFormData', options) 355 355 ]; 356 356 357 357 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 378 378 }; return mutationOptions; }; 379 379 380 380 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 381 - createQueryKey("callWithResultFromHeader", options) 381 + createQueryKey('callWithResultFromHeader', options) 382 382 ]; 383 383 384 384 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 405 405 }; return mutationOptions; }; 406 406 407 407 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 408 - createQueryKey("multipartRequest", options) 408 + createQueryKey('multipartRequest', options) 409 409 ]; 410 410 411 411 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 432 432 }; return mutationOptions; }; 433 433 434 434 export const multipartResponseQueryKey = (options?: Options) => [ 435 - createQueryKey("multipartResponse", options) 435 + createQueryKey('multipartResponse', options) 436 436 ]; 437 437 438 438 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 448 448 }); }; 449 449 450 450 export const dummyAQueryKey = (options?: Options) => [ 451 - createQueryKey("dummyA", options) 451 + createQueryKey('dummyA', options) 452 452 ]; 453 453 454 454 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 464 464 }); }; 465 465 466 466 export const dummyBQueryKey = (options?: Options) => [ 467 - createQueryKey("dummyB", options) 467 + createQueryKey('dummyB', options) 468 468 ]; 469 469 470 470 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 480 480 }); }; 481 481 482 482 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 483 - createQueryKey("callWithNoContentResponse", options) 483 + createQueryKey('callWithNoContentResponse', options) 484 484 ]; 485 485 486 486 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 496 496 }); }; 497 497 498 498 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 499 - createQueryKey("callWithResponseAndNoContentResponse", options) 499 + createQueryKey('callWithResponseAndNoContentResponse', options) 500 500 ]; 501 501 502 502 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 512 512 }); }; 513 513 514 514 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 515 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 515 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 516 516 ]; 517 517 518 518 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ ··· 561 561 }; return mutationOptions; }; 562 562 563 563 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 564 - createQueryKey("callWithParameters", options) 564 + createQueryKey('callWithParameters', options) 565 565 ]; 566 566 567 567 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 606 606 }; 607 607 608 608 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 609 - createQueryKey("callWithParameters", options, true) 609 + createQueryKey('callWithParameters', options, true) 610 610 ]; 611 611 612 612 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 614 614 { 615 615 queryFn: async ({ pageParam, queryKey }) => { 616 616 // @ts-ignore 617 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 617 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 618 618 query: { 619 619 cursor: pageParam 620 620 } ··· 642 642 }; return mutationOptions; }; 643 643 644 644 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 645 - createQueryKey("callWithWeirdParameterNames", options) 645 + createQueryKey('callWithWeirdParameterNames', options) 646 646 ]; 647 647 648 648 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 669 669 }; return mutationOptions; }; 670 670 671 671 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 672 - createQueryKey("getCallWithOptionalParam", options) 672 + createQueryKey('getCallWithOptionalParam', options) 673 673 ]; 674 674 675 675 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 685 685 }); }; 686 686 687 687 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 688 - createQueryKey("getCallWithOptionalParam", options, true) 688 + createQueryKey('getCallWithOptionalParam', options, true) 689 689 ]; 690 690 691 691 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 693 693 { 694 694 queryFn: async ({ pageParam, queryKey }) => { 695 695 // @ts-ignore 696 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 696 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 697 697 query: { 698 698 page: pageParam 699 699 } ··· 710 710 }); }; 711 711 712 712 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 713 - createQueryKey("postCallWithOptionalParam", options) 713 + createQueryKey('postCallWithOptionalParam', options) 714 714 ]; 715 715 716 716 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 726 726 }); }; 727 727 728 728 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 729 - createQueryKey("postCallWithOptionalParam", options, true) 729 + createQueryKey('postCallWithOptionalParam', options, true) 730 730 ]; 731 731 732 732 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 734 734 { 735 735 queryFn: async ({ pageParam, queryKey }) => { 736 736 // @ts-ignore 737 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 737 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 738 738 body: { 739 739 offset: pageParam 740 740 } ··· 762 762 }; return mutationOptions; }; 763 763 764 764 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 765 - createQueryKey("postApiVbyApiVersionRequestBody", options) 765 + createQueryKey('postApiVbyApiVersionRequestBody', options) 766 766 ]; 767 767 768 768 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 789 789 }; return mutationOptions; }; 790 790 791 791 export const callWithResponseQueryKey = (options?: Options) => [ 792 - createQueryKey("callWithResponse", options) 792 + createQueryKey('callWithResponse', options) 793 793 ]; 794 794 795 795 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 805 805 }); }; 806 806 807 807 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 808 - createQueryKey("callWithDuplicateResponses", options) 808 + createQueryKey('callWithDuplicateResponses', options) 809 809 ]; 810 810 811 811 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 843 843 }; return mutationOptions; }; 844 844 845 845 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 846 - createQueryKey("apiVVersionOdataControllerCount", options) 846 + createQueryKey('apiVVersionOdataControllerCount', options) 847 847 ]; 848 848 849 849 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 859 859 }); }; 860 860 861 861 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("getCallWithoutParametersAndResponse", options) 862 + createQueryKey('getCallWithoutParametersAndResponse', options) 863 863 ]; 864 864 865 865 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 889 - createQueryKey("postCallWithoutParametersAndResponse", options) 889 + createQueryKey('postCallWithoutParametersAndResponse', options) 890 890 ]; 891 891 892 892 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 935 935 }; return mutationOptions; }; 936 936 937 937 export const typesQueryKey = (options: Options<TypesData>) => [ 938 - createQueryKey("types", options) 938 + createQueryKey('types', options) 939 939 ]; 940 940 941 941 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 951 951 }); }; 952 952 953 953 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 954 - createQueryKey("uploadFile", options) 954 + createQueryKey('uploadFile', options) 955 955 ]; 956 956 957 957 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts
··· 34 34 }; 35 35 36 36 export const exportQueryKey = (options?: Options) => [ 37 - createQueryKey("export", options) 37 + createQueryKey('export', options) 38 38 ]; 39 39 40 40 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 50 50 }); }; 51 51 52 52 export const importQueryKey = (options: Options<ImportData>) => [ 53 - createQueryKey("import", options) 53 + createQueryKey('import', options) 54 54 ]; 55 55 56 56 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 77 77 }; return mutationOptions; }; 78 78 79 79 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 80 - createQueryKey("apiVVersionOdataControllerCount", options) 80 + createQueryKey('apiVVersionOdataControllerCount', options) 81 81 ]; 82 82 83 83 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 93 93 }); }; 94 94 95 95 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 96 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 96 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 97 97 ]; 98 98 99 99 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 109 109 }); }; 110 110 111 111 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 112 - createQueryKey("getCallWithoutParametersAndResponse", options) 112 + createQueryKey('getCallWithoutParametersAndResponse', options) 113 113 ]; 114 114 115 115 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 136 136 }; return mutationOptions; }; 137 137 138 138 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 139 - createQueryKey("postCallWithoutParametersAndResponse", options) 139 + createQueryKey('postCallWithoutParametersAndResponse', options) 140 140 ]; 141 141 142 142 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 196 196 }; return mutationOptions; }; 197 197 198 198 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 199 - createQueryKey("callWithDescriptions", options) 199 + createQueryKey('callWithDescriptions', options) 200 200 ]; 201 201 202 202 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 223 223 }; return mutationOptions; }; 224 224 225 225 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 226 - createQueryKey("deprecatedCall", options) 226 + createQueryKey('deprecatedCall', options) 227 227 ]; 228 228 229 229 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 250 250 }; return mutationOptions; }; 251 251 252 252 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 253 - createQueryKey("callWithParameters", options) 253 + createQueryKey('callWithParameters', options) 254 254 ]; 255 255 256 256 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 295 295 }; 296 296 297 297 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 298 - createQueryKey("callWithParameters", options, true) 298 + createQueryKey('callWithParameters', options, true) 299 299 ]; 300 300 301 301 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 303 303 { 304 304 queryFn: async ({ pageParam, queryKey }) => { 305 305 // @ts-ignore 306 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 306 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 307 307 query: { 308 308 cursor: pageParam 309 309 } ··· 331 331 }; return mutationOptions; }; 332 332 333 333 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 334 - createQueryKey("callWithWeirdParameterNames", options) 334 + createQueryKey('callWithWeirdParameterNames', options) 335 335 ]; 336 336 337 337 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 358 358 }; return mutationOptions; }; 359 359 360 360 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 361 - createQueryKey("getCallWithOptionalParam", options) 361 + createQueryKey('getCallWithOptionalParam', options) 362 362 ]; 363 363 364 364 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 374 374 }); }; 375 375 376 376 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 377 - createQueryKey("getCallWithOptionalParam", options, true) 377 + createQueryKey('getCallWithOptionalParam', options, true) 378 378 ]; 379 379 380 380 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 382 382 { 383 383 queryFn: async ({ pageParam, queryKey }) => { 384 384 // @ts-ignore 385 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 385 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 386 386 query: { 387 387 page: pageParam 388 388 } ··· 399 399 }); }; 400 400 401 401 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 402 - createQueryKey("postCallWithOptionalParam", options) 402 + createQueryKey('postCallWithOptionalParam', options) 403 403 ]; 404 404 405 405 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 415 415 }); }; 416 416 417 417 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 418 - createQueryKey("postCallWithOptionalParam", options, true) 418 + createQueryKey('postCallWithOptionalParam', options, true) 419 419 ]; 420 420 421 421 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 423 423 { 424 424 queryFn: async ({ pageParam, queryKey }) => { 425 425 // @ts-ignore 426 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 426 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 427 427 body: { 428 428 offset: pageParam 429 429 } ··· 451 451 }; return mutationOptions; }; 452 452 453 453 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 454 - createQueryKey("postApiVbyApiVersionRequestBody", options) 454 + createQueryKey('postApiVbyApiVersionRequestBody', options) 455 455 ]; 456 456 457 457 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 478 478 }; return mutationOptions; }; 479 479 480 480 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 481 - createQueryKey("postApiVbyApiVersionFormData", options) 481 + createQueryKey('postApiVbyApiVersionFormData', options) 482 482 ]; 483 483 484 484 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 505 505 }; return mutationOptions; }; 506 506 507 507 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 508 - createQueryKey("callWithDefaultParameters", options) 508 + createQueryKey('callWithDefaultParameters', options) 509 509 ]; 510 510 511 511 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 521 521 }); }; 522 522 523 523 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 524 - createQueryKey("callWithDefaultOptionalParameters", options) 524 + createQueryKey('callWithDefaultOptionalParameters', options) 525 525 ]; 526 526 527 527 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 559 559 }; return mutationOptions; }; 560 560 561 561 export const duplicateNameQueryKey = (options?: Options) => [ 562 - createQueryKey("duplicateName", options) 562 + createQueryKey('duplicateName', options) 563 563 ]; 564 564 565 565 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 575 575 }); }; 576 576 577 577 export const duplicateName1QueryKey = (options?: Options) => [ 578 - createQueryKey("duplicateName1", options) 578 + createQueryKey('duplicateName1', options) 579 579 ]; 580 580 581 581 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 624 624 }; return mutationOptions; }; 625 625 626 626 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 627 - createQueryKey("callWithNoContentResponse", options) 627 + createQueryKey('callWithNoContentResponse', options) 628 628 ]; 629 629 630 630 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 640 640 }); }; 641 641 642 642 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 643 - createQueryKey("callWithResponseAndNoContentResponse", options) 643 + createQueryKey('callWithResponseAndNoContentResponse', options) 644 644 ]; 645 645 646 646 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 656 656 }); }; 657 657 658 658 export const dummyAQueryKey = (options?: Options) => [ 659 - createQueryKey("dummyA", options) 659 + createQueryKey('dummyA', options) 660 660 ]; 661 661 662 662 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 672 672 }); }; 673 673 674 674 export const dummyBQueryKey = (options?: Options) => [ 675 - createQueryKey("dummyB", options) 675 + createQueryKey('dummyB', options) 676 676 ]; 677 677 678 678 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 688 688 }); }; 689 689 690 690 export const callWithResponseQueryKey = (options?: Options) => [ 691 - createQueryKey("callWithResponse", options) 691 + createQueryKey('callWithResponse', options) 692 692 ]; 693 693 694 694 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 704 704 }); }; 705 705 706 706 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 707 - createQueryKey("callWithDuplicateResponses", options) 707 + createQueryKey('callWithDuplicateResponses', options) 708 708 ]; 709 709 710 710 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 742 742 }; return mutationOptions; }; 743 743 744 744 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 745 - createQueryKey("collectionFormat", options) 745 + createQueryKey('collectionFormat', options) 746 746 ]; 747 747 748 748 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 758 758 }); }; 759 759 760 760 export const typesQueryKey = (options: Options<TypesData>) => [ 761 - createQueryKey("types", options) 761 + createQueryKey('types', options) 762 762 ]; 763 763 764 764 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 774 774 }); }; 775 775 776 776 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 777 - createQueryKey("uploadFile", options) 777 + createQueryKey('uploadFile', options) 778 778 ]; 779 779 780 780 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 801 801 }; return mutationOptions; }; 802 802 803 803 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 804 - createQueryKey("fileResponse", options) 804 + createQueryKey('fileResponse', options) 805 805 ]; 806 806 807 807 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 817 817 }); }; 818 818 819 819 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 820 - createQueryKey("complexTypes", options) 820 + createQueryKey('complexTypes', options) 821 821 ]; 822 822 823 823 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 833 833 }); }; 834 834 835 835 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 836 - createQueryKey("multipartRequest", options) 836 + createQueryKey('multipartRequest', options) 837 837 ]; 838 838 839 839 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 860 860 }; return mutationOptions; }; 861 861 862 862 export const multipartResponseQueryKey = (options?: Options) => [ 863 - createQueryKey("multipartResponse", options) 863 + createQueryKey('multipartResponse', options) 864 864 ]; 865 865 866 866 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 887 887 }; return mutationOptions; }; 888 888 889 889 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 890 - createQueryKey("callWithResultFromHeader", options) 890 + createQueryKey('callWithResultFromHeader', options) 891 891 ]; 892 892 893 893 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 914 914 }; return mutationOptions; }; 915 915 916 916 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 917 - createQueryKey("testErrorCode", options) 917 + createQueryKey('testErrorCode', options) 918 918 ]; 919 919 920 920 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 941 941 }; return mutationOptions; }; 942 942 943 943 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 944 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 944 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 945 945 ]; 946 946 947 947 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts
··· 33 33 }; 34 34 35 35 export const exportQueryKey = (options?: Options) => [ 36 - createQueryKey("export", options) 36 + createQueryKey('export', options) 37 37 ]; 38 38 39 39 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const importQueryKey = (options: Options<ImportData>) => [ 52 - createQueryKey("import", options) 52 + createQueryKey('import', options) 53 53 ]; 54 54 55 55 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 79 - createQueryKey("apiVVersionOdataControllerCount", options) 79 + createQueryKey('apiVVersionOdataControllerCount', options) 80 80 ]; 81 81 82 82 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 95 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 95 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 96 96 ]; 97 97 98 98 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 108 108 }); }; 109 109 110 110 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 111 - createQueryKey("getCallWithoutParametersAndResponse", options) 111 + createQueryKey('getCallWithoutParametersAndResponse', options) 112 112 ]; 113 113 114 114 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 135 135 }; return mutationOptions; }; 136 136 137 137 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 138 - createQueryKey("postCallWithoutParametersAndResponse", options) 138 + createQueryKey('postCallWithoutParametersAndResponse', options) 139 139 ]; 140 140 141 141 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 195 195 }; return mutationOptions; }; 196 196 197 197 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 198 - createQueryKey("callWithDescriptions", options) 198 + createQueryKey('callWithDescriptions', options) 199 199 ]; 200 200 201 201 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 222 222 }; return mutationOptions; }; 223 223 224 224 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 225 - createQueryKey("deprecatedCall", options) 225 + createQueryKey('deprecatedCall', options) 226 226 ]; 227 227 228 228 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 249 249 }; return mutationOptions; }; 250 250 251 251 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 252 - createQueryKey("callWithParameters", options) 252 + createQueryKey('callWithParameters', options) 253 253 ]; 254 254 255 255 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 294 294 }; 295 295 296 296 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 297 - createQueryKey("callWithParameters", options, true) 297 + createQueryKey('callWithParameters', options, true) 298 298 ]; 299 299 300 300 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 302 302 { 303 303 queryFn: async ({ pageParam, queryKey }) => { 304 304 // @ts-ignore 305 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 305 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 306 306 query: { 307 307 cursor: pageParam 308 308 } ··· 330 330 }; return mutationOptions; }; 331 331 332 332 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 333 - createQueryKey("callWithWeirdParameterNames", options) 333 + createQueryKey('callWithWeirdParameterNames', options) 334 334 ]; 335 335 336 336 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 357 357 }; return mutationOptions; }; 358 358 359 359 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 360 - createQueryKey("getCallWithOptionalParam", options) 360 + createQueryKey('getCallWithOptionalParam', options) 361 361 ]; 362 362 363 363 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 373 373 }); }; 374 374 375 375 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 376 - createQueryKey("getCallWithOptionalParam", options, true) 376 + createQueryKey('getCallWithOptionalParam', options, true) 377 377 ]; 378 378 379 379 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 381 381 { 382 382 queryFn: async ({ pageParam, queryKey }) => { 383 383 // @ts-ignore 384 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 384 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 385 385 query: { 386 386 page: pageParam 387 387 } ··· 398 398 }); }; 399 399 400 400 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 401 - createQueryKey("postCallWithOptionalParam", options) 401 + createQueryKey('postCallWithOptionalParam', options) 402 402 ]; 403 403 404 404 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 414 414 }); }; 415 415 416 416 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 417 - createQueryKey("postCallWithOptionalParam", options, true) 417 + createQueryKey('postCallWithOptionalParam', options, true) 418 418 ]; 419 419 420 420 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 422 422 { 423 423 queryFn: async ({ pageParam, queryKey }) => { 424 424 // @ts-ignore 425 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 425 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 426 426 body: { 427 427 offset: pageParam 428 428 } ··· 450 450 }; return mutationOptions; }; 451 451 452 452 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 453 - createQueryKey("postApiVbyApiVersionRequestBody", options) 453 + createQueryKey('postApiVbyApiVersionRequestBody', options) 454 454 ]; 455 455 456 456 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 477 477 }; return mutationOptions; }; 478 478 479 479 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 480 - createQueryKey("postApiVbyApiVersionFormData", options) 480 + createQueryKey('postApiVbyApiVersionFormData', options) 481 481 ]; 482 482 483 483 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 504 504 }; return mutationOptions; }; 505 505 506 506 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 507 - createQueryKey("callWithDefaultParameters", options) 507 + createQueryKey('callWithDefaultParameters', options) 508 508 ]; 509 509 510 510 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 520 520 }); }; 521 521 522 522 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 523 - createQueryKey("callWithDefaultOptionalParameters", options) 523 + createQueryKey('callWithDefaultOptionalParameters', options) 524 524 ]; 525 525 526 526 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 558 558 }; return mutationOptions; }; 559 559 560 560 export const duplicateNameQueryKey = (options?: Options) => [ 561 - createQueryKey("duplicateName", options) 561 + createQueryKey('duplicateName', options) 562 562 ]; 563 563 564 564 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 574 574 }); }; 575 575 576 576 export const duplicateName1QueryKey = (options?: Options) => [ 577 - createQueryKey("duplicateName1", options) 577 + createQueryKey('duplicateName1', options) 578 578 ]; 579 579 580 580 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 623 623 }; return mutationOptions; }; 624 624 625 625 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 626 - createQueryKey("callWithNoContentResponse", options) 626 + createQueryKey('callWithNoContentResponse', options) 627 627 ]; 628 628 629 629 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 639 639 }); }; 640 640 641 641 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 642 - createQueryKey("callWithResponseAndNoContentResponse", options) 642 + createQueryKey('callWithResponseAndNoContentResponse', options) 643 643 ]; 644 644 645 645 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 655 655 }); }; 656 656 657 657 export const dummyAQueryKey = (options?: Options) => [ 658 - createQueryKey("dummyA", options) 658 + createQueryKey('dummyA', options) 659 659 ]; 660 660 661 661 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 671 671 }); }; 672 672 673 673 export const dummyBQueryKey = (options?: Options) => [ 674 - createQueryKey("dummyB", options) 674 + createQueryKey('dummyB', options) 675 675 ]; 676 676 677 677 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 687 687 }); }; 688 688 689 689 export const callWithResponseQueryKey = (options?: Options) => [ 690 - createQueryKey("callWithResponse", options) 690 + createQueryKey('callWithResponse', options) 691 691 ]; 692 692 693 693 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 703 703 }); }; 704 704 705 705 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 706 - createQueryKey("callWithDuplicateResponses", options) 706 + createQueryKey('callWithDuplicateResponses', options) 707 707 ]; 708 708 709 709 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 741 741 }; return mutationOptions; }; 742 742 743 743 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 744 - createQueryKey("collectionFormat", options) 744 + createQueryKey('collectionFormat', options) 745 745 ]; 746 746 747 747 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 757 757 }); }; 758 758 759 759 export const typesQueryKey = (options: Options<TypesData>) => [ 760 - createQueryKey("types", options) 760 + createQueryKey('types', options) 761 761 ]; 762 762 763 763 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 773 773 }); }; 774 774 775 775 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 776 - createQueryKey("uploadFile", options) 776 + createQueryKey('uploadFile', options) 777 777 ]; 778 778 779 779 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 800 800 }; return mutationOptions; }; 801 801 802 802 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 803 - createQueryKey("fileResponse", options) 803 + createQueryKey('fileResponse', options) 804 804 ]; 805 805 806 806 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 816 816 }); }; 817 817 818 818 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 819 - createQueryKey("complexTypes", options) 819 + createQueryKey('complexTypes', options) 820 820 ]; 821 821 822 822 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 832 832 }); }; 833 833 834 834 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 835 - createQueryKey("multipartRequest", options) 835 + createQueryKey('multipartRequest', options) 836 836 ]; 837 837 838 838 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 859 859 }; return mutationOptions; }; 860 860 861 861 export const multipartResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("multipartResponse", options) 862 + createQueryKey('multipartResponse', options) 863 863 ]; 864 864 865 865 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 889 - createQueryKey("callWithResultFromHeader", options) 889 + createQueryKey('callWithResultFromHeader', options) 890 890 ]; 891 891 892 892 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 913 913 }; return mutationOptions; }; 914 914 915 915 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 916 - createQueryKey("testErrorCode", options) 916 + createQueryKey('testErrorCode', options) 917 917 ]; 918 918 919 919 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 940 940 }; return mutationOptions; }; 941 941 942 942 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 943 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 943 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 944 944 ]; 945 945 946 946 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts
··· 33 33 }; 34 34 35 35 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 36 - createQueryKey("collectionFormat", options) 36 + createQueryKey('collectionFormat', options) 37 37 ]; 38 38 39 39 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 52 - createQueryKey("complexTypes", options) 52 + createQueryKey('complexTypes', options) 53 53 ]; 54 54 55 55 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const exportQueryKey = (options?: Options) => [ 79 - createQueryKey("export", options) 79 + createQueryKey('export', options) 80 80 ]; 81 81 82 82 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const importQueryKey = (options: Options<ImportData>) => [ 95 - createQueryKey("import", options) 95 + createQueryKey('import', options) 96 96 ]; 97 97 98 98 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 119 119 }; return mutationOptions; }; 120 120 121 121 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 122 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 122 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 123 123 ]; 124 124 125 125 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 135 135 }); }; 136 136 137 137 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 138 - createQueryKey("callWithDefaultParameters", options) 138 + createQueryKey('callWithDefaultParameters', options) 139 139 ]; 140 140 141 141 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 151 151 }); }; 152 152 153 153 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 154 - createQueryKey("callWithDefaultOptionalParameters", options) 154 + createQueryKey('callWithDefaultOptionalParameters', options) 155 155 ]; 156 156 157 157 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 189 189 }; return mutationOptions; }; 190 190 191 191 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 192 - createQueryKey("deprecatedCall", options) 192 + createQueryKey('deprecatedCall', options) 193 193 ]; 194 194 195 195 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 216 216 }; return mutationOptions; }; 217 217 218 218 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 219 - createQueryKey("callWithDescriptions", options) 219 + createQueryKey('callWithDescriptions', options) 220 220 ]; 221 221 222 222 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 243 243 }; return mutationOptions; }; 244 244 245 245 export const duplicateNameQueryKey = (options?: Options) => [ 246 - createQueryKey("duplicateName", options) 246 + createQueryKey('duplicateName', options) 247 247 ]; 248 248 249 249 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 259 259 }); }; 260 260 261 261 export const duplicateName1QueryKey = (options?: Options) => [ 262 - createQueryKey("duplicateName1", options) 262 + createQueryKey('duplicateName1', options) 263 263 ]; 264 264 265 265 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 308 308 }; return mutationOptions; }; 309 309 310 310 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 311 - createQueryKey("testErrorCode", options) 311 + createQueryKey('testErrorCode', options) 312 312 ]; 313 313 314 314 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 335 335 }; return mutationOptions; }; 336 336 337 337 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 338 - createQueryKey("fileResponse", options) 338 + createQueryKey('fileResponse', options) 339 339 ]; 340 340 341 341 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 351 351 }); }; 352 352 353 353 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 354 - createQueryKey("postApiVbyApiVersionFormData", options) 354 + createQueryKey('postApiVbyApiVersionFormData', options) 355 355 ]; 356 356 357 357 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 378 378 }; return mutationOptions; }; 379 379 380 380 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 381 - createQueryKey("callWithResultFromHeader", options) 381 + createQueryKey('callWithResultFromHeader', options) 382 382 ]; 383 383 384 384 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 405 405 }; return mutationOptions; }; 406 406 407 407 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 408 - createQueryKey("multipartRequest", options) 408 + createQueryKey('multipartRequest', options) 409 409 ]; 410 410 411 411 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 432 432 }; return mutationOptions; }; 433 433 434 434 export const multipartResponseQueryKey = (options?: Options) => [ 435 - createQueryKey("multipartResponse", options) 435 + createQueryKey('multipartResponse', options) 436 436 ]; 437 437 438 438 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 448 448 }); }; 449 449 450 450 export const dummyAQueryKey = (options?: Options) => [ 451 - createQueryKey("dummyA", options) 451 + createQueryKey('dummyA', options) 452 452 ]; 453 453 454 454 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 464 464 }); }; 465 465 466 466 export const dummyBQueryKey = (options?: Options) => [ 467 - createQueryKey("dummyB", options) 467 + createQueryKey('dummyB', options) 468 468 ]; 469 469 470 470 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 480 480 }); }; 481 481 482 482 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 483 - createQueryKey("callWithNoContentResponse", options) 483 + createQueryKey('callWithNoContentResponse', options) 484 484 ]; 485 485 486 486 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 496 496 }); }; 497 497 498 498 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 499 - createQueryKey("callWithResponseAndNoContentResponse", options) 499 + createQueryKey('callWithResponseAndNoContentResponse', options) 500 500 ]; 501 501 502 502 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 512 512 }); }; 513 513 514 514 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 515 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 515 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 516 516 ]; 517 517 518 518 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ ··· 561 561 }; return mutationOptions; }; 562 562 563 563 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 564 - createQueryKey("callWithParameters", options) 564 + createQueryKey('callWithParameters', options) 565 565 ]; 566 566 567 567 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 606 606 }; 607 607 608 608 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 609 - createQueryKey("callWithParameters", options, true) 609 + createQueryKey('callWithParameters', options, true) 610 610 ]; 611 611 612 612 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 614 614 { 615 615 queryFn: async ({ pageParam, queryKey }) => { 616 616 // @ts-ignore 617 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 617 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 618 618 query: { 619 619 cursor: pageParam 620 620 } ··· 642 642 }; return mutationOptions; }; 643 643 644 644 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 645 - createQueryKey("callWithWeirdParameterNames", options) 645 + createQueryKey('callWithWeirdParameterNames', options) 646 646 ]; 647 647 648 648 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 669 669 }; return mutationOptions; }; 670 670 671 671 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 672 - createQueryKey("getCallWithOptionalParam", options) 672 + createQueryKey('getCallWithOptionalParam', options) 673 673 ]; 674 674 675 675 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 685 685 }); }; 686 686 687 687 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 688 - createQueryKey("getCallWithOptionalParam", options, true) 688 + createQueryKey('getCallWithOptionalParam', options, true) 689 689 ]; 690 690 691 691 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 693 693 { 694 694 queryFn: async ({ pageParam, queryKey }) => { 695 695 // @ts-ignore 696 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 696 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 697 697 query: { 698 698 page: pageParam 699 699 } ··· 710 710 }); }; 711 711 712 712 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 713 - createQueryKey("postCallWithOptionalParam", options) 713 + createQueryKey('postCallWithOptionalParam', options) 714 714 ]; 715 715 716 716 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 726 726 }); }; 727 727 728 728 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 729 - createQueryKey("postCallWithOptionalParam", options, true) 729 + createQueryKey('postCallWithOptionalParam', options, true) 730 730 ]; 731 731 732 732 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 734 734 { 735 735 queryFn: async ({ pageParam, queryKey }) => { 736 736 // @ts-ignore 737 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 737 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 738 738 body: { 739 739 offset: pageParam 740 740 } ··· 762 762 }; return mutationOptions; }; 763 763 764 764 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 765 - createQueryKey("postApiVbyApiVersionRequestBody", options) 765 + createQueryKey('postApiVbyApiVersionRequestBody', options) 766 766 ]; 767 767 768 768 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 789 789 }; return mutationOptions; }; 790 790 791 791 export const callWithResponseQueryKey = (options?: Options) => [ 792 - createQueryKey("callWithResponse", options) 792 + createQueryKey('callWithResponse', options) 793 793 ]; 794 794 795 795 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 805 805 }); }; 806 806 807 807 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 808 - createQueryKey("callWithDuplicateResponses", options) 808 + createQueryKey('callWithDuplicateResponses', options) 809 809 ]; 810 810 811 811 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 843 843 }; return mutationOptions; }; 844 844 845 845 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 846 - createQueryKey("apiVVersionOdataControllerCount", options) 846 + createQueryKey('apiVVersionOdataControllerCount', options) 847 847 ]; 848 848 849 849 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 859 859 }); }; 860 860 861 861 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("getCallWithoutParametersAndResponse", options) 862 + createQueryKey('getCallWithoutParametersAndResponse', options) 863 863 ]; 864 864 865 865 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 889 - createQueryKey("postCallWithoutParametersAndResponse", options) 889 + createQueryKey('postCallWithoutParametersAndResponse', options) 890 890 ]; 891 891 892 892 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 935 935 }; return mutationOptions; }; 936 936 937 937 export const typesQueryKey = (options: Options<TypesData>) => [ 938 - createQueryKey("types", options) 938 + createQueryKey('types', options) 939 939 ]; 940 940 941 941 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 951 951 }); }; 952 952 953 953 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 954 - createQueryKey("uploadFile", options) 954 + createQueryKey('uploadFile', options) 955 955 ]; 956 956 957 957 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts
··· 34 34 }; 35 35 36 36 export const exportQueryKey = (options?: Options) => [ 37 - createQueryKey("export", options) 37 + createQueryKey('export', options) 38 38 ]; 39 39 40 40 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 50 50 }); }; 51 51 52 52 export const importQueryKey = (options: Options<ImportData>) => [ 53 - createQueryKey("import", options) 53 + createQueryKey('import', options) 54 54 ]; 55 55 56 56 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 77 77 }; return mutationOptions; }; 78 78 79 79 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 80 - createQueryKey("apiVVersionOdataControllerCount", options) 80 + createQueryKey('apiVVersionOdataControllerCount', options) 81 81 ]; 82 82 83 83 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 93 93 }); }; 94 94 95 95 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 96 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 96 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 97 97 ]; 98 98 99 99 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 109 109 }); }; 110 110 111 111 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 112 - createQueryKey("getCallWithoutParametersAndResponse", options) 112 + createQueryKey('getCallWithoutParametersAndResponse', options) 113 113 ]; 114 114 115 115 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 136 136 }; return mutationOptions; }; 137 137 138 138 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 139 - createQueryKey("postCallWithoutParametersAndResponse", options) 139 + createQueryKey('postCallWithoutParametersAndResponse', options) 140 140 ]; 141 141 142 142 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 196 196 }; return mutationOptions; }; 197 197 198 198 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 199 - createQueryKey("callWithDescriptions", options) 199 + createQueryKey('callWithDescriptions', options) 200 200 ]; 201 201 202 202 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 223 223 }; return mutationOptions; }; 224 224 225 225 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 226 - createQueryKey("deprecatedCall", options) 226 + createQueryKey('deprecatedCall', options) 227 227 ]; 228 228 229 229 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 250 250 }; return mutationOptions; }; 251 251 252 252 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 253 - createQueryKey("callWithParameters", options) 253 + createQueryKey('callWithParameters', options) 254 254 ]; 255 255 256 256 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 295 295 }; 296 296 297 297 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 298 - createQueryKey("callWithParameters", options, true) 298 + createQueryKey('callWithParameters', options, true) 299 299 ]; 300 300 301 301 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 303 303 { 304 304 queryFn: async ({ pageParam, queryKey }) => { 305 305 // @ts-ignore 306 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 306 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 307 307 query: { 308 308 cursor: pageParam 309 309 } ··· 331 331 }; return mutationOptions; }; 332 332 333 333 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 334 - createQueryKey("callWithWeirdParameterNames", options) 334 + createQueryKey('callWithWeirdParameterNames', options) 335 335 ]; 336 336 337 337 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 358 358 }; return mutationOptions; }; 359 359 360 360 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 361 - createQueryKey("getCallWithOptionalParam", options) 361 + createQueryKey('getCallWithOptionalParam', options) 362 362 ]; 363 363 364 364 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 374 374 }); }; 375 375 376 376 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 377 - createQueryKey("getCallWithOptionalParam", options, true) 377 + createQueryKey('getCallWithOptionalParam', options, true) 378 378 ]; 379 379 380 380 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 382 382 { 383 383 queryFn: async ({ pageParam, queryKey }) => { 384 384 // @ts-ignore 385 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 385 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 386 386 query: { 387 387 page: pageParam 388 388 } ··· 399 399 }); }; 400 400 401 401 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 402 - createQueryKey("postCallWithOptionalParam", options) 402 + createQueryKey('postCallWithOptionalParam', options) 403 403 ]; 404 404 405 405 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 415 415 }); }; 416 416 417 417 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 418 - createQueryKey("postCallWithOptionalParam", options, true) 418 + createQueryKey('postCallWithOptionalParam', options, true) 419 419 ]; 420 420 421 421 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 423 423 { 424 424 queryFn: async ({ pageParam, queryKey }) => { 425 425 // @ts-ignore 426 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 426 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 427 427 body: { 428 428 offset: pageParam 429 429 } ··· 451 451 }; return mutationOptions; }; 452 452 453 453 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 454 - createQueryKey("postApiVbyApiVersionRequestBody", options) 454 + createQueryKey('postApiVbyApiVersionRequestBody', options) 455 455 ]; 456 456 457 457 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 478 478 }; return mutationOptions; }; 479 479 480 480 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 481 - createQueryKey("postApiVbyApiVersionFormData", options) 481 + createQueryKey('postApiVbyApiVersionFormData', options) 482 482 ]; 483 483 484 484 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 505 505 }; return mutationOptions; }; 506 506 507 507 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 508 - createQueryKey("callWithDefaultParameters", options) 508 + createQueryKey('callWithDefaultParameters', options) 509 509 ]; 510 510 511 511 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 521 521 }); }; 522 522 523 523 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 524 - createQueryKey("callWithDefaultOptionalParameters", options) 524 + createQueryKey('callWithDefaultOptionalParameters', options) 525 525 ]; 526 526 527 527 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 559 559 }; return mutationOptions; }; 560 560 561 561 export const duplicateNameQueryKey = (options?: Options) => [ 562 - createQueryKey("duplicateName", options) 562 + createQueryKey('duplicateName', options) 563 563 ]; 564 564 565 565 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 575 575 }); }; 576 576 577 577 export const duplicateName1QueryKey = (options?: Options) => [ 578 - createQueryKey("duplicateName1", options) 578 + createQueryKey('duplicateName1', options) 579 579 ]; 580 580 581 581 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 624 624 }; return mutationOptions; }; 625 625 626 626 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 627 - createQueryKey("callWithNoContentResponse", options) 627 + createQueryKey('callWithNoContentResponse', options) 628 628 ]; 629 629 630 630 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 640 640 }); }; 641 641 642 642 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 643 - createQueryKey("callWithResponseAndNoContentResponse", options) 643 + createQueryKey('callWithResponseAndNoContentResponse', options) 644 644 ]; 645 645 646 646 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 656 656 }); }; 657 657 658 658 export const dummyAQueryKey = (options?: Options) => [ 659 - createQueryKey("dummyA", options) 659 + createQueryKey('dummyA', options) 660 660 ]; 661 661 662 662 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 672 672 }); }; 673 673 674 674 export const dummyBQueryKey = (options?: Options) => [ 675 - createQueryKey("dummyB", options) 675 + createQueryKey('dummyB', options) 676 676 ]; 677 677 678 678 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 688 688 }); }; 689 689 690 690 export const callWithResponseQueryKey = (options?: Options) => [ 691 - createQueryKey("callWithResponse", options) 691 + createQueryKey('callWithResponse', options) 692 692 ]; 693 693 694 694 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 704 704 }); }; 705 705 706 706 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 707 - createQueryKey("callWithDuplicateResponses", options) 707 + createQueryKey('callWithDuplicateResponses', options) 708 708 ]; 709 709 710 710 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 742 742 }; return mutationOptions; }; 743 743 744 744 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 745 - createQueryKey("collectionFormat", options) 745 + createQueryKey('collectionFormat', options) 746 746 ]; 747 747 748 748 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 758 758 }); }; 759 759 760 760 export const typesQueryKey = (options: Options<TypesData>) => [ 761 - createQueryKey("types", options) 761 + createQueryKey('types', options) 762 762 ]; 763 763 764 764 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 774 774 }); }; 775 775 776 776 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 777 - createQueryKey("uploadFile", options) 777 + createQueryKey('uploadFile', options) 778 778 ]; 779 779 780 780 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 801 801 }; return mutationOptions; }; 802 802 803 803 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 804 - createQueryKey("fileResponse", options) 804 + createQueryKey('fileResponse', options) 805 805 ]; 806 806 807 807 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 817 817 }); }; 818 818 819 819 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 820 - createQueryKey("complexTypes", options) 820 + createQueryKey('complexTypes', options) 821 821 ]; 822 822 823 823 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 833 833 }); }; 834 834 835 835 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 836 - createQueryKey("multipartRequest", options) 836 + createQueryKey('multipartRequest', options) 837 837 ]; 838 838 839 839 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 860 860 }; return mutationOptions; }; 861 861 862 862 export const multipartResponseQueryKey = (options?: Options) => [ 863 - createQueryKey("multipartResponse", options) 863 + createQueryKey('multipartResponse', options) 864 864 ]; 865 865 866 866 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 887 887 }; return mutationOptions; }; 888 888 889 889 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 890 - createQueryKey("callWithResultFromHeader", options) 890 + createQueryKey('callWithResultFromHeader', options) 891 891 ]; 892 892 893 893 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 914 914 }; return mutationOptions; }; 915 915 916 916 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 917 - createQueryKey("testErrorCode", options) 917 + createQueryKey('testErrorCode', options) 918 918 ]; 919 919 920 920 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 941 941 }; return mutationOptions; }; 942 942 943 943 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 944 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 944 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 945 945 ]; 946 946 947 947 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts
··· 33 33 }; 34 34 35 35 export const exportQueryKey = (options?: Options) => [ 36 - createQueryKey("export", options) 36 + createQueryKey('export', options) 37 37 ]; 38 38 39 39 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const importQueryKey = (options: Options<ImportData>) => [ 52 - createQueryKey("import", options) 52 + createQueryKey('import', options) 53 53 ]; 54 54 55 55 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 79 - createQueryKey("apiVVersionOdataControllerCount", options) 79 + createQueryKey('apiVVersionOdataControllerCount', options) 80 80 ]; 81 81 82 82 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 95 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 95 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 96 96 ]; 97 97 98 98 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 108 108 }); }; 109 109 110 110 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 111 - createQueryKey("getCallWithoutParametersAndResponse", options) 111 + createQueryKey('getCallWithoutParametersAndResponse', options) 112 112 ]; 113 113 114 114 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 135 135 }; return mutationOptions; }; 136 136 137 137 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 138 - createQueryKey("postCallWithoutParametersAndResponse", options) 138 + createQueryKey('postCallWithoutParametersAndResponse', options) 139 139 ]; 140 140 141 141 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 195 195 }; return mutationOptions; }; 196 196 197 197 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 198 - createQueryKey("callWithDescriptions", options) 198 + createQueryKey('callWithDescriptions', options) 199 199 ]; 200 200 201 201 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 222 222 }; return mutationOptions; }; 223 223 224 224 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 225 - createQueryKey("deprecatedCall", options) 225 + createQueryKey('deprecatedCall', options) 226 226 ]; 227 227 228 228 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 249 249 }; return mutationOptions; }; 250 250 251 251 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 252 - createQueryKey("callWithParameters", options) 252 + createQueryKey('callWithParameters', options) 253 253 ]; 254 254 255 255 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 294 294 }; 295 295 296 296 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 297 - createQueryKey("callWithParameters", options, true) 297 + createQueryKey('callWithParameters', options, true) 298 298 ]; 299 299 300 300 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 302 302 { 303 303 queryFn: async ({ pageParam, queryKey }) => { 304 304 // @ts-ignore 305 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 305 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 306 306 query: { 307 307 cursor: pageParam 308 308 } ··· 330 330 }; return mutationOptions; }; 331 331 332 332 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 333 - createQueryKey("callWithWeirdParameterNames", options) 333 + createQueryKey('callWithWeirdParameterNames', options) 334 334 ]; 335 335 336 336 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 357 357 }; return mutationOptions; }; 358 358 359 359 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 360 - createQueryKey("getCallWithOptionalParam", options) 360 + createQueryKey('getCallWithOptionalParam', options) 361 361 ]; 362 362 363 363 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 373 373 }); }; 374 374 375 375 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 376 - createQueryKey("getCallWithOptionalParam", options, true) 376 + createQueryKey('getCallWithOptionalParam', options, true) 377 377 ]; 378 378 379 379 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 381 381 { 382 382 queryFn: async ({ pageParam, queryKey }) => { 383 383 // @ts-ignore 384 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 384 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 385 385 query: { 386 386 page: pageParam 387 387 } ··· 398 398 }); }; 399 399 400 400 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 401 - createQueryKey("postCallWithOptionalParam", options) 401 + createQueryKey('postCallWithOptionalParam', options) 402 402 ]; 403 403 404 404 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 414 414 }); }; 415 415 416 416 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 417 - createQueryKey("postCallWithOptionalParam", options, true) 417 + createQueryKey('postCallWithOptionalParam', options, true) 418 418 ]; 419 419 420 420 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 422 422 { 423 423 queryFn: async ({ pageParam, queryKey }) => { 424 424 // @ts-ignore 425 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 425 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 426 426 body: { 427 427 offset: pageParam 428 428 } ··· 450 450 }; return mutationOptions; }; 451 451 452 452 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 453 - createQueryKey("postApiVbyApiVersionRequestBody", options) 453 + createQueryKey('postApiVbyApiVersionRequestBody', options) 454 454 ]; 455 455 456 456 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 477 477 }; return mutationOptions; }; 478 478 479 479 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 480 - createQueryKey("postApiVbyApiVersionFormData", options) 480 + createQueryKey('postApiVbyApiVersionFormData', options) 481 481 ]; 482 482 483 483 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 504 504 }; return mutationOptions; }; 505 505 506 506 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 507 - createQueryKey("callWithDefaultParameters", options) 507 + createQueryKey('callWithDefaultParameters', options) 508 508 ]; 509 509 510 510 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 520 520 }); }; 521 521 522 522 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 523 - createQueryKey("callWithDefaultOptionalParameters", options) 523 + createQueryKey('callWithDefaultOptionalParameters', options) 524 524 ]; 525 525 526 526 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 558 558 }; return mutationOptions; }; 559 559 560 560 export const duplicateNameQueryKey = (options?: Options) => [ 561 - createQueryKey("duplicateName", options) 561 + createQueryKey('duplicateName', options) 562 562 ]; 563 563 564 564 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 574 574 }); }; 575 575 576 576 export const duplicateName1QueryKey = (options?: Options) => [ 577 - createQueryKey("duplicateName1", options) 577 + createQueryKey('duplicateName1', options) 578 578 ]; 579 579 580 580 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 623 623 }; return mutationOptions; }; 624 624 625 625 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 626 - createQueryKey("callWithNoContentResponse", options) 626 + createQueryKey('callWithNoContentResponse', options) 627 627 ]; 628 628 629 629 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 639 639 }); }; 640 640 641 641 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 642 - createQueryKey("callWithResponseAndNoContentResponse", options) 642 + createQueryKey('callWithResponseAndNoContentResponse', options) 643 643 ]; 644 644 645 645 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 655 655 }); }; 656 656 657 657 export const dummyAQueryKey = (options?: Options) => [ 658 - createQueryKey("dummyA", options) 658 + createQueryKey('dummyA', options) 659 659 ]; 660 660 661 661 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 671 671 }); }; 672 672 673 673 export const dummyBQueryKey = (options?: Options) => [ 674 - createQueryKey("dummyB", options) 674 + createQueryKey('dummyB', options) 675 675 ]; 676 676 677 677 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 687 687 }); }; 688 688 689 689 export const callWithResponseQueryKey = (options?: Options) => [ 690 - createQueryKey("callWithResponse", options) 690 + createQueryKey('callWithResponse', options) 691 691 ]; 692 692 693 693 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 703 703 }); }; 704 704 705 705 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 706 - createQueryKey("callWithDuplicateResponses", options) 706 + createQueryKey('callWithDuplicateResponses', options) 707 707 ]; 708 708 709 709 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 741 741 }; return mutationOptions; }; 742 742 743 743 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 744 - createQueryKey("collectionFormat", options) 744 + createQueryKey('collectionFormat', options) 745 745 ]; 746 746 747 747 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 757 757 }); }; 758 758 759 759 export const typesQueryKey = (options: Options<TypesData>) => [ 760 - createQueryKey("types", options) 760 + createQueryKey('types', options) 761 761 ]; 762 762 763 763 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 773 773 }); }; 774 774 775 775 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 776 - createQueryKey("uploadFile", options) 776 + createQueryKey('uploadFile', options) 777 777 ]; 778 778 779 779 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 800 800 }; return mutationOptions; }; 801 801 802 802 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 803 - createQueryKey("fileResponse", options) 803 + createQueryKey('fileResponse', options) 804 804 ]; 805 805 806 806 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 816 816 }); }; 817 817 818 818 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 819 - createQueryKey("complexTypes", options) 819 + createQueryKey('complexTypes', options) 820 820 ]; 821 821 822 822 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 832 832 }); }; 833 833 834 834 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 835 - createQueryKey("multipartRequest", options) 835 + createQueryKey('multipartRequest', options) 836 836 ]; 837 837 838 838 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 859 859 }; return mutationOptions; }; 860 860 861 861 export const multipartResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("multipartResponse", options) 862 + createQueryKey('multipartResponse', options) 863 863 ]; 864 864 865 865 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 889 - createQueryKey("callWithResultFromHeader", options) 889 + createQueryKey('callWithResultFromHeader', options) 890 890 ]; 891 891 892 892 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 913 913 }; return mutationOptions; }; 914 914 915 915 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 916 - createQueryKey("testErrorCode", options) 916 + createQueryKey('testErrorCode', options) 917 917 ]; 918 918 919 919 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 940 940 }; return mutationOptions; }; 941 941 942 942 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 943 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 943 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 944 944 ]; 945 945 946 946 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts
··· 33 33 }; 34 34 35 35 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 36 - createQueryKey("collectionFormat", options) 36 + createQueryKey('collectionFormat', options) 37 37 ]; 38 38 39 39 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 52 - createQueryKey("complexTypes", options) 52 + createQueryKey('complexTypes', options) 53 53 ]; 54 54 55 55 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const exportQueryKey = (options?: Options) => [ 79 - createQueryKey("export", options) 79 + createQueryKey('export', options) 80 80 ]; 81 81 82 82 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const importQueryKey = (options: Options<ImportData>) => [ 95 - createQueryKey("import", options) 95 + createQueryKey('import', options) 96 96 ]; 97 97 98 98 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 119 119 }; return mutationOptions; }; 120 120 121 121 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 122 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 122 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 123 123 ]; 124 124 125 125 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 135 135 }); }; 136 136 137 137 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 138 - createQueryKey("callWithDefaultParameters", options) 138 + createQueryKey('callWithDefaultParameters', options) 139 139 ]; 140 140 141 141 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 151 151 }); }; 152 152 153 153 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 154 - createQueryKey("callWithDefaultOptionalParameters", options) 154 + createQueryKey('callWithDefaultOptionalParameters', options) 155 155 ]; 156 156 157 157 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 189 189 }; return mutationOptions; }; 190 190 191 191 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 192 - createQueryKey("deprecatedCall", options) 192 + createQueryKey('deprecatedCall', options) 193 193 ]; 194 194 195 195 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 216 216 }; return mutationOptions; }; 217 217 218 218 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 219 - createQueryKey("callWithDescriptions", options) 219 + createQueryKey('callWithDescriptions', options) 220 220 ]; 221 221 222 222 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 243 243 }; return mutationOptions; }; 244 244 245 245 export const duplicateNameQueryKey = (options?: Options) => [ 246 - createQueryKey("duplicateName", options) 246 + createQueryKey('duplicateName', options) 247 247 ]; 248 248 249 249 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 259 259 }); }; 260 260 261 261 export const duplicateName1QueryKey = (options?: Options) => [ 262 - createQueryKey("duplicateName1", options) 262 + createQueryKey('duplicateName1', options) 263 263 ]; 264 264 265 265 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 308 308 }; return mutationOptions; }; 309 309 310 310 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 311 - createQueryKey("testErrorCode", options) 311 + createQueryKey('testErrorCode', options) 312 312 ]; 313 313 314 314 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 335 335 }; return mutationOptions; }; 336 336 337 337 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 338 - createQueryKey("fileResponse", options) 338 + createQueryKey('fileResponse', options) 339 339 ]; 340 340 341 341 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 351 351 }); }; 352 352 353 353 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 354 - createQueryKey("postApiVbyApiVersionFormData", options) 354 + createQueryKey('postApiVbyApiVersionFormData', options) 355 355 ]; 356 356 357 357 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 378 378 }; return mutationOptions; }; 379 379 380 380 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 381 - createQueryKey("callWithResultFromHeader", options) 381 + createQueryKey('callWithResultFromHeader', options) 382 382 ]; 383 383 384 384 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 405 405 }; return mutationOptions; }; 406 406 407 407 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 408 - createQueryKey("multipartRequest", options) 408 + createQueryKey('multipartRequest', options) 409 409 ]; 410 410 411 411 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 432 432 }; return mutationOptions; }; 433 433 434 434 export const multipartResponseQueryKey = (options?: Options) => [ 435 - createQueryKey("multipartResponse", options) 435 + createQueryKey('multipartResponse', options) 436 436 ]; 437 437 438 438 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 448 448 }); }; 449 449 450 450 export const dummyAQueryKey = (options?: Options) => [ 451 - createQueryKey("dummyA", options) 451 + createQueryKey('dummyA', options) 452 452 ]; 453 453 454 454 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 464 464 }); }; 465 465 466 466 export const dummyBQueryKey = (options?: Options) => [ 467 - createQueryKey("dummyB", options) 467 + createQueryKey('dummyB', options) 468 468 ]; 469 469 470 470 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 480 480 }); }; 481 481 482 482 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 483 - createQueryKey("callWithNoContentResponse", options) 483 + createQueryKey('callWithNoContentResponse', options) 484 484 ]; 485 485 486 486 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 496 496 }); }; 497 497 498 498 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 499 - createQueryKey("callWithResponseAndNoContentResponse", options) 499 + createQueryKey('callWithResponseAndNoContentResponse', options) 500 500 ]; 501 501 502 502 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 512 512 }); }; 513 513 514 514 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 515 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 515 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 516 516 ]; 517 517 518 518 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ ··· 561 561 }; return mutationOptions; }; 562 562 563 563 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 564 - createQueryKey("callWithParameters", options) 564 + createQueryKey('callWithParameters', options) 565 565 ]; 566 566 567 567 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 606 606 }; 607 607 608 608 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 609 - createQueryKey("callWithParameters", options, true) 609 + createQueryKey('callWithParameters', options, true) 610 610 ]; 611 611 612 612 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 614 614 { 615 615 queryFn: async ({ pageParam, queryKey }) => { 616 616 // @ts-ignore 617 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 617 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 618 618 query: { 619 619 cursor: pageParam 620 620 } ··· 642 642 }; return mutationOptions; }; 643 643 644 644 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 645 - createQueryKey("callWithWeirdParameterNames", options) 645 + createQueryKey('callWithWeirdParameterNames', options) 646 646 ]; 647 647 648 648 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 669 669 }; return mutationOptions; }; 670 670 671 671 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 672 - createQueryKey("getCallWithOptionalParam", options) 672 + createQueryKey('getCallWithOptionalParam', options) 673 673 ]; 674 674 675 675 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 685 685 }); }; 686 686 687 687 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 688 - createQueryKey("getCallWithOptionalParam", options, true) 688 + createQueryKey('getCallWithOptionalParam', options, true) 689 689 ]; 690 690 691 691 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 693 693 { 694 694 queryFn: async ({ pageParam, queryKey }) => { 695 695 // @ts-ignore 696 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 696 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 697 697 query: { 698 698 page: pageParam 699 699 } ··· 710 710 }); }; 711 711 712 712 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 713 - createQueryKey("postCallWithOptionalParam", options) 713 + createQueryKey('postCallWithOptionalParam', options) 714 714 ]; 715 715 716 716 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 726 726 }); }; 727 727 728 728 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 729 - createQueryKey("postCallWithOptionalParam", options, true) 729 + createQueryKey('postCallWithOptionalParam', options, true) 730 730 ]; 731 731 732 732 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 734 734 { 735 735 queryFn: async ({ pageParam, queryKey }) => { 736 736 // @ts-ignore 737 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 737 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 738 738 body: { 739 739 offset: pageParam 740 740 } ··· 762 762 }; return mutationOptions; }; 763 763 764 764 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 765 - createQueryKey("postApiVbyApiVersionRequestBody", options) 765 + createQueryKey('postApiVbyApiVersionRequestBody', options) 766 766 ]; 767 767 768 768 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 789 789 }; return mutationOptions; }; 790 790 791 791 export const callWithResponseQueryKey = (options?: Options) => [ 792 - createQueryKey("callWithResponse", options) 792 + createQueryKey('callWithResponse', options) 793 793 ]; 794 794 795 795 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 805 805 }); }; 806 806 807 807 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 808 - createQueryKey("callWithDuplicateResponses", options) 808 + createQueryKey('callWithDuplicateResponses', options) 809 809 ]; 810 810 811 811 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 843 843 }; return mutationOptions; }; 844 844 845 845 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 846 - createQueryKey("apiVVersionOdataControllerCount", options) 846 + createQueryKey('apiVVersionOdataControllerCount', options) 847 847 ]; 848 848 849 849 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 859 859 }); }; 860 860 861 861 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("getCallWithoutParametersAndResponse", options) 862 + createQueryKey('getCallWithoutParametersAndResponse', options) 863 863 ]; 864 864 865 865 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 889 - createQueryKey("postCallWithoutParametersAndResponse", options) 889 + createQueryKey('postCallWithoutParametersAndResponse', options) 890 890 ]; 891 891 892 892 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 935 935 }; return mutationOptions; }; 936 936 937 937 export const typesQueryKey = (options: Options<TypesData>) => [ 938 - createQueryKey("types", options) 938 + createQueryKey('types', options) 939 939 ]; 940 940 941 941 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 951 951 }); }; 952 952 953 953 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 954 - createQueryKey("uploadFile", options) 954 + createQueryKey('uploadFile', options) 955 955 ]; 956 956 957 957 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts
··· 34 34 }; 35 35 36 36 export const exportQueryKey = (options?: Options) => [ 37 - createQueryKey("export", options) 37 + createQueryKey('export', options) 38 38 ]; 39 39 40 40 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 50 50 }); }; 51 51 52 52 export const importQueryKey = (options: Options<ImportData>) => [ 53 - createQueryKey("import", options) 53 + createQueryKey('import', options) 54 54 ]; 55 55 56 56 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 77 77 }; return mutationOptions; }; 78 78 79 79 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 80 - createQueryKey("apiVVersionOdataControllerCount", options) 80 + createQueryKey('apiVVersionOdataControllerCount', options) 81 81 ]; 82 82 83 83 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 93 93 }); }; 94 94 95 95 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 96 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 96 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 97 97 ]; 98 98 99 99 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 109 109 }); }; 110 110 111 111 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 112 - createQueryKey("getCallWithoutParametersAndResponse", options) 112 + createQueryKey('getCallWithoutParametersAndResponse', options) 113 113 ]; 114 114 115 115 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 136 136 }; return mutationOptions; }; 137 137 138 138 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 139 - createQueryKey("postCallWithoutParametersAndResponse", options) 139 + createQueryKey('postCallWithoutParametersAndResponse', options) 140 140 ]; 141 141 142 142 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 196 196 }; return mutationOptions; }; 197 197 198 198 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 199 - createQueryKey("callWithDescriptions", options) 199 + createQueryKey('callWithDescriptions', options) 200 200 ]; 201 201 202 202 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 223 223 }; return mutationOptions; }; 224 224 225 225 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 226 - createQueryKey("deprecatedCall", options) 226 + createQueryKey('deprecatedCall', options) 227 227 ]; 228 228 229 229 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 250 250 }; return mutationOptions; }; 251 251 252 252 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 253 - createQueryKey("callWithParameters", options) 253 + createQueryKey('callWithParameters', options) 254 254 ]; 255 255 256 256 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 295 295 }; 296 296 297 297 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 298 - createQueryKey("callWithParameters", options, true) 298 + createQueryKey('callWithParameters', options, true) 299 299 ]; 300 300 301 301 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 303 303 { 304 304 queryFn: async ({ pageParam, queryKey }) => { 305 305 // @ts-ignore 306 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 306 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 307 307 query: { 308 308 cursor: pageParam 309 309 } ··· 331 331 }; return mutationOptions; }; 332 332 333 333 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 334 - createQueryKey("callWithWeirdParameterNames", options) 334 + createQueryKey('callWithWeirdParameterNames', options) 335 335 ]; 336 336 337 337 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 358 358 }; return mutationOptions; }; 359 359 360 360 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 361 - createQueryKey("getCallWithOptionalParam", options) 361 + createQueryKey('getCallWithOptionalParam', options) 362 362 ]; 363 363 364 364 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 374 374 }); }; 375 375 376 376 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 377 - createQueryKey("getCallWithOptionalParam", options, true) 377 + createQueryKey('getCallWithOptionalParam', options, true) 378 378 ]; 379 379 380 380 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 382 382 { 383 383 queryFn: async ({ pageParam, queryKey }) => { 384 384 // @ts-ignore 385 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 385 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 386 386 query: { 387 387 page: pageParam 388 388 } ··· 399 399 }); }; 400 400 401 401 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 402 - createQueryKey("postCallWithOptionalParam", options) 402 + createQueryKey('postCallWithOptionalParam', options) 403 403 ]; 404 404 405 405 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 415 415 }); }; 416 416 417 417 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 418 - createQueryKey("postCallWithOptionalParam", options, true) 418 + createQueryKey('postCallWithOptionalParam', options, true) 419 419 ]; 420 420 421 421 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 423 423 { 424 424 queryFn: async ({ pageParam, queryKey }) => { 425 425 // @ts-ignore 426 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 426 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 427 427 body: { 428 428 offset: pageParam 429 429 } ··· 451 451 }; return mutationOptions; }; 452 452 453 453 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 454 - createQueryKey("postApiVbyApiVersionRequestBody", options) 454 + createQueryKey('postApiVbyApiVersionRequestBody', options) 455 455 ]; 456 456 457 457 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 478 478 }; return mutationOptions; }; 479 479 480 480 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 481 - createQueryKey("postApiVbyApiVersionFormData", options) 481 + createQueryKey('postApiVbyApiVersionFormData', options) 482 482 ]; 483 483 484 484 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 505 505 }; return mutationOptions; }; 506 506 507 507 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 508 - createQueryKey("callWithDefaultParameters", options) 508 + createQueryKey('callWithDefaultParameters', options) 509 509 ]; 510 510 511 511 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 521 521 }); }; 522 522 523 523 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 524 - createQueryKey("callWithDefaultOptionalParameters", options) 524 + createQueryKey('callWithDefaultOptionalParameters', options) 525 525 ]; 526 526 527 527 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 559 559 }; return mutationOptions; }; 560 560 561 561 export const duplicateNameQueryKey = (options?: Options) => [ 562 - createQueryKey("duplicateName", options) 562 + createQueryKey('duplicateName', options) 563 563 ]; 564 564 565 565 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 575 575 }); }; 576 576 577 577 export const duplicateName1QueryKey = (options?: Options) => [ 578 - createQueryKey("duplicateName1", options) 578 + createQueryKey('duplicateName1', options) 579 579 ]; 580 580 581 581 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 624 624 }; return mutationOptions; }; 625 625 626 626 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 627 - createQueryKey("callWithNoContentResponse", options) 627 + createQueryKey('callWithNoContentResponse', options) 628 628 ]; 629 629 630 630 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 640 640 }); }; 641 641 642 642 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 643 - createQueryKey("callWithResponseAndNoContentResponse", options) 643 + createQueryKey('callWithResponseAndNoContentResponse', options) 644 644 ]; 645 645 646 646 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 656 656 }); }; 657 657 658 658 export const dummyAQueryKey = (options?: Options) => [ 659 - createQueryKey("dummyA", options) 659 + createQueryKey('dummyA', options) 660 660 ]; 661 661 662 662 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 672 672 }); }; 673 673 674 674 export const dummyBQueryKey = (options?: Options) => [ 675 - createQueryKey("dummyB", options) 675 + createQueryKey('dummyB', options) 676 676 ]; 677 677 678 678 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 688 688 }); }; 689 689 690 690 export const callWithResponseQueryKey = (options?: Options) => [ 691 - createQueryKey("callWithResponse", options) 691 + createQueryKey('callWithResponse', options) 692 692 ]; 693 693 694 694 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 704 704 }); }; 705 705 706 706 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 707 - createQueryKey("callWithDuplicateResponses", options) 707 + createQueryKey('callWithDuplicateResponses', options) 708 708 ]; 709 709 710 710 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 742 742 }; return mutationOptions; }; 743 743 744 744 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 745 - createQueryKey("collectionFormat", options) 745 + createQueryKey('collectionFormat', options) 746 746 ]; 747 747 748 748 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 758 758 }); }; 759 759 760 760 export const typesQueryKey = (options: Options<TypesData>) => [ 761 - createQueryKey("types", options) 761 + createQueryKey('types', options) 762 762 ]; 763 763 764 764 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 774 774 }); }; 775 775 776 776 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 777 - createQueryKey("uploadFile", options) 777 + createQueryKey('uploadFile', options) 778 778 ]; 779 779 780 780 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 801 801 }; return mutationOptions; }; 802 802 803 803 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 804 - createQueryKey("fileResponse", options) 804 + createQueryKey('fileResponse', options) 805 805 ]; 806 806 807 807 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 817 817 }); }; 818 818 819 819 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 820 - createQueryKey("complexTypes", options) 820 + createQueryKey('complexTypes', options) 821 821 ]; 822 822 823 823 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 833 833 }); }; 834 834 835 835 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 836 - createQueryKey("multipartRequest", options) 836 + createQueryKey('multipartRequest', options) 837 837 ]; 838 838 839 839 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 860 860 }; return mutationOptions; }; 861 861 862 862 export const multipartResponseQueryKey = (options?: Options) => [ 863 - createQueryKey("multipartResponse", options) 863 + createQueryKey('multipartResponse', options) 864 864 ]; 865 865 866 866 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 887 887 }; return mutationOptions; }; 888 888 889 889 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 890 - createQueryKey("callWithResultFromHeader", options) 890 + createQueryKey('callWithResultFromHeader', options) 891 891 ]; 892 892 893 893 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 914 914 }; return mutationOptions; }; 915 915 916 916 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 917 - createQueryKey("testErrorCode", options) 917 + createQueryKey('testErrorCode', options) 918 918 ]; 919 919 920 920 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 941 941 }; return mutationOptions; }; 942 942 943 943 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 944 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 944 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 945 945 ]; 946 946 947 947 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts
··· 33 33 }; 34 34 35 35 export const exportQueryKey = (options?: Options) => [ 36 - createQueryKey("export", options) 36 + createQueryKey('export', options) 37 37 ]; 38 38 39 39 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const importQueryKey = (options: Options<ImportData>) => [ 52 - createQueryKey("import", options) 52 + createQueryKey('import', options) 53 53 ]; 54 54 55 55 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 79 - createQueryKey("apiVVersionOdataControllerCount", options) 79 + createQueryKey('apiVVersionOdataControllerCount', options) 80 80 ]; 81 81 82 82 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 95 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 95 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 96 96 ]; 97 97 98 98 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 108 108 }); }; 109 109 110 110 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 111 - createQueryKey("getCallWithoutParametersAndResponse", options) 111 + createQueryKey('getCallWithoutParametersAndResponse', options) 112 112 ]; 113 113 114 114 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 135 135 }; return mutationOptions; }; 136 136 137 137 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 138 - createQueryKey("postCallWithoutParametersAndResponse", options) 138 + createQueryKey('postCallWithoutParametersAndResponse', options) 139 139 ]; 140 140 141 141 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 195 195 }; return mutationOptions; }; 196 196 197 197 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 198 - createQueryKey("callWithDescriptions", options) 198 + createQueryKey('callWithDescriptions', options) 199 199 ]; 200 200 201 201 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 222 222 }; return mutationOptions; }; 223 223 224 224 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 225 - createQueryKey("deprecatedCall", options) 225 + createQueryKey('deprecatedCall', options) 226 226 ]; 227 227 228 228 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 249 249 }; return mutationOptions; }; 250 250 251 251 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 252 - createQueryKey("callWithParameters", options) 252 + createQueryKey('callWithParameters', options) 253 253 ]; 254 254 255 255 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 294 294 }; 295 295 296 296 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 297 - createQueryKey("callWithParameters", options, true) 297 + createQueryKey('callWithParameters', options, true) 298 298 ]; 299 299 300 300 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 302 302 { 303 303 queryFn: async ({ pageParam, queryKey }) => { 304 304 // @ts-ignore 305 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 305 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 306 306 query: { 307 307 cursor: pageParam 308 308 } ··· 330 330 }; return mutationOptions; }; 331 331 332 332 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 333 - createQueryKey("callWithWeirdParameterNames", options) 333 + createQueryKey('callWithWeirdParameterNames', options) 334 334 ]; 335 335 336 336 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 357 357 }; return mutationOptions; }; 358 358 359 359 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 360 - createQueryKey("getCallWithOptionalParam", options) 360 + createQueryKey('getCallWithOptionalParam', options) 361 361 ]; 362 362 363 363 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 373 373 }); }; 374 374 375 375 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 376 - createQueryKey("getCallWithOptionalParam", options, true) 376 + createQueryKey('getCallWithOptionalParam', options, true) 377 377 ]; 378 378 379 379 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 381 381 { 382 382 queryFn: async ({ pageParam, queryKey }) => { 383 383 // @ts-ignore 384 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 384 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 385 385 query: { 386 386 page: pageParam 387 387 } ··· 398 398 }); }; 399 399 400 400 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 401 - createQueryKey("postCallWithOptionalParam", options) 401 + createQueryKey('postCallWithOptionalParam', options) 402 402 ]; 403 403 404 404 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 414 414 }); }; 415 415 416 416 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 417 - createQueryKey("postCallWithOptionalParam", options, true) 417 + createQueryKey('postCallWithOptionalParam', options, true) 418 418 ]; 419 419 420 420 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 422 422 { 423 423 queryFn: async ({ pageParam, queryKey }) => { 424 424 // @ts-ignore 425 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 425 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 426 426 body: { 427 427 offset: pageParam 428 428 } ··· 450 450 }; return mutationOptions; }; 451 451 452 452 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 453 - createQueryKey("postApiVbyApiVersionRequestBody", options) 453 + createQueryKey('postApiVbyApiVersionRequestBody', options) 454 454 ]; 455 455 456 456 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 477 477 }; return mutationOptions; }; 478 478 479 479 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 480 - createQueryKey("postApiVbyApiVersionFormData", options) 480 + createQueryKey('postApiVbyApiVersionFormData', options) 481 481 ]; 482 482 483 483 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 504 504 }; return mutationOptions; }; 505 505 506 506 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 507 - createQueryKey("callWithDefaultParameters", options) 507 + createQueryKey('callWithDefaultParameters', options) 508 508 ]; 509 509 510 510 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 520 520 }); }; 521 521 522 522 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 523 - createQueryKey("callWithDefaultOptionalParameters", options) 523 + createQueryKey('callWithDefaultOptionalParameters', options) 524 524 ]; 525 525 526 526 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 558 558 }; return mutationOptions; }; 559 559 560 560 export const duplicateNameQueryKey = (options?: Options) => [ 561 - createQueryKey("duplicateName", options) 561 + createQueryKey('duplicateName', options) 562 562 ]; 563 563 564 564 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 574 574 }); }; 575 575 576 576 export const duplicateName1QueryKey = (options?: Options) => [ 577 - createQueryKey("duplicateName1", options) 577 + createQueryKey('duplicateName1', options) 578 578 ]; 579 579 580 580 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 623 623 }; return mutationOptions; }; 624 624 625 625 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 626 - createQueryKey("callWithNoContentResponse", options) 626 + createQueryKey('callWithNoContentResponse', options) 627 627 ]; 628 628 629 629 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 639 639 }); }; 640 640 641 641 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 642 - createQueryKey("callWithResponseAndNoContentResponse", options) 642 + createQueryKey('callWithResponseAndNoContentResponse', options) 643 643 ]; 644 644 645 645 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 655 655 }); }; 656 656 657 657 export const dummyAQueryKey = (options?: Options) => [ 658 - createQueryKey("dummyA", options) 658 + createQueryKey('dummyA', options) 659 659 ]; 660 660 661 661 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 671 671 }); }; 672 672 673 673 export const dummyBQueryKey = (options?: Options) => [ 674 - createQueryKey("dummyB", options) 674 + createQueryKey('dummyB', options) 675 675 ]; 676 676 677 677 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 687 687 }); }; 688 688 689 689 export const callWithResponseQueryKey = (options?: Options) => [ 690 - createQueryKey("callWithResponse", options) 690 + createQueryKey('callWithResponse', options) 691 691 ]; 692 692 693 693 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 703 703 }); }; 704 704 705 705 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 706 - createQueryKey("callWithDuplicateResponses", options) 706 + createQueryKey('callWithDuplicateResponses', options) 707 707 ]; 708 708 709 709 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 741 741 }; return mutationOptions; }; 742 742 743 743 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 744 - createQueryKey("collectionFormat", options) 744 + createQueryKey('collectionFormat', options) 745 745 ]; 746 746 747 747 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 757 757 }); }; 758 758 759 759 export const typesQueryKey = (options: Options<TypesData>) => [ 760 - createQueryKey("types", options) 760 + createQueryKey('types', options) 761 761 ]; 762 762 763 763 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 773 773 }); }; 774 774 775 775 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 776 - createQueryKey("uploadFile", options) 776 + createQueryKey('uploadFile', options) 777 777 ]; 778 778 779 779 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 800 800 }; return mutationOptions; }; 801 801 802 802 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 803 - createQueryKey("fileResponse", options) 803 + createQueryKey('fileResponse', options) 804 804 ]; 805 805 806 806 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 816 816 }); }; 817 817 818 818 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 819 - createQueryKey("complexTypes", options) 819 + createQueryKey('complexTypes', options) 820 820 ]; 821 821 822 822 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 832 832 }); }; 833 833 834 834 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 835 - createQueryKey("multipartRequest", options) 835 + createQueryKey('multipartRequest', options) 836 836 ]; 837 837 838 838 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 859 859 }; return mutationOptions; }; 860 860 861 861 export const multipartResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("multipartResponse", options) 862 + createQueryKey('multipartResponse', options) 863 863 ]; 864 864 865 865 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 889 - createQueryKey("callWithResultFromHeader", options) 889 + createQueryKey('callWithResultFromHeader', options) 890 890 ]; 891 891 892 892 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 913 913 }; return mutationOptions; }; 914 914 915 915 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 916 - createQueryKey("testErrorCode", options) 916 + createQueryKey('testErrorCode', options) 917 917 ]; 918 918 919 919 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 940 940 }; return mutationOptions; }; 941 941 942 942 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 943 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 943 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 944 944 ]; 945 945 946 946 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts
··· 33 33 }; 34 34 35 35 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 36 - createQueryKey("collectionFormat", options) 36 + createQueryKey('collectionFormat', options) 37 37 ]; 38 38 39 39 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 52 - createQueryKey("complexTypes", options) 52 + createQueryKey('complexTypes', options) 53 53 ]; 54 54 55 55 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const exportQueryKey = (options?: Options) => [ 79 - createQueryKey("export", options) 79 + createQueryKey('export', options) 80 80 ]; 81 81 82 82 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const importQueryKey = (options: Options<ImportData>) => [ 95 - createQueryKey("import", options) 95 + createQueryKey('import', options) 96 96 ]; 97 97 98 98 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 119 119 }; return mutationOptions; }; 120 120 121 121 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 122 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 122 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 123 123 ]; 124 124 125 125 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 135 135 }); }; 136 136 137 137 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 138 - createQueryKey("callWithDefaultParameters", options) 138 + createQueryKey('callWithDefaultParameters', options) 139 139 ]; 140 140 141 141 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 151 151 }); }; 152 152 153 153 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 154 - createQueryKey("callWithDefaultOptionalParameters", options) 154 + createQueryKey('callWithDefaultOptionalParameters', options) 155 155 ]; 156 156 157 157 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 189 189 }; return mutationOptions; }; 190 190 191 191 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 192 - createQueryKey("deprecatedCall", options) 192 + createQueryKey('deprecatedCall', options) 193 193 ]; 194 194 195 195 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 216 216 }; return mutationOptions; }; 217 217 218 218 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 219 - createQueryKey("callWithDescriptions", options) 219 + createQueryKey('callWithDescriptions', options) 220 220 ]; 221 221 222 222 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 243 243 }; return mutationOptions; }; 244 244 245 245 export const duplicateNameQueryKey = (options?: Options) => [ 246 - createQueryKey("duplicateName", options) 246 + createQueryKey('duplicateName', options) 247 247 ]; 248 248 249 249 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 259 259 }); }; 260 260 261 261 export const duplicateName1QueryKey = (options?: Options) => [ 262 - createQueryKey("duplicateName1", options) 262 + createQueryKey('duplicateName1', options) 263 263 ]; 264 264 265 265 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 308 308 }; return mutationOptions; }; 309 309 310 310 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 311 - createQueryKey("testErrorCode", options) 311 + createQueryKey('testErrorCode', options) 312 312 ]; 313 313 314 314 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 335 335 }; return mutationOptions; }; 336 336 337 337 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 338 - createQueryKey("fileResponse", options) 338 + createQueryKey('fileResponse', options) 339 339 ]; 340 340 341 341 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 351 351 }); }; 352 352 353 353 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 354 - createQueryKey("postApiVbyApiVersionFormData", options) 354 + createQueryKey('postApiVbyApiVersionFormData', options) 355 355 ]; 356 356 357 357 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 378 378 }; return mutationOptions; }; 379 379 380 380 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 381 - createQueryKey("callWithResultFromHeader", options) 381 + createQueryKey('callWithResultFromHeader', options) 382 382 ]; 383 383 384 384 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 405 405 }; return mutationOptions; }; 406 406 407 407 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 408 - createQueryKey("multipartRequest", options) 408 + createQueryKey('multipartRequest', options) 409 409 ]; 410 410 411 411 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 432 432 }; return mutationOptions; }; 433 433 434 434 export const multipartResponseQueryKey = (options?: Options) => [ 435 - createQueryKey("multipartResponse", options) 435 + createQueryKey('multipartResponse', options) 436 436 ]; 437 437 438 438 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 448 448 }); }; 449 449 450 450 export const dummyAQueryKey = (options?: Options) => [ 451 - createQueryKey("dummyA", options) 451 + createQueryKey('dummyA', options) 452 452 ]; 453 453 454 454 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 464 464 }); }; 465 465 466 466 export const dummyBQueryKey = (options?: Options) => [ 467 - createQueryKey("dummyB", options) 467 + createQueryKey('dummyB', options) 468 468 ]; 469 469 470 470 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 480 480 }); }; 481 481 482 482 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 483 - createQueryKey("callWithNoContentResponse", options) 483 + createQueryKey('callWithNoContentResponse', options) 484 484 ]; 485 485 486 486 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 496 496 }); }; 497 497 498 498 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 499 - createQueryKey("callWithResponseAndNoContentResponse", options) 499 + createQueryKey('callWithResponseAndNoContentResponse', options) 500 500 ]; 501 501 502 502 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 512 512 }); }; 513 513 514 514 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 515 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 515 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 516 516 ]; 517 517 518 518 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({ ··· 561 561 }; return mutationOptions; }; 562 562 563 563 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 564 - createQueryKey("callWithParameters", options) 564 + createQueryKey('callWithParameters', options) 565 565 ]; 566 566 567 567 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 606 606 }; 607 607 608 608 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 609 - createQueryKey("callWithParameters", options, true) 609 + createQueryKey('callWithParameters', options, true) 610 610 ]; 611 611 612 612 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 614 614 { 615 615 queryFn: async ({ pageParam, queryKey }) => { 616 616 // @ts-ignore 617 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 617 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 618 618 query: { 619 619 cursor: pageParam 620 620 } ··· 642 642 }; return mutationOptions; }; 643 643 644 644 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 645 - createQueryKey("callWithWeirdParameterNames", options) 645 + createQueryKey('callWithWeirdParameterNames', options) 646 646 ]; 647 647 648 648 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 669 669 }; return mutationOptions; }; 670 670 671 671 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 672 - createQueryKey("getCallWithOptionalParam", options) 672 + createQueryKey('getCallWithOptionalParam', options) 673 673 ]; 674 674 675 675 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 685 685 }); }; 686 686 687 687 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 688 - createQueryKey("getCallWithOptionalParam", options, true) 688 + createQueryKey('getCallWithOptionalParam', options, true) 689 689 ]; 690 690 691 691 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 693 693 { 694 694 queryFn: async ({ pageParam, queryKey }) => { 695 695 // @ts-ignore 696 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 696 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 697 697 query: { 698 698 page: pageParam 699 699 } ··· 710 710 }); }; 711 711 712 712 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 713 - createQueryKey("postCallWithOptionalParam", options) 713 + createQueryKey('postCallWithOptionalParam', options) 714 714 ]; 715 715 716 716 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 726 726 }); }; 727 727 728 728 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 729 - createQueryKey("postCallWithOptionalParam", options, true) 729 + createQueryKey('postCallWithOptionalParam', options, true) 730 730 ]; 731 731 732 732 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 734 734 { 735 735 queryFn: async ({ pageParam, queryKey }) => { 736 736 // @ts-ignore 737 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 737 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 738 738 body: { 739 739 offset: pageParam 740 740 } ··· 762 762 }; return mutationOptions; }; 763 763 764 764 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 765 - createQueryKey("postApiVbyApiVersionRequestBody", options) 765 + createQueryKey('postApiVbyApiVersionRequestBody', options) 766 766 ]; 767 767 768 768 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 789 789 }; return mutationOptions; }; 790 790 791 791 export const callWithResponseQueryKey = (options?: Options) => [ 792 - createQueryKey("callWithResponse", options) 792 + createQueryKey('callWithResponse', options) 793 793 ]; 794 794 795 795 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 805 805 }); }; 806 806 807 807 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 808 - createQueryKey("callWithDuplicateResponses", options) 808 + createQueryKey('callWithDuplicateResponses', options) 809 809 ]; 810 810 811 811 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 843 843 }; return mutationOptions; }; 844 844 845 845 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 846 - createQueryKey("apiVVersionOdataControllerCount", options) 846 + createQueryKey('apiVVersionOdataControllerCount', options) 847 847 ]; 848 848 849 849 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 859 859 }); }; 860 860 861 861 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("getCallWithoutParametersAndResponse", options) 862 + createQueryKey('getCallWithoutParametersAndResponse', options) 863 863 ]; 864 864 865 865 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 889 - createQueryKey("postCallWithoutParametersAndResponse", options) 889 + createQueryKey('postCallWithoutParametersAndResponse', options) 890 890 ]; 891 891 892 892 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 935 935 }; return mutationOptions; }; 936 936 937 937 export const typesQueryKey = (options: Options<TypesData>) => [ 938 - createQueryKey("types", options) 938 + createQueryKey('types', options) 939 939 ]; 940 940 941 941 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 951 951 }); }; 952 952 953 953 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 954 - createQueryKey("uploadFile", options) 954 + createQueryKey('uploadFile', options) 955 955 ]; 956 956 957 957 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts
··· 34 34 }; 35 35 36 36 export const exportQueryKey = (options?: Options) => [ 37 - createQueryKey("export", options) 37 + createQueryKey('export', options) 38 38 ]; 39 39 40 40 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 50 50 }); }; 51 51 52 52 export const importQueryKey = (options: Options<ImportData>) => [ 53 - createQueryKey("import", options) 53 + createQueryKey('import', options) 54 54 ]; 55 55 56 56 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 77 77 }; return mutationOptions; }; 78 78 79 79 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 80 - createQueryKey("apiVVersionOdataControllerCount", options) 80 + createQueryKey('apiVVersionOdataControllerCount', options) 81 81 ]; 82 82 83 83 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 93 93 }); }; 94 94 95 95 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 96 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 96 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 97 97 ]; 98 98 99 99 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 109 109 }); }; 110 110 111 111 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 112 - createQueryKey("getCallWithoutParametersAndResponse", options) 112 + createQueryKey('getCallWithoutParametersAndResponse', options) 113 113 ]; 114 114 115 115 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 136 136 }; return mutationOptions; }; 137 137 138 138 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 139 - createQueryKey("postCallWithoutParametersAndResponse", options) 139 + createQueryKey('postCallWithoutParametersAndResponse', options) 140 140 ]; 141 141 142 142 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 196 196 }; return mutationOptions; }; 197 197 198 198 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 199 - createQueryKey("callWithDescriptions", options) 199 + createQueryKey('callWithDescriptions', options) 200 200 ]; 201 201 202 202 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 223 223 }; return mutationOptions; }; 224 224 225 225 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 226 - createQueryKey("deprecatedCall", options) 226 + createQueryKey('deprecatedCall', options) 227 227 ]; 228 228 229 229 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 250 250 }; return mutationOptions; }; 251 251 252 252 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 253 - createQueryKey("callWithParameters", options) 253 + createQueryKey('callWithParameters', options) 254 254 ]; 255 255 256 256 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 295 295 }; 296 296 297 297 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 298 - createQueryKey("callWithParameters", options, true) 298 + createQueryKey('callWithParameters', options, true) 299 299 ]; 300 300 301 301 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 303 303 { 304 304 queryFn: async ({ pageParam, queryKey }) => { 305 305 // @ts-ignore 306 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 306 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 307 307 query: { 308 308 cursor: pageParam 309 309 } ··· 331 331 }; return mutationOptions; }; 332 332 333 333 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 334 - createQueryKey("callWithWeirdParameterNames", options) 334 + createQueryKey('callWithWeirdParameterNames', options) 335 335 ]; 336 336 337 337 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 358 358 }; return mutationOptions; }; 359 359 360 360 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 361 - createQueryKey("getCallWithOptionalParam", options) 361 + createQueryKey('getCallWithOptionalParam', options) 362 362 ]; 363 363 364 364 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 374 374 }); }; 375 375 376 376 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 377 - createQueryKey("getCallWithOptionalParam", options, true) 377 + createQueryKey('getCallWithOptionalParam', options, true) 378 378 ]; 379 379 380 380 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, AxiosError<DefaultError>, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 382 382 { 383 383 queryFn: async ({ pageParam, queryKey }) => { 384 384 // @ts-ignore 385 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 385 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 386 386 query: { 387 387 page: pageParam 388 388 } ··· 399 399 }); }; 400 400 401 401 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 402 - createQueryKey("postCallWithOptionalParam", options) 402 + createQueryKey('postCallWithOptionalParam', options) 403 403 ]; 404 404 405 405 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 415 415 }); }; 416 416 417 417 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 418 - createQueryKey("postCallWithOptionalParam", options, true) 418 + createQueryKey('postCallWithOptionalParam', options, true) 419 419 ]; 420 420 421 421 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, AxiosError<PostCallWithOptionalParamError>, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 423 423 { 424 424 queryFn: async ({ pageParam, queryKey }) => { 425 425 // @ts-ignore 426 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 426 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 427 427 body: { 428 428 offset: pageParam 429 429 } ··· 451 451 }; return mutationOptions; }; 452 452 453 453 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 454 - createQueryKey("postApiVbyApiVersionRequestBody", options) 454 + createQueryKey('postApiVbyApiVersionRequestBody', options) 455 455 ]; 456 456 457 457 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 478 478 }; return mutationOptions; }; 479 479 480 480 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 481 - createQueryKey("postApiVbyApiVersionFormData", options) 481 + createQueryKey('postApiVbyApiVersionFormData', options) 482 482 ]; 483 483 484 484 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 505 505 }; return mutationOptions; }; 506 506 507 507 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 508 - createQueryKey("callWithDefaultParameters", options) 508 + createQueryKey('callWithDefaultParameters', options) 509 509 ]; 510 510 511 511 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 521 521 }); }; 522 522 523 523 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 524 - createQueryKey("callWithDefaultOptionalParameters", options) 524 + createQueryKey('callWithDefaultOptionalParameters', options) 525 525 ]; 526 526 527 527 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 559 559 }; return mutationOptions; }; 560 560 561 561 export const duplicateNameQueryKey = (options?: Options) => [ 562 - createQueryKey("duplicateName", options) 562 + createQueryKey('duplicateName', options) 563 563 ]; 564 564 565 565 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 575 575 }); }; 576 576 577 577 export const duplicateName1QueryKey = (options?: Options) => [ 578 - createQueryKey("duplicateName1", options) 578 + createQueryKey('duplicateName1', options) 579 579 ]; 580 580 581 581 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 624 624 }; return mutationOptions; }; 625 625 626 626 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 627 - createQueryKey("callWithNoContentResponse", options) 627 + createQueryKey('callWithNoContentResponse', options) 628 628 ]; 629 629 630 630 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 640 640 }); }; 641 641 642 642 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 643 - createQueryKey("callWithResponseAndNoContentResponse", options) 643 + createQueryKey('callWithResponseAndNoContentResponse', options) 644 644 ]; 645 645 646 646 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 656 656 }); }; 657 657 658 658 export const dummyAQueryKey = (options?: Options) => [ 659 - createQueryKey("dummyA", options) 659 + createQueryKey('dummyA', options) 660 660 ]; 661 661 662 662 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 672 672 }); }; 673 673 674 674 export const dummyBQueryKey = (options?: Options) => [ 675 - createQueryKey("dummyB", options) 675 + createQueryKey('dummyB', options) 676 676 ]; 677 677 678 678 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 688 688 }); }; 689 689 690 690 export const callWithResponseQueryKey = (options?: Options) => [ 691 - createQueryKey("callWithResponse", options) 691 + createQueryKey('callWithResponse', options) 692 692 ]; 693 693 694 694 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 704 704 }); }; 705 705 706 706 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 707 - createQueryKey("callWithDuplicateResponses", options) 707 + createQueryKey('callWithDuplicateResponses', options) 708 708 ]; 709 709 710 710 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 742 742 }; return mutationOptions; }; 743 743 744 744 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 745 - createQueryKey("collectionFormat", options) 745 + createQueryKey('collectionFormat', options) 746 746 ]; 747 747 748 748 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 758 758 }); }; 759 759 760 760 export const typesQueryKey = (options: Options<TypesData>) => [ 761 - createQueryKey("types", options) 761 + createQueryKey('types', options) 762 762 ]; 763 763 764 764 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 774 774 }); }; 775 775 776 776 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 777 - createQueryKey("uploadFile", options) 777 + createQueryKey('uploadFile', options) 778 778 ]; 779 779 780 780 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 801 801 }; return mutationOptions; }; 802 802 803 803 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 804 - createQueryKey("fileResponse", options) 804 + createQueryKey('fileResponse', options) 805 805 ]; 806 806 807 807 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 817 817 }); }; 818 818 819 819 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 820 - createQueryKey("complexTypes", options) 820 + createQueryKey('complexTypes', options) 821 821 ]; 822 822 823 823 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 833 833 }); }; 834 834 835 835 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 836 - createQueryKey("multipartRequest", options) 836 + createQueryKey('multipartRequest', options) 837 837 ]; 838 838 839 839 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 860 860 }; return mutationOptions; }; 861 861 862 862 export const multipartResponseQueryKey = (options?: Options) => [ 863 - createQueryKey("multipartResponse", options) 863 + createQueryKey('multipartResponse', options) 864 864 ]; 865 865 866 866 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 887 887 }; return mutationOptions; }; 888 888 889 889 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 890 - createQueryKey("callWithResultFromHeader", options) 890 + createQueryKey('callWithResultFromHeader', options) 891 891 ]; 892 892 893 893 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 914 914 }; return mutationOptions; }; 915 915 916 916 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 917 - createQueryKey("testErrorCode", options) 917 + createQueryKey('testErrorCode', options) 918 918 ]; 919 919 920 920 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 941 941 }; return mutationOptions; }; 942 942 943 943 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 944 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 944 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 945 945 ]; 946 946 947 947 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+40 -40
packages/openapi-ts/test/__snapshots__/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts
··· 33 33 }; 34 34 35 35 export const exportQueryKey = (options?: Options) => [ 36 - createQueryKey("export", options) 36 + createQueryKey('export', options) 37 37 ]; 38 38 39 39 export const exportOptions = (options?: Options) => { return queryOptions({ ··· 49 49 }); }; 50 50 51 51 export const importQueryKey = (options: Options<ImportData>) => [ 52 - createQueryKey("import", options) 52 + createQueryKey('import', options) 53 53 ]; 54 54 55 55 export const importOptions = (options: Options<ImportData>) => { return queryOptions({ ··· 76 76 }; return mutationOptions; }; 77 77 78 78 export const apiVVersionOdataControllerCountQueryKey = (options?: Options) => [ 79 - createQueryKey("apiVVersionOdataControllerCount", options) 79 + createQueryKey('apiVVersionOdataControllerCount', options) 80 80 ]; 81 81 82 82 export const apiVVersionOdataControllerCountOptions = (options?: Options) => { return queryOptions({ ··· 92 92 }); }; 93 93 94 94 export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => [ 95 - createQueryKey("getApiVbyApiVersionSimpleOperation", options) 95 + createQueryKey('getApiVbyApiVersionSimpleOperation', options) 96 96 ]; 97 97 98 98 export const getApiVbyApiVersionSimpleOperationOptions = (options: Options<GetApiVbyApiVersionSimpleOperationData>) => { return queryOptions({ ··· 108 108 }); }; 109 109 110 110 export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 111 - createQueryKey("getCallWithoutParametersAndResponse", options) 111 + createQueryKey('getCallWithoutParametersAndResponse', options) 112 112 ]; 113 113 114 114 export const getCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 135 135 }; return mutationOptions; }; 136 136 137 137 export const postCallWithoutParametersAndResponseQueryKey = (options?: Options) => [ 138 - createQueryKey("postCallWithoutParametersAndResponse", options) 138 + createQueryKey('postCallWithoutParametersAndResponse', options) 139 139 ]; 140 140 141 141 export const postCallWithoutParametersAndResponseOptions = (options?: Options) => { return queryOptions({ ··· 195 195 }; return mutationOptions; }; 196 196 197 197 export const callWithDescriptionsQueryKey = (options?: Options<CallWithDescriptionsData>) => [ 198 - createQueryKey("callWithDescriptions", options) 198 + createQueryKey('callWithDescriptions', options) 199 199 ]; 200 200 201 201 export const callWithDescriptionsOptions = (options?: Options<CallWithDescriptionsData>) => { return queryOptions({ ··· 222 222 }; return mutationOptions; }; 223 223 224 224 export const deprecatedCallQueryKey = (options: Options<DeprecatedCallData>) => [ 225 - createQueryKey("deprecatedCall", options) 225 + createQueryKey('deprecatedCall', options) 226 226 ]; 227 227 228 228 export const deprecatedCallOptions = (options: Options<DeprecatedCallData>) => { return queryOptions({ ··· 249 249 }; return mutationOptions; }; 250 250 251 251 export const callWithParametersQueryKey = (options: Options<CallWithParametersData>) => [ 252 - createQueryKey("callWithParameters", options) 252 + createQueryKey('callWithParameters', options) 253 253 ]; 254 254 255 255 export const callWithParametersOptions = (options: Options<CallWithParametersData>) => { return queryOptions({ ··· 294 294 }; 295 295 296 296 export const callWithParametersInfiniteQueryKey = (options: Options<CallWithParametersData>): QueryKey<Options<CallWithParametersData>> => [ 297 - createQueryKey("callWithParameters", options, true) 297 + createQueryKey('callWithParameters', options, true) 298 298 ]; 299 299 300 300 export const callWithParametersInfiniteOptions = (options: Options<CallWithParametersData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<CallWithParametersData>>, string | Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 302 302 { 303 303 queryFn: async ({ pageParam, queryKey }) => { 304 304 // @ts-ignore 305 - const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 305 + const page: Pick<QueryKey<Options<CallWithParametersData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 306 306 query: { 307 307 cursor: pageParam 308 308 } ··· 330 330 }; return mutationOptions; }; 331 331 332 332 export const callWithWeirdParameterNamesQueryKey = (options: Options<CallWithWeirdParameterNamesData>) => [ 333 - createQueryKey("callWithWeirdParameterNames", options) 333 + createQueryKey('callWithWeirdParameterNames', options) 334 334 ]; 335 335 336 336 export const callWithWeirdParameterNamesOptions = (options: Options<CallWithWeirdParameterNamesData>) => { return queryOptions({ ··· 357 357 }; return mutationOptions; }; 358 358 359 359 export const getCallWithOptionalParamQueryKey = (options: Options<GetCallWithOptionalParamData>) => [ 360 - createQueryKey("getCallWithOptionalParam", options) 360 + createQueryKey('getCallWithOptionalParam', options) 361 361 ]; 362 362 363 363 export const getCallWithOptionalParamOptions = (options: Options<GetCallWithOptionalParamData>) => { return queryOptions({ ··· 373 373 }); }; 374 374 375 375 export const getCallWithOptionalParamInfiniteQueryKey = (options: Options<GetCallWithOptionalParamData>): QueryKey<Options<GetCallWithOptionalParamData>> => [ 376 - createQueryKey("getCallWithOptionalParam", options, true) 376 + createQueryKey('getCallWithOptionalParam', options, true) 377 377 ]; 378 378 379 379 export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCallWithOptionalParamData>) => { return infiniteQueryOptions<void, DefaultError, InfiniteData<void>, QueryKey<Options<GetCallWithOptionalParamData>>, number | Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 381 381 { 382 382 queryFn: async ({ pageParam, queryKey }) => { 383 383 // @ts-ignore 384 - const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 384 + const page: Pick<QueryKey<Options<GetCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 385 385 query: { 386 386 page: pageParam 387 387 } ··· 398 398 }); }; 399 399 400 400 export const postCallWithOptionalParamQueryKey = (options: Options<PostCallWithOptionalParamData>) => [ 401 - createQueryKey("postCallWithOptionalParam", options) 401 + createQueryKey('postCallWithOptionalParam', options) 402 402 ]; 403 403 404 404 export const postCallWithOptionalParamOptions = (options: Options<PostCallWithOptionalParamData>) => { return queryOptions({ ··· 414 414 }); }; 415 415 416 416 export const postCallWithOptionalParamInfiniteQueryKey = (options: Options<PostCallWithOptionalParamData>): QueryKey<Options<PostCallWithOptionalParamData>> => [ 417 - createQueryKey("postCallWithOptionalParam", options, true) 417 + createQueryKey('postCallWithOptionalParam', options, true) 418 418 ]; 419 419 420 420 export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCallWithOptionalParamData>) => { return infiniteQueryOptions<PostCallWithOptionalParamResponse, PostCallWithOptionalParamError, InfiniteData<PostCallWithOptionalParamResponse>, QueryKey<Options<PostCallWithOptionalParamData>>, number | Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'>>( ··· 422 422 { 423 423 queryFn: async ({ pageParam, queryKey }) => { 424 424 // @ts-ignore 425 - const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === "object" ? pageParam : { 425 + const page: Pick<QueryKey<Options<PostCallWithOptionalParamData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : { 426 426 body: { 427 427 offset: pageParam 428 428 } ··· 450 450 }; return mutationOptions; }; 451 451 452 452 export const postApiVbyApiVersionRequestBodyQueryKey = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => [ 453 - createQueryKey("postApiVbyApiVersionRequestBody", options) 453 + createQueryKey('postApiVbyApiVersionRequestBody', options) 454 454 ]; 455 455 456 456 export const postApiVbyApiVersionRequestBodyOptions = (options?: Options<PostApiVbyApiVersionRequestBodyData>) => { return queryOptions({ ··· 477 477 }; return mutationOptions; }; 478 478 479 479 export const postApiVbyApiVersionFormDataQueryKey = (options?: Options<PostApiVbyApiVersionFormDataData>) => [ 480 - createQueryKey("postApiVbyApiVersionFormData", options) 480 + createQueryKey('postApiVbyApiVersionFormData', options) 481 481 ]; 482 482 483 483 export const postApiVbyApiVersionFormDataOptions = (options?: Options<PostApiVbyApiVersionFormDataData>) => { return queryOptions({ ··· 504 504 }; return mutationOptions; }; 505 505 506 506 export const callWithDefaultParametersQueryKey = (options?: Options<CallWithDefaultParametersData>) => [ 507 - createQueryKey("callWithDefaultParameters", options) 507 + createQueryKey('callWithDefaultParameters', options) 508 508 ]; 509 509 510 510 export const callWithDefaultParametersOptions = (options?: Options<CallWithDefaultParametersData>) => { return queryOptions({ ··· 520 520 }); }; 521 521 522 522 export const callWithDefaultOptionalParametersQueryKey = (options?: Options<CallWithDefaultOptionalParametersData>) => [ 523 - createQueryKey("callWithDefaultOptionalParameters", options) 523 + createQueryKey('callWithDefaultOptionalParameters', options) 524 524 ]; 525 525 526 526 export const callWithDefaultOptionalParametersOptions = (options?: Options<CallWithDefaultOptionalParametersData>) => { return queryOptions({ ··· 558 558 }; return mutationOptions; }; 559 559 560 560 export const duplicateNameQueryKey = (options?: Options) => [ 561 - createQueryKey("duplicateName", options) 561 + createQueryKey('duplicateName', options) 562 562 ]; 563 563 564 564 export const duplicateNameOptions = (options?: Options) => { return queryOptions({ ··· 574 574 }); }; 575 575 576 576 export const duplicateName1QueryKey = (options?: Options) => [ 577 - createQueryKey("duplicateName1", options) 577 + createQueryKey('duplicateName1', options) 578 578 ]; 579 579 580 580 export const duplicateName1Options = (options?: Options) => { return queryOptions({ ··· 623 623 }; return mutationOptions; }; 624 624 625 625 export const callWithNoContentResponseQueryKey = (options?: Options) => [ 626 - createQueryKey("callWithNoContentResponse", options) 626 + createQueryKey('callWithNoContentResponse', options) 627 627 ]; 628 628 629 629 export const callWithNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 639 639 }); }; 640 640 641 641 export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => [ 642 - createQueryKey("callWithResponseAndNoContentResponse", options) 642 + createQueryKey('callWithResponseAndNoContentResponse', options) 643 643 ]; 644 644 645 645 export const callWithResponseAndNoContentResponseOptions = (options?: Options) => { return queryOptions({ ··· 655 655 }); }; 656 656 657 657 export const dummyAQueryKey = (options?: Options) => [ 658 - createQueryKey("dummyA", options) 658 + createQueryKey('dummyA', options) 659 659 ]; 660 660 661 661 export const dummyAOptions = (options?: Options) => { return queryOptions({ ··· 671 671 }); }; 672 672 673 673 export const dummyBQueryKey = (options?: Options) => [ 674 - createQueryKey("dummyB", options) 674 + createQueryKey('dummyB', options) 675 675 ]; 676 676 677 677 export const dummyBOptions = (options?: Options) => { return queryOptions({ ··· 687 687 }); }; 688 688 689 689 export const callWithResponseQueryKey = (options?: Options) => [ 690 - createQueryKey("callWithResponse", options) 690 + createQueryKey('callWithResponse', options) 691 691 ]; 692 692 693 693 export const callWithResponseOptions = (options?: Options) => { return queryOptions({ ··· 703 703 }); }; 704 704 705 705 export const callWithDuplicateResponsesQueryKey = (options?: Options) => [ 706 - createQueryKey("callWithDuplicateResponses", options) 706 + createQueryKey('callWithDuplicateResponses', options) 707 707 ]; 708 708 709 709 export const callWithDuplicateResponsesOptions = (options?: Options) => { return queryOptions({ ··· 741 741 }; return mutationOptions; }; 742 742 743 743 export const collectionFormatQueryKey = (options: Options<CollectionFormatData>) => [ 744 - createQueryKey("collectionFormat", options) 744 + createQueryKey('collectionFormat', options) 745 745 ]; 746 746 747 747 export const collectionFormatOptions = (options: Options<CollectionFormatData>) => { return queryOptions({ ··· 757 757 }); }; 758 758 759 759 export const typesQueryKey = (options: Options<TypesData>) => [ 760 - createQueryKey("types", options) 760 + createQueryKey('types', options) 761 761 ]; 762 762 763 763 export const typesOptions = (options: Options<TypesData>) => { return queryOptions({ ··· 773 773 }); }; 774 774 775 775 export const uploadFileQueryKey = (options: Options<UploadFileData>) => [ 776 - createQueryKey("uploadFile", options) 776 + createQueryKey('uploadFile', options) 777 777 ]; 778 778 779 779 export const uploadFileOptions = (options: Options<UploadFileData>) => { return queryOptions({ ··· 800 800 }; return mutationOptions; }; 801 801 802 802 export const fileResponseQueryKey = (options: Options<FileResponseData>) => [ 803 - createQueryKey("fileResponse", options) 803 + createQueryKey('fileResponse', options) 804 804 ]; 805 805 806 806 export const fileResponseOptions = (options: Options<FileResponseData>) => { return queryOptions({ ··· 816 816 }); }; 817 817 818 818 export const complexTypesQueryKey = (options: Options<ComplexTypesData>) => [ 819 - createQueryKey("complexTypes", options) 819 + createQueryKey('complexTypes', options) 820 820 ]; 821 821 822 822 export const complexTypesOptions = (options: Options<ComplexTypesData>) => { return queryOptions({ ··· 832 832 }); }; 833 833 834 834 export const multipartRequestQueryKey = (options?: Options<MultipartRequestData>) => [ 835 - createQueryKey("multipartRequest", options) 835 + createQueryKey('multipartRequest', options) 836 836 ]; 837 837 838 838 export const multipartRequestOptions = (options?: Options<MultipartRequestData>) => { return queryOptions({ ··· 859 859 }; return mutationOptions; }; 860 860 861 861 export const multipartResponseQueryKey = (options?: Options) => [ 862 - createQueryKey("multipartResponse", options) 862 + createQueryKey('multipartResponse', options) 863 863 ]; 864 864 865 865 export const multipartResponseOptions = (options?: Options) => { return queryOptions({ ··· 886 886 }; return mutationOptions; }; 887 887 888 888 export const callWithResultFromHeaderQueryKey = (options?: Options) => [ 889 - createQueryKey("callWithResultFromHeader", options) 889 + createQueryKey('callWithResultFromHeader', options) 890 890 ]; 891 891 892 892 export const callWithResultFromHeaderOptions = (options?: Options) => { return queryOptions({ ··· 913 913 }; return mutationOptions; }; 914 914 915 915 export const testErrorCodeQueryKey = (options: Options<TestErrorCodeData>) => [ 916 - createQueryKey("testErrorCode", options) 916 + createQueryKey('testErrorCode', options) 917 917 ]; 918 918 919 919 export const testErrorCodeOptions = (options: Options<TestErrorCodeData>) => { return queryOptions({ ··· 940 940 }; return mutationOptions; }; 941 941 942 942 export const nonAsciiæøåÆøÅöôêÊ字符串QueryKey = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => [ 943 - createQueryKey("nonAsciiæøåÆøÅöôêÊ字符串", options) 943 + createQueryKey('nonAsciiæøåÆøÅöôêÊ字符串', options) 944 944 ]; 945 945 946 946 export const nonAsciiæøåÆøÅöôêÊ字符串Options = (options: Options<NonAsciiæøåÆøÅöôêÊ字符串Data>) => { return queryOptions({
+6 -5
packages/openapi-ts/test/performance.spec.ts
··· 4 4 import { Performance } from '../src/utils/performance'; 5 5 6 6 const V3_SPEC_PATH = './test/spec/v3.json'; 7 + const V3_1_SPEC_PATH = './test/spec/3.1.0/full.json'; 7 8 8 9 const OUTPUT_PREFIX = './test/generated/'; 9 10 ··· 40 41 expect(measures[0].duration).toBeLessThanOrEqual(500); 41 42 }); 42 43 43 - it('parses spec under 300ms (experimental)', async () => { 44 + it('parses spec under 500ms (experimental)', async () => { 44 45 Performance.clear(); 45 46 46 47 await createClient({ 47 48 client: '@hey-api/client-fetch', 48 49 experimental_parser: true, 49 - input: V3_SPEC_PATH, 50 + input: V3_1_SPEC_PATH, 50 51 output: toOutputPath('perf'), 51 52 }); 52 53 53 - Performance.measure('experimental_parser'); 54 - const measures = Performance.getEntriesByName('experimental_parser'); 54 + Performance.measure('parser'); 55 + const measures = Performance.getEntriesByName('parser'); 55 56 56 - expect(measures[0].duration).toBeLessThanOrEqual(300); 57 + expect(measures[0].duration).toBeLessThanOrEqual(500); 57 58 }); 58 59 });
+12 -8
packages/openapi-ts/test/sample.cjs
··· 11 11 // debug: true, 12 12 // experimental_parser: true, 13 13 // input: './test/spec/v3-transforms.json', 14 - input: './test/spec/v3.json', 15 - // input: './test/spec/3.1.0/required-all-of-ref.json', 14 + // input: './test/spec/v3.json', 15 + input: './test/spec/3.1.0/full.json', 16 16 // input: './test/spec/v2.json', 17 17 // input: 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/2caffd88277a4e27c95dcefc7e3b6a63a3b03297-v2-2023-11-15.json', 18 18 // name: 'foo', 19 19 output: { 20 + format: 'prettier', 21 + lint: 'eslint', 20 22 path: './test/generated/sample/', 21 23 }, 22 - plugins: [ 23 - // '@tanstack/react-query', 24 - // '@hey-api/services', 25 - 'zod', 26 - ], 24 + // plugins: [ 25 + // '@tanstack/react-query', 26 + // // '@hey-api/services', 27 + // // 'zod', 28 + // ], 27 29 schemas: { 28 30 export: false, 29 31 }, ··· 36 38 }, 37 39 types: { 38 40 // dates: 'types+transform', 39 - // enums: 'javascript', 41 + // enums: 'typescript', 42 + // enums: 'typescript+namespace', 43 + enums: 'javascript', 40 44 // export: false, 41 45 // include: 42 46 // '^(_400|CompositionWithOneOfAndProperties)',
+3622
packages/openapi-ts/test/spec/3.1.0/full.json
··· 1 + { 2 + "openapi": "3.1.0", 3 + "info": { 4 + "title": "swagger", 5 + "version": "v1.0" 6 + }, 7 + "servers": [ 8 + { 9 + "url": "http://localhost:3000/base" 10 + } 11 + ], 12 + "paths": { 13 + "/api/v{api-version}/no-tag": { 14 + "tags": [], 15 + "get": { 16 + "operationId": "export" 17 + }, 18 + "post": { 19 + "operationId": "import", 20 + "requestBody": { 21 + "required": true, 22 + "content": { 23 + "application/json": { 24 + "schema": { 25 + "type": "object", 26 + "oneOf": [ 27 + { 28 + "$ref": "#/components/schemas/ModelWithReadOnlyAndWriteOnly" 29 + }, 30 + { 31 + "$ref": "#/components/schemas/ModelWithArrayReadOnlyAndWriteOnly" 32 + } 33 + ] 34 + } 35 + } 36 + } 37 + }, 38 + "responses": { 39 + "default": { 40 + "description": "Default success response", 41 + "content": { 42 + "application/json": { 43 + "schema": { 44 + "$ref": "#/components/schemas/ModelWithReadOnlyAndWriteOnly" 45 + } 46 + } 47 + } 48 + }, 49 + "200": { 50 + "description": "Success", 51 + "content": { 52 + "application/json; type=collection": { 53 + "schema": { 54 + "$ref": "#/components/schemas/Model-From.Zendesk" 55 + } 56 + } 57 + } 58 + } 59 + } 60 + } 61 + }, 62 + "/api/v{api-version}/simple/$count": { 63 + "get": { 64 + "tags": ["Simple"], 65 + "operationId": "api/v{version}/ODataController/$count", 66 + "responses": { 67 + "200": { 68 + "description": "Success", 69 + "content": { 70 + "application/json; type=collection": { 71 + "schema": { 72 + "$ref": "#/components/schemas/Model-From.Zendesk" 73 + } 74 + } 75 + } 76 + } 77 + } 78 + } 79 + }, 80 + "/api/v{api-version}/simple:operation": { 81 + "get": { 82 + "parameters": [ 83 + { 84 + "description": "foo in method", 85 + "in": "path", 86 + "name": "foo_param", 87 + "required": true, 88 + "schema": { 89 + "oneOf": [ 90 + { 91 + "type": "string" 92 + }, 93 + { 94 + "format": "uuid", 95 + "type": "string" 96 + } 97 + ] 98 + } 99 + } 100 + ], 101 + "responses": { 102 + "default": { 103 + "description": "Default error response", 104 + "content": { 105 + "application/json": { 106 + "schema": { 107 + "$ref": "#/components/schemas/ModelWithBoolean" 108 + } 109 + } 110 + } 111 + }, 112 + "200": { 113 + "description": "Response is a simple number", 114 + "content": { 115 + "application/json": { 116 + "schema": { 117 + "type": "number" 118 + } 119 + } 120 + } 121 + } 122 + } 123 + } 124 + }, 125 + "/api/v{api-version}/simple": { 126 + "get": { 127 + "tags": ["Simple"], 128 + "operationId": "GetCallWithoutParametersAndResponse" 129 + }, 130 + "put": { 131 + "tags": ["Simple"], 132 + "operationId": "PutCallWithoutParametersAndResponse" 133 + }, 134 + "post": { 135 + "tags": ["Simple"], 136 + "operationId": "PostCallWithoutParametersAndResponse" 137 + }, 138 + "delete": { 139 + "tags": ["Simple"], 140 + "operationId": "DeleteCallWithoutParametersAndResponse" 141 + }, 142 + "options": { 143 + "tags": ["Simple"], 144 + "operationId": "OptionsCallWithoutParametersAndResponse" 145 + }, 146 + "head": { 147 + "tags": ["Simple"], 148 + "operationId": "HeadCallWithoutParametersAndResponse" 149 + }, 150 + "patch": { 151 + "tags": ["Simple"], 152 + "operationId": "PatchCallWithoutParametersAndResponse" 153 + } 154 + }, 155 + "/api/v{api-version}/foo/{foo_param}/bar/{BarParam}": { 156 + "delete": { 157 + "tags": ["Parameters"], 158 + "operationId": "deleteFoo", 159 + "parameters": [ 160 + { 161 + "description": "foo in method", 162 + "in": "path", 163 + "name": "foo_param", 164 + "required": true, 165 + "schema": { 166 + "type": "string" 167 + } 168 + }, 169 + { 170 + "description": "bar in method", 171 + "in": "path", 172 + "name": "BarParam", 173 + "required": true, 174 + "schema": { 175 + "type": "string" 176 + } 177 + }, 178 + { 179 + "description": "Parameter with illegal characters", 180 + "name": "x-Foo-Bar", 181 + "in": "header", 182 + "required": true, 183 + "content": { 184 + "application/json": { 185 + "schema": { 186 + "$ref": "#/components/schemas/ModelWithString" 187 + } 188 + } 189 + } 190 + } 191 + ] 192 + }, 193 + "parameters": [ 194 + { 195 + "description": "foo in global parameters", 196 + "in": "path", 197 + "name": "foo_param", 198 + "required": true, 199 + "schema": { 200 + "type": "string" 201 + } 202 + }, 203 + { 204 + "description": "bar in global parameters", 205 + "in": "path", 206 + "name": "BarParam", 207 + "required": true, 208 + "schema": { 209 + "type": "string" 210 + } 211 + } 212 + ] 213 + }, 214 + "/api/v{api-version}/descriptions/": { 215 + "post": { 216 + "tags": ["Descriptions"], 217 + "operationId": "CallWithDescriptions", 218 + "parameters": [ 219 + { 220 + "description": "Testing multiline comments in string: First line\nSecond line\n\nFourth line", 221 + "name": "parameterWithBreaks", 222 + "in": "query", 223 + "schema": { 224 + "type": "string" 225 + } 226 + }, 227 + { 228 + "description": "Testing backticks in string: `backticks` and ```multiple backticks``` should work", 229 + "name": "parameterWithBackticks", 230 + "in": "query", 231 + "schema": { 232 + "type": "string" 233 + } 234 + }, 235 + { 236 + "description": "Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work", 237 + "name": "parameterWithSlashes", 238 + "in": "query", 239 + "schema": { 240 + "type": "string" 241 + } 242 + }, 243 + { 244 + "description": "Testing expression placeholders in string: ${expression} should work", 245 + "name": "parameterWithExpressionPlaceholders", 246 + "in": "query", 247 + "schema": { 248 + "type": "string" 249 + } 250 + }, 251 + { 252 + "description": "Testing quotes in string: 'single quote''' and \"double quotes\"\"\" should work", 253 + "name": "parameterWithQuotes", 254 + "in": "query", 255 + "schema": { 256 + "type": "string" 257 + } 258 + }, 259 + { 260 + "description": "Testing reserved characters in string: /* inline */ and /** inline **/ should work", 261 + "name": "parameterWithReservedCharacters", 262 + "in": "query", 263 + "schema": { 264 + "type": "string" 265 + } 266 + } 267 + ] 268 + } 269 + }, 270 + "/api/v{api-version}/parameters/deprecated": { 271 + "post": { 272 + "tags": ["Deprecated"], 273 + "deprecated": true, 274 + "operationId": "DeprecatedCall", 275 + "parameters": [ 276 + { 277 + "deprecated": true, 278 + "description": "This parameter is deprecated", 279 + "name": "parameter", 280 + "in": "header", 281 + "required": true, 282 + "schema": { 283 + "oneOf": [ 284 + { 285 + "$ref": "#/components/schemas/DeprecatedModel" 286 + }, 287 + { 288 + "type": "null" 289 + } 290 + ] 291 + } 292 + } 293 + ] 294 + } 295 + }, 296 + "/api/v{api-version}/parameters/{parameterPath}": { 297 + "post": { 298 + "tags": ["Parameters"], 299 + "operationId": "CallWithParameters", 300 + "parameters": [ 301 + { 302 + "description": "This is the parameter that goes into the header", 303 + "name": "parameterHeader", 304 + "in": "header", 305 + "required": true, 306 + "schema": { 307 + "type": ["string", "null"] 308 + } 309 + }, 310 + { 311 + "required": false, 312 + "schema": { 313 + "$ref": "#/components/schemas/ModelWithNestedArrayEnumsDataFoo" 314 + }, 315 + "name": "foo_ref_enum", 316 + "in": "query" 317 + }, 318 + { 319 + "required": true, 320 + "schema": { 321 + "allOf": [ 322 + { 323 + "$ref": "#/components/schemas/ModelWithNestedArrayEnumsDataFoo" 324 + } 325 + ] 326 + }, 327 + "name": "foo_all_of_enum", 328 + "in": "query" 329 + }, 330 + { 331 + "description": "This is the parameter that goes into the query params", 332 + "name": "cursor", 333 + "in": "query", 334 + "required": true, 335 + "schema": { 336 + "type": ["string", "null"] 337 + } 338 + }, 339 + { 340 + "description": "This is the parameter that goes into the cookie", 341 + "name": "parameterCookie", 342 + "in": "cookie", 343 + "required": true, 344 + "schema": { 345 + "type": ["string", "null"] 346 + } 347 + }, 348 + { 349 + "description": "This is the parameter that goes into the path", 350 + "name": "parameterPath", 351 + "in": "path", 352 + "required": true, 353 + "schema": { 354 + "type": ["string", "null"] 355 + } 356 + }, 357 + { 358 + "description": "api-version should be required in standalone clients", 359 + "name": "api-version", 360 + "in": "path", 361 + "required": true, 362 + "schema": { 363 + "type": ["string", "null"] 364 + } 365 + } 366 + ], 367 + "requestBody": { 368 + "description": "This is the parameter that goes into the body", 369 + "required": true, 370 + "content": { 371 + "application/json": { 372 + "schema": { 373 + "properties": {}, 374 + "type": ["object", "null"] 375 + } 376 + } 377 + } 378 + } 379 + } 380 + }, 381 + "/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}": { 382 + "post": { 383 + "tags": ["Parameters"], 384 + "operationId": "CallWithWeirdParameterNames", 385 + "parameters": [ 386 + { 387 + "description": "This is the parameter that goes into the path", 388 + "name": "parameter.path.1", 389 + "in": "path", 390 + "required": false, 391 + "schema": { 392 + "type": "string" 393 + } 394 + }, 395 + { 396 + "description": "This is the parameter that goes into the path", 397 + "name": "parameter-path-2", 398 + "in": "path", 399 + "required": false, 400 + "schema": { 401 + "type": "string" 402 + } 403 + }, 404 + { 405 + "description": "This is the parameter that goes into the path", 406 + "name": "PARAMETER-PATH-3", 407 + "in": "path", 408 + "required": false, 409 + "schema": { 410 + "type": "string" 411 + } 412 + }, 413 + { 414 + "description": "This is the parameter with a reserved keyword", 415 + "name": "default", 416 + "in": "query", 417 + "required": false, 418 + "schema": { 419 + "type": "string" 420 + } 421 + }, 422 + { 423 + "description": "This is the parameter that goes into the request header", 424 + "name": "parameter.header", 425 + "in": "header", 426 + "required": true, 427 + "schema": { 428 + "type": ["string", "null"] 429 + } 430 + }, 431 + { 432 + "description": "This is the parameter that goes into the request query params", 433 + "name": "parameter-query", 434 + "in": "query", 435 + "required": true, 436 + "schema": { 437 + "type": ["string", "null"] 438 + } 439 + }, 440 + { 441 + "description": "This is the parameter that goes into the cookie", 442 + "name": "PARAMETER-COOKIE", 443 + "in": "cookie", 444 + "required": true, 445 + "schema": { 446 + "type": ["string", "null"] 447 + } 448 + }, 449 + { 450 + "description": "api-version should be required in standalone clients", 451 + "name": "api-version", 452 + "in": "path", 453 + "required": true, 454 + "schema": { 455 + "type": ["string", "null"] 456 + } 457 + } 458 + ], 459 + "requestBody": { 460 + "description": "This is the parameter that goes into the body", 461 + "required": true, 462 + "content": { 463 + "application/json": { 464 + "schema": { 465 + "oneOf": [ 466 + { 467 + "$ref": "#/components/schemas/ModelWithString" 468 + }, 469 + { 470 + "type": "null" 471 + } 472 + ] 473 + } 474 + } 475 + } 476 + } 477 + } 478 + }, 479 + "/api/v{api-version}/parameters/": { 480 + "get": { 481 + "tags": ["Parameters"], 482 + "operationId": "GetCallWithOptionalParam", 483 + "parameters": [ 484 + { 485 + "description": "This is an optional parameter", 486 + "name": "page", 487 + "in": "query", 488 + "required": false, 489 + "schema": { 490 + "type": "number" 491 + } 492 + } 493 + ], 494 + "requestBody": { 495 + "description": "This is a required parameter", 496 + "required": true, 497 + "content": { 498 + "application/json": { 499 + "schema": { 500 + "$ref": "#/components/schemas/ModelWithOneOfEnum" 501 + } 502 + } 503 + } 504 + } 505 + }, 506 + "post": { 507 + "tags": ["Parameters"], 508 + "operationId": "PostCallWithOptionalParam", 509 + "parameters": [ 510 + { 511 + "description": "This is a required parameter", 512 + "name": "parameter", 513 + "in": "query", 514 + "required": true, 515 + "schema": { 516 + "$ref": "#/components/schemas/Pageable" 517 + } 518 + } 519 + ], 520 + "requestBody": { 521 + "description": "This is an optional parameter", 522 + "required": false, 523 + "content": { 524 + "application/json": { 525 + "schema": { 526 + "properties": { 527 + "offset": { 528 + "required": true, 529 + "type": ["number", "null"] 530 + } 531 + }, 532 + "type": "object" 533 + } 534 + } 535 + } 536 + }, 537 + "responses": { 538 + "200": { 539 + "description": "Response is a simple number", 540 + "content": { 541 + "application/json": { 542 + "schema": { 543 + "type": "number" 544 + } 545 + } 546 + } 547 + }, 548 + "204": { 549 + "description": "Success" 550 + } 551 + } 552 + } 553 + }, 554 + "/api/v{api-version}/requestBody/": { 555 + "post": { 556 + "tags": ["RequestBody"], 557 + "parameters": [ 558 + { 559 + "$ref": "#/components/parameters/SimpleParameter" 560 + } 561 + ], 562 + "requestBody": { 563 + "$ref": "#/components/requestBodies/SimpleRequestBody" 564 + } 565 + } 566 + }, 567 + "/api/v{api-version}/formData/": { 568 + "post": { 569 + "tags": ["FormData"], 570 + "parameters": [ 571 + { 572 + "$ref": "#/components/parameters/SimpleParameter" 573 + } 574 + ], 575 + "requestBody": { 576 + "$ref": "#/components/requestBodies/SimpleFormData" 577 + } 578 + } 579 + }, 580 + "/api/v{api-version}/defaults": { 581 + "get": { 582 + "tags": ["Defaults"], 583 + "operationId": "CallWithDefaultParameters", 584 + "parameters": [ 585 + { 586 + "description": "This is a simple string with default value", 587 + "name": "parameterString", 588 + "in": "query", 589 + "schema": { 590 + "default": "Hello World!", 591 + "type": ["string", "null"] 592 + } 593 + }, 594 + { 595 + "description": "This is a simple number with default value", 596 + "name": "parameterNumber", 597 + "in": "query", 598 + "schema": { 599 + "default": 123, 600 + "type": ["number", "null"] 601 + } 602 + }, 603 + { 604 + "description": "This is a simple boolean with default value", 605 + "name": "parameterBoolean", 606 + "in": "query", 607 + "schema": { 608 + "default": true, 609 + "type": ["boolean", "null"] 610 + } 611 + }, 612 + { 613 + "description": "This is a simple enum with default value", 614 + "name": "parameterEnum", 615 + "in": "query", 616 + "schema": { 617 + "enum": ["Success", "Warning", "Error"], 618 + "default": 0 619 + } 620 + }, 621 + { 622 + "description": "This is a simple model with default value", 623 + "name": "parameterModel", 624 + "in": "query", 625 + "schema": { 626 + "oneOf": [ 627 + { 628 + "$ref": "#/components/schemas/ModelWithString", 629 + "default": { 630 + "prop": "Hello World!" 631 + } 632 + }, 633 + { 634 + "type": "null" 635 + } 636 + ] 637 + } 638 + } 639 + ] 640 + }, 641 + "post": { 642 + "tags": ["Defaults"], 643 + "operationId": "CallWithDefaultOptionalParameters", 644 + "parameters": [ 645 + { 646 + "description": "This is a simple string that is optional with default value", 647 + "name": "parameterString", 648 + "in": "query", 649 + "required": false, 650 + "schema": { 651 + "type": "string", 652 + "default": "Hello World!" 653 + } 654 + }, 655 + { 656 + "description": "This is a simple number that is optional with default value", 657 + "name": "parameterNumber", 658 + "in": "query", 659 + "required": false, 660 + "schema": { 661 + "type": "number", 662 + "default": 123 663 + } 664 + }, 665 + { 666 + "description": "This is a simple boolean that is optional with default value", 667 + "name": "parameterBoolean", 668 + "in": "query", 669 + "required": false, 670 + "schema": { 671 + "type": "boolean", 672 + "default": true 673 + } 674 + }, 675 + { 676 + "description": "This is a simple enum that is optional with default value", 677 + "name": "parameterEnum", 678 + "in": "query", 679 + "required": false, 680 + "schema": { 681 + "enum": ["Success", "Warning", "Error"], 682 + "default": 0 683 + } 684 + }, 685 + { 686 + "description": "This is a simple model that is optional with default value", 687 + "name": "parameterModel", 688 + "in": "query", 689 + "required": false, 690 + "schema": { 691 + "$ref": "#/components/schemas/ModelWithString", 692 + "default": { 693 + "prop": "Hello World!" 694 + } 695 + } 696 + } 697 + ] 698 + }, 699 + "put": { 700 + "tags": ["Defaults"], 701 + "operationId": "CallToTestOrderOfParams", 702 + "parameters": [ 703 + { 704 + "description": "This is a optional string with default", 705 + "name": "parameterOptionalStringWithDefault", 706 + "in": "query", 707 + "required": false, 708 + "schema": { 709 + "type": "string", 710 + "default": "Hello World!" 711 + } 712 + }, 713 + { 714 + "description": "This is a optional string with empty default", 715 + "name": "parameterOptionalStringWithEmptyDefault", 716 + "in": "query", 717 + "required": false, 718 + "schema": { 719 + "type": "string", 720 + "default": "" 721 + } 722 + }, 723 + { 724 + "description": "This is a optional string with no default", 725 + "name": "parameterOptionalStringWithNoDefault", 726 + "in": "query", 727 + "required": false, 728 + "schema": { 729 + "type": "string" 730 + } 731 + }, 732 + { 733 + "description": "This is a string with default", 734 + "name": "parameterStringWithDefault", 735 + "in": "query", 736 + "required": true, 737 + "schema": { 738 + "type": "string", 739 + "default": "Hello World!" 740 + } 741 + }, 742 + { 743 + "description": "This is a string with empty default", 744 + "name": "parameterStringWithEmptyDefault", 745 + "in": "query", 746 + "required": true, 747 + "schema": { 748 + "type": "string", 749 + "default": "" 750 + } 751 + }, 752 + { 753 + "description": "This is a string with no default", 754 + "name": "parameterStringWithNoDefault", 755 + "in": "query", 756 + "required": true, 757 + "schema": { 758 + "type": "string" 759 + } 760 + }, 761 + { 762 + "description": "This is a string that can be null with no default", 763 + "name": "parameterStringNullableWithNoDefault", 764 + "in": "query", 765 + "required": false, 766 + "schema": { 767 + "type": ["string", "null"] 768 + } 769 + }, 770 + { 771 + "description": "This is a string that can be null with default", 772 + "name": "parameterStringNullableWithDefault", 773 + "in": "query", 774 + "required": false, 775 + "schema": { 776 + "default": null, 777 + "type": ["string", "null"] 778 + } 779 + } 780 + ] 781 + } 782 + }, 783 + "/api/v{api-version}/duplicate": { 784 + "get": { 785 + "tags": ["Duplicate"], 786 + "operationId": "DuplicateName" 787 + }, 788 + "post": { 789 + "tags": ["Duplicate"], 790 + "operationId": "DuplicateName" 791 + }, 792 + "put": { 793 + "tags": ["Duplicate"], 794 + "operationId": "DuplicateName" 795 + }, 796 + "delete": { 797 + "tags": ["Duplicate"], 798 + "operationId": "DuplicateName" 799 + } 800 + }, 801 + "/api/v{api-version}/no-content": { 802 + "get": { 803 + "tags": ["NoContent"], 804 + "operationId": "CallWithNoContentResponse", 805 + "responses": { 806 + "204": { 807 + "description": "Success" 808 + } 809 + } 810 + } 811 + }, 812 + "/api/v{api-version}/multiple-tags/response-and-no-content": { 813 + "get": { 814 + "tags": ["Response", "NoContent"], 815 + "operationId": "CallWithResponseAndNoContentResponse", 816 + "responses": { 817 + "200": { 818 + "description": "Response is a simple number", 819 + "content": { 820 + "application/json": { 821 + "schema": { 822 + "type": "number" 823 + } 824 + } 825 + } 826 + }, 827 + "204": { 828 + "description": "Success" 829 + } 830 + } 831 + } 832 + }, 833 + "/api/v{api-version}/multiple-tags/a": { 834 + "get": { 835 + "tags": ["MultipleTags1", "MultipleTags2"], 836 + "operationId": "DummyA", 837 + "responses": { 838 + "200": { 839 + "content": { 840 + "application/json": { 841 + "schema": { 842 + "$ref": "#/components/schemas/400" 843 + } 844 + } 845 + } 846 + } 847 + } 848 + } 849 + }, 850 + "/api/v{api-version}/multiple-tags/b": { 851 + "get": { 852 + "tags": ["MultipleTags1", "MultipleTags2", "MultipleTags3"], 853 + "operationId": "DummyB", 854 + "responses": { 855 + "204": { 856 + "description": "Success" 857 + } 858 + } 859 + } 860 + }, 861 + "/api/v{api-version}/response": { 862 + "get": { 863 + "tags": ["Response"], 864 + "operationId": "CallWithResponse", 865 + "responses": { 866 + "default": { 867 + "content": { 868 + "application/json": { 869 + "schema": { 870 + "$ref": "#/components/schemas/import" 871 + } 872 + } 873 + } 874 + } 875 + } 876 + }, 877 + "post": { 878 + "tags": ["Response"], 879 + "operationId": "CallWithDuplicateResponses", 880 + "responses": { 881 + "default": { 882 + "description": "Default error response", 883 + "content": { 884 + "application/json": { 885 + "schema": { 886 + "$ref": "#/components/schemas/ModelWithBoolean" 887 + } 888 + } 889 + } 890 + }, 891 + "200": { 892 + "description": "Message for 200 response", 893 + "content": { 894 + "application/json": { 895 + "schema": { 896 + "allOf": [ 897 + { 898 + "$ref": "#/components/schemas/ModelWithBoolean" 899 + }, 900 + { 901 + "$ref": "#/components/schemas/ModelWithInteger" 902 + } 903 + ] 904 + } 905 + } 906 + } 907 + }, 908 + "201": { 909 + "description": "Message for 201 response", 910 + "content": { 911 + "application/json": { 912 + "schema": { 913 + "$ref": "#/components/schemas/ModelWithString" 914 + } 915 + } 916 + } 917 + }, 918 + "202": { 919 + "description": "Message for 202 response", 920 + "content": { 921 + "application/json": { 922 + "schema": { 923 + "$ref": "#/components/schemas/ModelWithString" 924 + } 925 + } 926 + } 927 + }, 928 + "4XX": { 929 + "description": "Message for 4XX errors", 930 + "content": { 931 + "application/json": { 932 + "schema": { 933 + "$ref": "#/components/schemas/DictionaryWithArray" 934 + } 935 + } 936 + } 937 + }, 938 + "500": { 939 + "description": "Message for 500 error", 940 + "content": { 941 + "application/json": { 942 + "schema": { 943 + "$ref": "#/components/schemas/ModelWithStringError" 944 + } 945 + } 946 + } 947 + }, 948 + "501": { 949 + "description": "Message for 501 error", 950 + "content": { 951 + "application/json": { 952 + "schema": { 953 + "$ref": "#/components/schemas/ModelWithStringError" 954 + } 955 + } 956 + } 957 + }, 958 + "502": { 959 + "description": "Message for 502 error", 960 + "content": { 961 + "application/json": { 962 + "schema": { 963 + "$ref": "#/components/schemas/ModelWithStringError" 964 + } 965 + } 966 + } 967 + } 968 + } 969 + }, 970 + "put": { 971 + "tags": ["Response"], 972 + "operationId": "CallWithResponses", 973 + "responses": { 974 + "default": { 975 + "description": "Message for default response", 976 + "content": { 977 + "application/json": { 978 + "schema": { 979 + "$ref": "#/components/schemas/ModelWithStringError" 980 + } 981 + } 982 + } 983 + }, 984 + "200": { 985 + "description": "Message for 200 response", 986 + "content": { 987 + "application/json": { 988 + "schema": { 989 + "type": "object", 990 + "properties": { 991 + "@namespace.string": { 992 + "type": "string", 993 + "readOnly": true 994 + }, 995 + "@namespace.integer": { 996 + "type": "integer", 997 + "readOnly": true 998 + }, 999 + "value": { 1000 + "type": "array", 1001 + "items": { 1002 + "$ref": "#/components/schemas/ModelWithString" 1003 + }, 1004 + "readOnly": true 1005 + } 1006 + } 1007 + } 1008 + } 1009 + } 1010 + }, 1011 + "201": { 1012 + "description": "Message for 201 response", 1013 + "content": { 1014 + "application/json": { 1015 + "schema": { 1016 + "$ref": "#/components/schemas/ModelThatExtends" 1017 + } 1018 + } 1019 + } 1020 + }, 1021 + "202": { 1022 + "description": "Message for 202 response", 1023 + "content": { 1024 + "application/json": { 1025 + "schema": { 1026 + "$ref": "#/components/schemas/ModelThatExtendsExtends" 1027 + } 1028 + } 1029 + } 1030 + }, 1031 + "500": { 1032 + "description": "Message for 500 error", 1033 + "content": { 1034 + "application/json": { 1035 + "schema": { 1036 + "$ref": "#/components/schemas/ModelWithStringError" 1037 + } 1038 + } 1039 + } 1040 + }, 1041 + "501": { 1042 + "description": "Message for 501 error", 1043 + "content": { 1044 + "application/json": { 1045 + "schema": { 1046 + "$ref": "#/components/schemas/ModelWithStringError" 1047 + } 1048 + } 1049 + } 1050 + }, 1051 + "502": { 1052 + "description": "Message for 502 error", 1053 + "content": { 1054 + "application/json": { 1055 + "schema": { 1056 + "$ref": "#/components/schemas/ModelWithStringError" 1057 + } 1058 + } 1059 + } 1060 + } 1061 + } 1062 + } 1063 + }, 1064 + "/api/v{api-version}/collectionFormat": { 1065 + "get": { 1066 + "tags": ["CollectionFormat"], 1067 + "operationId": "CollectionFormat", 1068 + "parameters": [ 1069 + { 1070 + "description": "This is an array parameter that is sent as csv format (comma-separated values)", 1071 + "name": "parameterArrayCSV", 1072 + "in": "query", 1073 + "required": true, 1074 + "schema": { 1075 + "type": ["array", "null"], 1076 + "items": { 1077 + "type": "string" 1078 + } 1079 + }, 1080 + "collectionFormat": "csv" 1081 + }, 1082 + { 1083 + "description": "This is an array parameter that is sent as ssv format (space-separated values)", 1084 + "name": "parameterArraySSV", 1085 + "in": "query", 1086 + "required": true, 1087 + "schema": { 1088 + "type": ["array", "null"], 1089 + "items": { 1090 + "type": "string" 1091 + } 1092 + }, 1093 + "collectionFormat": "ssv" 1094 + }, 1095 + { 1096 + "description": "This is an array parameter that is sent as tsv format (tab-separated values)", 1097 + "name": "parameterArrayTSV", 1098 + "in": "query", 1099 + "required": true, 1100 + "schema": { 1101 + "type": ["array", "null"], 1102 + "items": { 1103 + "type": "string" 1104 + } 1105 + }, 1106 + "collectionFormat": "tsv" 1107 + }, 1108 + { 1109 + "description": "This is an array parameter that is sent as pipes format (pipe-separated values)", 1110 + "name": "parameterArrayPipes", 1111 + "in": "query", 1112 + "required": true, 1113 + "schema": { 1114 + "type": ["array", "null"], 1115 + "items": { 1116 + "type": "string" 1117 + } 1118 + }, 1119 + "collectionFormat": "pipes" 1120 + }, 1121 + { 1122 + "description": "This is an array parameter that is sent as multi format (multiple parameter instances)", 1123 + "name": "parameterArrayMulti", 1124 + "in": "query", 1125 + "required": true, 1126 + "schema": { 1127 + "type": ["array", "null"], 1128 + "items": { 1129 + "type": "string" 1130 + } 1131 + }, 1132 + "collectionFormat": "multi" 1133 + } 1134 + ] 1135 + } 1136 + }, 1137 + "/api/v{api-version}/types": { 1138 + "get": { 1139 + "tags": ["Types"], 1140 + "operationId": "Types", 1141 + "parameters": [ 1142 + { 1143 + "description": "This is a number parameter", 1144 + "name": "parameterNumber", 1145 + "in": "query", 1146 + "required": true, 1147 + "schema": { 1148 + "type": "number", 1149 + "default": 123 1150 + } 1151 + }, 1152 + { 1153 + "description": "This is a string parameter", 1154 + "name": "parameterString", 1155 + "in": "query", 1156 + "required": true, 1157 + "schema": { 1158 + "type": ["string", "null"], 1159 + "default": "default" 1160 + } 1161 + }, 1162 + { 1163 + "description": "This is a boolean parameter", 1164 + "name": "parameterBoolean", 1165 + "in": "query", 1166 + "required": true, 1167 + "schema": { 1168 + "type": ["boolean", "null"], 1169 + "default": true 1170 + } 1171 + }, 1172 + { 1173 + "description": "This is an object parameter", 1174 + "name": "parameterObject", 1175 + "in": "query", 1176 + "required": true, 1177 + "schema": { 1178 + "type": ["object", "null"], 1179 + "default": null 1180 + } 1181 + }, 1182 + { 1183 + "description": "This is an array parameter", 1184 + "name": "parameterArray", 1185 + "in": "query", 1186 + "required": true, 1187 + "schema": { 1188 + "type": ["array", "null"], 1189 + "items": { 1190 + "type": "string" 1191 + } 1192 + } 1193 + }, 1194 + { 1195 + "description": "This is a dictionary parameter", 1196 + "name": "parameterDictionary", 1197 + "in": "query", 1198 + "required": true, 1199 + "schema": { 1200 + "type": ["object", "null"], 1201 + "items": { 1202 + "type": "string" 1203 + } 1204 + } 1205 + }, 1206 + { 1207 + "description": "This is an enum parameter", 1208 + "name": "parameterEnum", 1209 + "in": "query", 1210 + "required": true, 1211 + "schema": { 1212 + "oneOf": [ 1213 + { 1214 + "enum": ["Success", "Warning", "Error"] 1215 + }, 1216 + { 1217 + "type": "null" 1218 + } 1219 + ] 1220 + } 1221 + }, 1222 + { 1223 + "description": "This is a number parameter", 1224 + "name": "id", 1225 + "in": "path", 1226 + "schema": { 1227 + "type": "integer", 1228 + "format": "int32" 1229 + } 1230 + } 1231 + ], 1232 + "responses": { 1233 + "200": { 1234 + "description": "Response is a simple number", 1235 + "content": { 1236 + "application/json": { 1237 + "schema": { 1238 + "type": "number" 1239 + } 1240 + } 1241 + } 1242 + }, 1243 + "201": { 1244 + "description": "Response is a simple string", 1245 + "content": { 1246 + "application/json": { 1247 + "schema": { 1248 + "type": "string" 1249 + } 1250 + } 1251 + } 1252 + }, 1253 + "202": { 1254 + "description": "Response is a simple boolean", 1255 + "content": { 1256 + "application/json": { 1257 + "schema": { 1258 + "type": "boolean" 1259 + } 1260 + } 1261 + } 1262 + }, 1263 + "203": { 1264 + "description": "Response is a simple object", 1265 + "content": { 1266 + "application/json": { 1267 + "schema": { 1268 + "type": "object" 1269 + } 1270 + } 1271 + } 1272 + } 1273 + } 1274 + } 1275 + }, 1276 + "/api/v{api-version}/upload": { 1277 + "post": { 1278 + "tags": ["Upload"], 1279 + "operationId": "UploadFile", 1280 + "parameters": [ 1281 + { 1282 + "description": "api-version should be required in standalone clients", 1283 + "name": "api-version", 1284 + "in": "path", 1285 + "required": true, 1286 + "schema": { 1287 + "type": ["string", "null"] 1288 + } 1289 + } 1290 + ], 1291 + "requestBody": { 1292 + "content": { 1293 + "application/x-www-form-urlencoded": { 1294 + "description": "Supply a file reference for upload", 1295 + "schema": { 1296 + "format": "binary", 1297 + "type": "string" 1298 + } 1299 + } 1300 + }, 1301 + "required": true 1302 + }, 1303 + "responses": { 1304 + "200": { 1305 + "content": { 1306 + "application/json": { 1307 + "schema": { 1308 + "type": "boolean" 1309 + } 1310 + } 1311 + } 1312 + } 1313 + } 1314 + } 1315 + }, 1316 + "/api/v{api-version}/file/{id}": { 1317 + "get": { 1318 + "tags": ["FileResponse"], 1319 + "operationId": "FileResponse", 1320 + "parameters": [ 1321 + { 1322 + "name": "id", 1323 + "in": "path", 1324 + "required": true, 1325 + "schema": { 1326 + "type": "string" 1327 + } 1328 + }, 1329 + { 1330 + "description": "api-version should be required in standalone clients", 1331 + "name": "api-version", 1332 + "in": "path", 1333 + "required": true, 1334 + "schema": { 1335 + "type": "string" 1336 + } 1337 + } 1338 + ], 1339 + "responses": { 1340 + "200": { 1341 + "description": "Success", 1342 + "content": { 1343 + "audio/*": { 1344 + "schema": { 1345 + "format": "binary", 1346 + "type": "string" 1347 + } 1348 + }, 1349 + "video/*": { 1350 + "schema": { 1351 + "format": "binary", 1352 + "type": "string" 1353 + } 1354 + } 1355 + } 1356 + } 1357 + } 1358 + } 1359 + }, 1360 + "/api/v{api-version}/complex": { 1361 + "get": { 1362 + "tags": ["Complex"], 1363 + "operationId": "ComplexTypes", 1364 + "parameters": [ 1365 + { 1366 + "description": "Parameter containing object", 1367 + "name": "parameterObject", 1368 + "in": "query", 1369 + "required": true, 1370 + "schema": { 1371 + "type": "object", 1372 + "properties": { 1373 + "first": { 1374 + "type": "object", 1375 + "properties": { 1376 + "second": { 1377 + "type": "object", 1378 + "properties": { 1379 + "third": { 1380 + "type": "string" 1381 + } 1382 + } 1383 + } 1384 + } 1385 + } 1386 + } 1387 + } 1388 + }, 1389 + { 1390 + "description": "Parameter containing reference", 1391 + "name": "parameterReference", 1392 + "in": "query", 1393 + "required": true, 1394 + "schema": { 1395 + "$ref": "#/components/schemas/ModelWithString" 1396 + } 1397 + } 1398 + ], 1399 + "responses": { 1400 + "200": { 1401 + "description": "Successful response", 1402 + "content": { 1403 + "application/json": { 1404 + "schema": { 1405 + "type": "array", 1406 + "items": { 1407 + "$ref": "#/components/schemas/ModelWithString" 1408 + } 1409 + } 1410 + } 1411 + } 1412 + }, 1413 + "400": { 1414 + "description": "400 `server` error" 1415 + }, 1416 + "500": { 1417 + "description": "500 server error" 1418 + } 1419 + } 1420 + } 1421 + }, 1422 + "/api/v{api-version}/multipart": { 1423 + "post": { 1424 + "tags": ["multipart"], 1425 + "operationId": "MultipartRequest", 1426 + "requestBody": { 1427 + "content": { 1428 + "multipart/form-data": { 1429 + "schema": { 1430 + "type": "object", 1431 + "properties": { 1432 + "content": { 1433 + "type": "string", 1434 + "format": "binary" 1435 + }, 1436 + "data": { 1437 + "oneOf": [ 1438 + { 1439 + "$ref": "#/components/schemas/ModelWithString" 1440 + }, 1441 + { 1442 + "type": "null" 1443 + } 1444 + ] 1445 + } 1446 + } 1447 + }, 1448 + "encoding": { 1449 + "content": { 1450 + "style": "form" 1451 + }, 1452 + "data": { 1453 + "style": "form" 1454 + } 1455 + } 1456 + } 1457 + } 1458 + } 1459 + }, 1460 + "get": { 1461 + "tags": ["multipart"], 1462 + "operationId": "MultipartResponse", 1463 + "responses": { 1464 + "200": { 1465 + "description": "OK", 1466 + "content": { 1467 + "multipart/mixed": { 1468 + "schema": { 1469 + "type": "object", 1470 + "properties": { 1471 + "file": { 1472 + "type": "string", 1473 + "format": "binary" 1474 + }, 1475 + "metadata": { 1476 + "type": "object", 1477 + "properties": { 1478 + "foo": { 1479 + "type": "string" 1480 + }, 1481 + "bar": { 1482 + "type": "string" 1483 + } 1484 + } 1485 + } 1486 + } 1487 + } 1488 + } 1489 + } 1490 + } 1491 + } 1492 + } 1493 + }, 1494 + "/api/v{api-version}/complex/{id}": { 1495 + "put": { 1496 + "tags": ["Complex"], 1497 + "operationId": "ComplexParams", 1498 + "parameters": [ 1499 + { 1500 + "name": "id", 1501 + "in": "path", 1502 + "required": true, 1503 + "schema": { 1504 + "type": "integer", 1505 + "format": "int32" 1506 + } 1507 + }, 1508 + { 1509 + "description": "api-version should be required in standalone clients", 1510 + "name": "api-version", 1511 + "in": "path", 1512 + "required": true, 1513 + "schema": { 1514 + "type": "string" 1515 + } 1516 + } 1517 + ], 1518 + "requestBody": { 1519 + "content": { 1520 + "application/json-patch+json": { 1521 + "schema": { 1522 + "required": ["key", "name", "parameters", "type"], 1523 + "type": "object", 1524 + "properties": { 1525 + "key": { 1526 + "maxLength": 64, 1527 + "pattern": "^[a-zA-Z0-9_]*$", 1528 + "type": ["string", "null"], 1529 + "readOnly": true 1530 + }, 1531 + "name": { 1532 + "maxLength": 255, 1533 + "type": ["string", "null"] 1534 + }, 1535 + "enabled": { 1536 + "type": "boolean", 1537 + "default": true 1538 + }, 1539 + "type": { 1540 + "enum": ["Monkey", "Horse", "Bird"], 1541 + "type": "string", 1542 + "readOnly": true 1543 + }, 1544 + "listOfModels": { 1545 + "type": ["array", "null"], 1546 + "items": { 1547 + "$ref": "#/components/schemas/ModelWithString" 1548 + } 1549 + }, 1550 + "listOfStrings": { 1551 + "type": ["array", "null"], 1552 + "items": { 1553 + "type": "string" 1554 + } 1555 + }, 1556 + "parameters": { 1557 + "type": "object", 1558 + "oneOf": [ 1559 + { 1560 + "$ref": "#/components/schemas/ModelWithString" 1561 + }, 1562 + { 1563 + "$ref": "#/components/schemas/ModelWithEnum" 1564 + }, 1565 + { 1566 + "$ref": "#/components/schemas/ModelWithArray" 1567 + }, 1568 + { 1569 + "$ref": "#/components/schemas/ModelWithDictionary" 1570 + } 1571 + ] 1572 + }, 1573 + "user": { 1574 + "type": "object", 1575 + "properties": { 1576 + "id": { 1577 + "type": "integer", 1578 + "format": "int32", 1579 + "readOnly": true 1580 + }, 1581 + "name": { 1582 + "type": ["string", "null"], 1583 + "readOnly": true 1584 + } 1585 + }, 1586 + "readOnly": true 1587 + } 1588 + } 1589 + } 1590 + } 1591 + } 1592 + }, 1593 + "responses": { 1594 + "200": { 1595 + "description": "Success", 1596 + "content": { 1597 + "application/json; type=collection": { 1598 + "schema": { 1599 + "$ref": "#/components/schemas/ModelWithString" 1600 + } 1601 + } 1602 + } 1603 + } 1604 + } 1605 + } 1606 + }, 1607 + "/api/v{api-version}/header": { 1608 + "post": { 1609 + "tags": ["Header"], 1610 + "operationId": "CallWithResultFromHeader", 1611 + "responses": { 1612 + "200": { 1613 + "description": "Successful response", 1614 + "headers": { 1615 + "operation-location": { 1616 + "schema": { 1617 + "type": "string" 1618 + } 1619 + } 1620 + } 1621 + }, 1622 + "400": { 1623 + "description": "400 server error" 1624 + }, 1625 + "500": { 1626 + "description": "500 server error" 1627 + } 1628 + } 1629 + } 1630 + }, 1631 + "/api/v{api-version}/error": { 1632 + "post": { 1633 + "tags": ["Error"], 1634 + "operationId": "testErrorCode", 1635 + "parameters": [ 1636 + { 1637 + "description": "Status code to return", 1638 + "name": "status", 1639 + "in": "query", 1640 + "required": true, 1641 + "schema": { 1642 + "type": "integer" 1643 + } 1644 + } 1645 + ], 1646 + "responses": { 1647 + "200": { 1648 + "description": "Custom message: Successful response" 1649 + }, 1650 + "500": { 1651 + "description": "Custom message: Internal Server Error" 1652 + }, 1653 + "501": { 1654 + "description": "Custom message: Not Implemented" 1655 + }, 1656 + "502": { 1657 + "description": "Custom message: Bad Gateway" 1658 + }, 1659 + "503": { 1660 + "description": "Custom message: Service Unavailable" 1661 + } 1662 + } 1663 + } 1664 + }, 1665 + "/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串": { 1666 + "post": { 1667 + "tags": ["Non-Ascii-æøåÆØÅöôêÊ"], 1668 + "operationId": "nonAsciiæøåÆØÅöôêÊ字符串", 1669 + "parameters": [ 1670 + { 1671 + "description": "Dummy input param", 1672 + "name": "nonAsciiParamæøåÆØÅöôêÊ", 1673 + "in": "query", 1674 + "required": true, 1675 + "schema": { 1676 + "type": "integer" 1677 + } 1678 + } 1679 + ], 1680 + "responses": { 1681 + "200": { 1682 + "description": "Successful response", 1683 + "content": { 1684 + "application/json": { 1685 + "schema": { 1686 + "type": "array", 1687 + "items": { 1688 + "$ref": "#/components/schemas/NonAsciiStringæøåÆØÅöôêÊ字符串" 1689 + } 1690 + } 1691 + } 1692 + } 1693 + } 1694 + } 1695 + }, 1696 + "put": { 1697 + "tags": ["Non-Ascii-æøåÆØÅöôêÊ"], 1698 + "summary": "Login User", 1699 + "operationId": "putWithFormUrlEncoded", 1700 + "requestBody": { 1701 + "content": { 1702 + "application/x-www-form-urlencoded": { 1703 + "schema": { 1704 + "$ref": "#/components/schemas/ArrayWithStrings" 1705 + } 1706 + } 1707 + }, 1708 + "required": true 1709 + } 1710 + } 1711 + } 1712 + }, 1713 + "components": { 1714 + "requestBodies": { 1715 + "SimpleRequestBody": { 1716 + "x-body-name": "foo", 1717 + "description": "A reusable request body", 1718 + "required": false, 1719 + "content": { 1720 + "application/json": { 1721 + "schema": { 1722 + "$ref": "#/components/schemas/ModelWithString" 1723 + } 1724 + } 1725 + } 1726 + }, 1727 + "SimpleFormData": { 1728 + "description": "A reusable request body", 1729 + "required": false, 1730 + "content": { 1731 + "multipart/form-data": { 1732 + "schema": { 1733 + "$ref": "#/components/schemas/ModelWithString" 1734 + } 1735 + } 1736 + } 1737 + } 1738 + }, 1739 + "parameters": { 1740 + "SimpleParameter": { 1741 + "description": "This is a reusable parameter", 1742 + "name": "parameter", 1743 + "in": "query", 1744 + "required": false, 1745 + "schema": { 1746 + "type": "string" 1747 + } 1748 + }, 1749 + "x-Foo-Bar": { 1750 + "description": "Parameter with illegal characters", 1751 + "name": "x-Foo-Bar", 1752 + "in": "header", 1753 + "required": true, 1754 + "content": { 1755 + "application/json": { 1756 + "schema": { 1757 + "$ref": "#/components/schemas/ModelWithString" 1758 + } 1759 + } 1760 + } 1761 + } 1762 + }, 1763 + "schemas": { 1764 + "camelCaseCommentWithBreaks": { 1765 + "description": "Testing multiline comments in string: First line\nSecond line\n\nFourth line", 1766 + "type": "integer" 1767 + }, 1768 + "CommentWithBreaks": { 1769 + "description": "Testing multiline comments in string: First line\nSecond line\n\nFourth line", 1770 + "type": "integer" 1771 + }, 1772 + "CommentWithBackticks": { 1773 + "description": "Testing backticks in string: `backticks` and ```multiple backticks``` should work", 1774 + "type": "integer" 1775 + }, 1776 + "CommentWithBackticksAndQuotes": { 1777 + "description": "Testing backticks and quotes in string: `backticks`, 'quotes', \"double quotes\" and ```multiple backticks``` should work", 1778 + "type": "integer" 1779 + }, 1780 + "CommentWithSlashes": { 1781 + "description": "Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work", 1782 + "type": "integer" 1783 + }, 1784 + "CommentWithExpressionPlaceholders": { 1785 + "description": "Testing expression placeholders in string: ${expression} should work", 1786 + "type": "integer" 1787 + }, 1788 + "CommentWithQuotes": { 1789 + "description": "Testing quotes in string: 'single quote''' and \"double quotes\"\"\" should work", 1790 + "type": "integer" 1791 + }, 1792 + "CommentWithReservedCharacters": { 1793 + "description": "Testing reserved characters in string: /* inline */ and /** inline **/ should work", 1794 + "type": "integer" 1795 + }, 1796 + "SimpleInteger": { 1797 + "description": "This is a simple number", 1798 + "type": "integer" 1799 + }, 1800 + "SimpleBoolean": { 1801 + "description": "This is a simple boolean", 1802 + "type": "boolean" 1803 + }, 1804 + "SimpleString": { 1805 + "description": "This is a simple string", 1806 + "type": "string" 1807 + }, 1808 + "NonAsciiStringæøåÆØÅöôêÊ字符串": { 1809 + "description": "A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串)", 1810 + "type": "string" 1811 + }, 1812 + "SimpleFile": { 1813 + "description": "This is a simple file", 1814 + "format": "binary", 1815 + "type": "string" 1816 + }, 1817 + "SimpleReference": { 1818 + "description": "This is a simple reference", 1819 + "$ref": "#/components/schemas/ModelWithString" 1820 + }, 1821 + "SimpleStringWithPattern": { 1822 + "description": "This is a simple string", 1823 + "maxLength": 64, 1824 + "pattern": "^[a-zA-Z0-9_]*$", 1825 + "type": ["string", "null"] 1826 + }, 1827 + "EnumWithStrings": { 1828 + "description": "This is a simple enum with strings", 1829 + "enum": [ 1830 + "Success", 1831 + "Warning", 1832 + "Error", 1833 + "'Single Quote'", 1834 + "\"Double Quotes\"", 1835 + "Non-ascii: øæåôöØÆÅÔÖ字符串" 1836 + ] 1837 + }, 1838 + "EnumWithReplacedCharacters": { 1839 + "enum": [ 1840 + "'Single Quote'", 1841 + "\"Double Quotes\"", 1842 + "øæåôöØÆÅÔÖ字符串", 1843 + 3.1, 1844 + "" 1845 + ], 1846 + "type": "string" 1847 + }, 1848 + "EnumWithNumbers": { 1849 + "description": "This is a simple enum with numbers", 1850 + "enum": [ 1851 + 1, 2, 3, 1.1, 1.2, 1.3, 100, 200, 300, -100, -200, -300, -1.1, -1.2, 1852 + -1.3 1853 + ], 1854 + "default": 200 1855 + }, 1856 + "EnumFromDescription": { 1857 + "description": "Success=1,Warning=2,Error=3", 1858 + "type": "number" 1859 + }, 1860 + "EnumWithExtensions": { 1861 + "description": "This is a simple enum with numbers", 1862 + "enum": [200, 400, 500], 1863 + "x-enum-varnames": ["CUSTOM_SUCCESS", "CUSTOM_WARNING", "CUSTOM_ERROR"], 1864 + "x-enum-descriptions": [ 1865 + "Used when the status of something is successful", 1866 + "Used when the status of something has a warning", 1867 + "Used when the status of something has an error" 1868 + ] 1869 + }, 1870 + "EnumWithXEnumNames": { 1871 + "enum": [0, 1, 2], 1872 + "x-enumNames": ["zero", "one", "two"] 1873 + }, 1874 + "ArrayWithNumbers": { 1875 + "description": "This is a simple array with numbers", 1876 + "type": "array", 1877 + "items": { 1878 + "type": "integer" 1879 + } 1880 + }, 1881 + "ArrayWithBooleans": { 1882 + "description": "This is a simple array with booleans", 1883 + "type": "array", 1884 + "items": { 1885 + "type": "boolean" 1886 + } 1887 + }, 1888 + "ArrayWithStrings": { 1889 + "description": "This is a simple array with strings", 1890 + "type": "array", 1891 + "items": { 1892 + "type": "string" 1893 + }, 1894 + "default": ["test"] 1895 + }, 1896 + "ArrayWithReferences": { 1897 + "description": "This is a simple array with references", 1898 + "type": "array", 1899 + "items": { 1900 + "$ref": "#/components/schemas/ModelWithString" 1901 + } 1902 + }, 1903 + "ArrayWithArray": { 1904 + "description": "This is a simple array containing an array", 1905 + "type": "array", 1906 + "items": { 1907 + "type": "array", 1908 + "items": { 1909 + "$ref": "#/components/schemas/ModelWithString" 1910 + } 1911 + } 1912 + }, 1913 + "ArrayWithProperties": { 1914 + "description": "This is a simple array with properties", 1915 + "type": "array", 1916 + "items": { 1917 + "type": "object", 1918 + "properties": { 1919 + "16x16": { 1920 + "$ref": "#/components/schemas/camelCaseCommentWithBreaks" 1921 + }, 1922 + "bar": { 1923 + "type": "string" 1924 + } 1925 + } 1926 + } 1927 + }, 1928 + "ArrayWithAnyOfProperties": { 1929 + "description": "This is a simple array with any of properties", 1930 + "type": "array", 1931 + "items": { 1932 + "anyOf": [ 1933 + { 1934 + "type": "object", 1935 + "properties": { 1936 + "foo": { 1937 + "type": "string", 1938 + "default": "test" 1939 + } 1940 + } 1941 + }, 1942 + { 1943 + "type": "object", 1944 + "properties": { 1945 + "bar": { 1946 + "type": "string" 1947 + } 1948 + } 1949 + } 1950 + ] 1951 + } 1952 + }, 1953 + "AnyOfAnyAndNull": { 1954 + "type": "object", 1955 + "properties": { 1956 + "data": { 1957 + "anyOf": [ 1958 + {}, 1959 + { 1960 + "type": "null" 1961 + } 1962 + ] 1963 + } 1964 + } 1965 + }, 1966 + "AnyOfArrays": { 1967 + "description": "This is a simple array with any of properties", 1968 + "type": "object", 1969 + "properties": { 1970 + "results": { 1971 + "items": { 1972 + "anyOf": [ 1973 + { 1974 + "type": "object", 1975 + "properties": { 1976 + "foo": { 1977 + "type": "string" 1978 + } 1979 + } 1980 + }, 1981 + { 1982 + "type": "object", 1983 + "properties": { 1984 + "bar": { 1985 + "type": "string" 1986 + } 1987 + } 1988 + } 1989 + ] 1990 + }, 1991 + "type": "array" 1992 + } 1993 + } 1994 + }, 1995 + "DictionaryWithString": { 1996 + "description": "This is a string dictionary", 1997 + "type": "object", 1998 + "additionalProperties": { 1999 + "type": "string" 2000 + } 2001 + }, 2002 + "DictionaryWithPropertiesAndAdditionalProperties": { 2003 + "type": "object", 2004 + "properties": { 2005 + "foo": { 2006 + "type": "number" 2007 + }, 2008 + "bar": { 2009 + "type": "boolean" 2010 + } 2011 + }, 2012 + "additionalProperties": { 2013 + "type": "string" 2014 + } 2015 + }, 2016 + "DictionaryWithReference": { 2017 + "description": "This is a string reference", 2018 + "type": "object", 2019 + "additionalProperties": { 2020 + "$ref": "#/components/schemas/ModelWithString" 2021 + } 2022 + }, 2023 + "DictionaryWithArray": { 2024 + "description": "This is a complex dictionary", 2025 + "type": "object", 2026 + "additionalProperties": { 2027 + "type": "array", 2028 + "items": { 2029 + "$ref": "#/components/schemas/ModelWithString" 2030 + } 2031 + } 2032 + }, 2033 + "DictionaryWithDictionary": { 2034 + "description": "This is a string dictionary", 2035 + "type": "object", 2036 + "additionalProperties": { 2037 + "type": "object", 2038 + "additionalProperties": { 2039 + "type": "string" 2040 + } 2041 + } 2042 + }, 2043 + "DictionaryWithProperties": { 2044 + "description": "This is a complex dictionary", 2045 + "type": "object", 2046 + "additionalProperties": { 2047 + "type": "object", 2048 + "properties": { 2049 + "foo": { 2050 + "type": "string" 2051 + }, 2052 + "bar": { 2053 + "type": "string" 2054 + } 2055 + } 2056 + } 2057 + }, 2058 + "ModelWithInteger": { 2059 + "description": "This is a model with one number property", 2060 + "type": "object", 2061 + "properties": { 2062 + "prop": { 2063 + "description": "This is a simple number property", 2064 + "type": "integer" 2065 + } 2066 + } 2067 + }, 2068 + "ModelWithBoolean": { 2069 + "description": "This is a model with one boolean property", 2070 + "type": "object", 2071 + "properties": { 2072 + "prop": { 2073 + "description": "This is a simple boolean property", 2074 + "type": "boolean" 2075 + } 2076 + } 2077 + }, 2078 + "ModelWithString": { 2079 + "description": "This is a model with one string property", 2080 + "type": "object", 2081 + "properties": { 2082 + "prop": { 2083 + "description": "This is a simple string property", 2084 + "type": "string" 2085 + } 2086 + } 2087 + }, 2088 + "ModelWithStringError": { 2089 + "description": "This is a model with one string property", 2090 + "type": "object", 2091 + "properties": { 2092 + "prop": { 2093 + "description": "This is a simple string property", 2094 + "type": "string" 2095 + } 2096 + } 2097 + }, 2098 + "Model-From.Zendesk": { 2099 + "description": "`Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets)", 2100 + "type": "string" 2101 + }, 2102 + "ModelWithNullableString": { 2103 + "description": "This is a model with one string property", 2104 + "type": "object", 2105 + "required": ["nullableRequiredProp1", "nullableRequiredProp2"], 2106 + "properties": { 2107 + "nullableProp1": { 2108 + "description": "This is a simple string property", 2109 + "type": ["string", "null"] 2110 + }, 2111 + "nullableRequiredProp1": { 2112 + "description": "This is a simple string property", 2113 + "type": ["string", "null"] 2114 + }, 2115 + "nullableProp2": { 2116 + "description": "This is a simple string property", 2117 + "type": ["string", "null"] 2118 + }, 2119 + "nullableRequiredProp2": { 2120 + "description": "This is a simple string property", 2121 + "type": ["string", "null"] 2122 + }, 2123 + "foo_bar-enum": { 2124 + "description": "This is a simple enum with strings", 2125 + "enum": ["Success", "Warning", "Error", "ØÆÅ字符串"] 2126 + } 2127 + } 2128 + }, 2129 + "ModelWithEnum": { 2130 + "description": "This is a model with one enum", 2131 + "type": "object", 2132 + "properties": { 2133 + "foo_bar-enum": { 2134 + "description": "This is a simple enum with strings", 2135 + "enum": ["Success", "Warning", "Error", "ØÆÅ字符串"] 2136 + }, 2137 + "statusCode": { 2138 + "description": "These are the HTTP error code enums", 2139 + "enum": [ 2140 + "100", 2141 + "200 FOO", 2142 + "300 FOO_BAR", 2143 + "400 foo-bar", 2144 + "500 foo.bar", 2145 + "600 foo&bar" 2146 + ] 2147 + }, 2148 + "bool": { 2149 + "description": "Simple boolean enum", 2150 + "type": "boolean", 2151 + "enum": [true] 2152 + } 2153 + } 2154 + }, 2155 + "ModelWithEnumWithHyphen": { 2156 + "description": "This is a model with one enum with escaped name", 2157 + "type": "object", 2158 + "properties": { 2159 + "foo-bar-baz-qux": { 2160 + "type": "string", 2161 + "enum": ["3.0"], 2162 + "title": "Foo-Bar-Baz-Qux", 2163 + "default": "3.0" 2164 + } 2165 + } 2166 + }, 2167 + "ModelWithEnumFromDescription": { 2168 + "description": "This is a model with one enum", 2169 + "type": "object", 2170 + "properties": { 2171 + "test": { 2172 + "type": "integer", 2173 + "description": "Success=1,Warning=2,Error=3" 2174 + } 2175 + } 2176 + }, 2177 + "ModelWithNestedEnums": { 2178 + "description": "This is a model with nested enums", 2179 + "type": "object", 2180 + "properties": { 2181 + "dictionaryWithEnum": { 2182 + "type": "object", 2183 + "additionalProperties": { 2184 + "enum": ["Success", "Warning", "Error"] 2185 + } 2186 + }, 2187 + "dictionaryWithEnumFromDescription": { 2188 + "type": "object", 2189 + "additionalProperties": { 2190 + "type": "integer", 2191 + "description": "Success=1,Warning=2,Error=3" 2192 + } 2193 + }, 2194 + "arrayWithEnum": { 2195 + "type": "array", 2196 + "items": { 2197 + "enum": ["Success", "Warning", "Error"] 2198 + } 2199 + }, 2200 + "arrayWithDescription": { 2201 + "type": "array", 2202 + "items": { 2203 + "type": "integer", 2204 + "description": "Success=1,Warning=2,Error=3" 2205 + } 2206 + }, 2207 + "foo_bar-enum": { 2208 + "description": "This is a simple enum with strings", 2209 + "enum": ["Success", "Warning", "Error", "ØÆÅ字符串"] 2210 + } 2211 + } 2212 + }, 2213 + "ModelWithReference": { 2214 + "description": "This is a model with one property containing a reference", 2215 + "type": "object", 2216 + "properties": { 2217 + "prop": { 2218 + "$ref": "#/components/schemas/ModelWithProperties" 2219 + } 2220 + } 2221 + }, 2222 + "ModelWithArrayReadOnlyAndWriteOnly": { 2223 + "description": "This is a model with one property containing an array", 2224 + "type": "object", 2225 + "properties": { 2226 + "prop": { 2227 + "type": "array", 2228 + "items": { 2229 + "$ref": "#/components/schemas/ModelWithReadOnlyAndWriteOnly" 2230 + } 2231 + }, 2232 + "propWithFile": { 2233 + "type": "array", 2234 + "items": { 2235 + "format": "binary", 2236 + "type": "string" 2237 + } 2238 + }, 2239 + "propWithNumber": { 2240 + "type": "array", 2241 + "items": { 2242 + "type": "number" 2243 + } 2244 + } 2245 + } 2246 + }, 2247 + "ModelWithArray": { 2248 + "description": "This is a model with one property containing an array", 2249 + "type": "object", 2250 + "properties": { 2251 + "prop": { 2252 + "type": "array", 2253 + "items": { 2254 + "$ref": "#/components/schemas/ModelWithString" 2255 + } 2256 + }, 2257 + "propWithFile": { 2258 + "type": "array", 2259 + "items": { 2260 + "format": "binary", 2261 + "type": "string" 2262 + } 2263 + }, 2264 + "propWithNumber": { 2265 + "type": "array", 2266 + "items": { 2267 + "type": "number" 2268 + } 2269 + } 2270 + } 2271 + }, 2272 + "ModelWithDictionary": { 2273 + "description": "This is a model with one property containing a dictionary", 2274 + "type": "object", 2275 + "properties": { 2276 + "prop": { 2277 + "type": "object", 2278 + "additionalProperties": { 2279 + "type": "string" 2280 + } 2281 + } 2282 + } 2283 + }, 2284 + "DeprecatedModel": { 2285 + "deprecated": true, 2286 + "description": "This is a deprecated model with a deprecated property", 2287 + "type": "object", 2288 + "properties": { 2289 + "prop": { 2290 + "deprecated": true, 2291 + "description": "This is a deprecated property", 2292 + "type": "string" 2293 + } 2294 + } 2295 + }, 2296 + "ModelWithCircularReference": { 2297 + "description": "This is a model with one property containing a circular reference", 2298 + "type": "object", 2299 + "properties": { 2300 + "prop": { 2301 + "$ref": "#/components/schemas/ModelWithCircularReference" 2302 + } 2303 + } 2304 + }, 2305 + "CompositionWithOneOf": { 2306 + "description": "This is a model with one property with a 'one of' relationship", 2307 + "type": "object", 2308 + "properties": { 2309 + "propA": { 2310 + "type": "object", 2311 + "oneOf": [ 2312 + { 2313 + "$ref": "#/components/schemas/ModelWithString" 2314 + }, 2315 + { 2316 + "$ref": "#/components/schemas/ModelWithEnum" 2317 + }, 2318 + { 2319 + "$ref": "#/components/schemas/ModelWithArray" 2320 + }, 2321 + { 2322 + "$ref": "#/components/schemas/ModelWithDictionary" 2323 + } 2324 + ] 2325 + } 2326 + } 2327 + }, 2328 + "CompositionWithOneOfAnonymous": { 2329 + "description": "This is a model with one property with a 'one of' relationship where the options are not $ref", 2330 + "type": "object", 2331 + "properties": { 2332 + "propA": { 2333 + "type": "object", 2334 + "oneOf": [ 2335 + { 2336 + "description": "Anonymous object type", 2337 + "type": "object", 2338 + "properties": { 2339 + "propA": { 2340 + "type": "string" 2341 + } 2342 + } 2343 + }, 2344 + { 2345 + "description": "Anonymous string type", 2346 + "type": "string" 2347 + }, 2348 + { 2349 + "description": "Anonymous integer type", 2350 + "type": "integer" 2351 + } 2352 + ] 2353 + } 2354 + } 2355 + }, 2356 + "ModelCircle": { 2357 + "description": "Circle", 2358 + "type": "object", 2359 + "required": ["kind"], 2360 + "properties": { 2361 + "kind": { 2362 + "type": "string" 2363 + }, 2364 + "radius": { 2365 + "type": "number" 2366 + } 2367 + } 2368 + }, 2369 + "ModelSquare": { 2370 + "description": "Square", 2371 + "type": "object", 2372 + "required": ["kind"], 2373 + "properties": { 2374 + "kind": { 2375 + "type": "string" 2376 + }, 2377 + "sideLength": { 2378 + "type": "number" 2379 + } 2380 + } 2381 + }, 2382 + "CompositionWithOneOfDiscriminator": { 2383 + "description": "This is a model with one property with a 'one of' relationship where the options are not $ref", 2384 + "type": "object", 2385 + "oneOf": [ 2386 + { 2387 + "$ref": "#/components/schemas/ModelCircle" 2388 + }, 2389 + { 2390 + "$ref": "#/components/schemas/ModelSquare" 2391 + } 2392 + ], 2393 + "discriminator": { 2394 + "propertyName": "kind", 2395 + "mapping": { 2396 + "circle": "#/components/schemas/ModelCircle", 2397 + "square": "#/components/schemas/ModelSquare" 2398 + } 2399 + } 2400 + }, 2401 + "CompositionWithAnyOf": { 2402 + "description": "This is a model with one property with a 'any of' relationship", 2403 + "type": "object", 2404 + "properties": { 2405 + "propA": { 2406 + "type": "object", 2407 + "anyOf": [ 2408 + { 2409 + "$ref": "#/components/schemas/ModelWithString" 2410 + }, 2411 + { 2412 + "$ref": "#/components/schemas/ModelWithEnum" 2413 + }, 2414 + { 2415 + "$ref": "#/components/schemas/ModelWithArray" 2416 + }, 2417 + { 2418 + "$ref": "#/components/schemas/ModelWithDictionary" 2419 + } 2420 + ] 2421 + } 2422 + } 2423 + }, 2424 + "CompositionWithAnyOfAnonymous": { 2425 + "description": "This is a model with one property with a 'any of' relationship where the options are not $ref", 2426 + "type": "object", 2427 + "properties": { 2428 + "propA": { 2429 + "type": "object", 2430 + "anyOf": [ 2431 + { 2432 + "description": "Anonymous object type", 2433 + "type": "object", 2434 + "properties": { 2435 + "propA": { 2436 + "type": "string" 2437 + } 2438 + } 2439 + }, 2440 + { 2441 + "description": "Anonymous string type", 2442 + "type": "string" 2443 + }, 2444 + { 2445 + "description": "Anonymous integer type", 2446 + "type": "integer" 2447 + } 2448 + ] 2449 + } 2450 + } 2451 + }, 2452 + "CompositionWithNestedAnyAndTypeNull": { 2453 + "description": "This is a model with nested 'any of' property with a type null", 2454 + "type": "object", 2455 + "properties": { 2456 + "propA": { 2457 + "type": "object", 2458 + "anyOf": [ 2459 + { 2460 + "items": { 2461 + "anyOf": [ 2462 + { 2463 + "$ref": "#/components/schemas/ModelWithDictionary" 2464 + }, 2465 + { 2466 + "type": "null" 2467 + } 2468 + ] 2469 + }, 2470 + "type": "array" 2471 + }, 2472 + { 2473 + "items": { 2474 + "anyOf": [ 2475 + { 2476 + "$ref": "#/components/schemas/ModelWithArray" 2477 + }, 2478 + { 2479 + "type": "null" 2480 + } 2481 + ] 2482 + }, 2483 + "type": "array" 2484 + } 2485 + ] 2486 + } 2487 + } 2488 + }, 2489 + "3e-num_1Период": { 2490 + "enum": ["Bird", "Dog"], 2491 + "type": "string" 2492 + }, 2493 + "ConstValue": { 2494 + "type": "string", 2495 + "const": "ConstValue" 2496 + }, 2497 + "CompositionWithNestedAnyOfAndNull": { 2498 + "description": "This is a model with one property with a 'any of' relationship where the options are not $ref", 2499 + "type": "object", 2500 + "properties": { 2501 + "propA": { 2502 + "anyOf": [ 2503 + { 2504 + "items": { 2505 + "anyOf": [ 2506 + { 2507 + "$ref": "#/components/schemas/3e-num_1Период" 2508 + }, 2509 + { 2510 + "$ref": "#/components/schemas/ConstValue" 2511 + } 2512 + ] 2513 + }, 2514 + "type": "array" 2515 + }, 2516 + { 2517 + "type": "null" 2518 + } 2519 + ], 2520 + "title": "Scopes" 2521 + } 2522 + } 2523 + }, 2524 + "CompositionWithOneOfAndNullable": { 2525 + "description": "This is a model with one property with a 'one of' relationship", 2526 + "type": "object", 2527 + "properties": { 2528 + "propA": { 2529 + "type": ["object", "null"], 2530 + "oneOf": [ 2531 + { 2532 + "type": "object", 2533 + "properties": { 2534 + "boolean": { 2535 + "type": "boolean" 2536 + } 2537 + } 2538 + }, 2539 + { 2540 + "$ref": "#/components/schemas/ModelWithEnum" 2541 + }, 2542 + { 2543 + "$ref": "#/components/schemas/ModelWithArray" 2544 + }, 2545 + { 2546 + "$ref": "#/components/schemas/ModelWithDictionary" 2547 + } 2548 + ] 2549 + } 2550 + } 2551 + }, 2552 + "CompositionWithOneOfAndSimpleDictionary": { 2553 + "description": "This is a model that contains a simple dictionary within composition", 2554 + "type": "object", 2555 + "properties": { 2556 + "propA": { 2557 + "oneOf": [ 2558 + { 2559 + "type": "boolean" 2560 + }, 2561 + { 2562 + "type": "object", 2563 + "additionalProperties": { 2564 + "type": "number" 2565 + } 2566 + } 2567 + ] 2568 + } 2569 + } 2570 + }, 2571 + "CompositionWithOneOfAndSimpleArrayDictionary": { 2572 + "description": "This is a model that contains a dictionary of simple arrays within composition", 2573 + "type": "object", 2574 + "properties": { 2575 + "propA": { 2576 + "oneOf": [ 2577 + { 2578 + "type": "boolean" 2579 + }, 2580 + { 2581 + "type": "object", 2582 + "additionalProperties": { 2583 + "type": "array", 2584 + "items": { 2585 + "type": "boolean" 2586 + } 2587 + } 2588 + } 2589 + ] 2590 + } 2591 + } 2592 + }, 2593 + "CompositionWithOneOfAndComplexArrayDictionary": { 2594 + "description": "This is a model that contains a dictionary of complex arrays (composited) within composition", 2595 + "type": "object", 2596 + "properties": { 2597 + "propA": { 2598 + "oneOf": [ 2599 + { 2600 + "type": "boolean" 2601 + }, 2602 + { 2603 + "type": "object", 2604 + "additionalProperties": { 2605 + "type": "array", 2606 + "items": { 2607 + "oneOf": [ 2608 + { 2609 + "type": "number" 2610 + }, 2611 + { 2612 + "type": "string" 2613 + } 2614 + ] 2615 + } 2616 + } 2617 + } 2618 + ] 2619 + } 2620 + } 2621 + }, 2622 + "CompositionWithAllOfAndNullable": { 2623 + "description": "This is a model with one property with a 'all of' relationship", 2624 + "type": "object", 2625 + "properties": { 2626 + "propA": { 2627 + "type": ["object", "null"], 2628 + "allOf": [ 2629 + { 2630 + "type": "object", 2631 + "properties": { 2632 + "boolean": { 2633 + "type": "boolean" 2634 + } 2635 + } 2636 + }, 2637 + { 2638 + "$ref": "#/components/schemas/ModelWithEnum" 2639 + }, 2640 + { 2641 + "$ref": "#/components/schemas/ModelWithArray" 2642 + }, 2643 + { 2644 + "$ref": "#/components/schemas/ModelWithDictionary" 2645 + } 2646 + ] 2647 + } 2648 + } 2649 + }, 2650 + "CompositionWithAnyOfAndNullable": { 2651 + "description": "This is a model with one property with a 'any of' relationship", 2652 + "type": "object", 2653 + "properties": { 2654 + "propA": { 2655 + "type": ["object", "null"], 2656 + "anyOf": [ 2657 + { 2658 + "type": "object", 2659 + "properties": { 2660 + "boolean": { 2661 + "type": "boolean" 2662 + } 2663 + } 2664 + }, 2665 + { 2666 + "$ref": "#/components/schemas/ModelWithEnum" 2667 + }, 2668 + { 2669 + "$ref": "#/components/schemas/ModelWithArray" 2670 + }, 2671 + { 2672 + "$ref": "#/components/schemas/ModelWithDictionary" 2673 + } 2674 + ] 2675 + } 2676 + } 2677 + }, 2678 + "CompositionBaseModel": { 2679 + "description": "This is a base model with two simple optional properties", 2680 + "type": "object", 2681 + "properties": { 2682 + "firstName": { 2683 + "type": "string" 2684 + }, 2685 + "lastname": { 2686 + "type": "string" 2687 + } 2688 + } 2689 + }, 2690 + "CompositionExtendedModel": { 2691 + "description": "This is a model that extends the base model", 2692 + "type": "object", 2693 + "allOf": [ 2694 + { 2695 + "$ref": "#/components/schemas/CompositionBaseModel" 2696 + } 2697 + ], 2698 + "properties": { 2699 + "age": { 2700 + "type": "number" 2701 + } 2702 + }, 2703 + "required": ["firstName", "lastname", "age"] 2704 + }, 2705 + "ModelWithProperties": { 2706 + "description": "This is a model with one nested property", 2707 + "type": "object", 2708 + "required": ["required", "requiredAndReadOnly", "requiredAndNullable"], 2709 + "properties": { 2710 + "required": { 2711 + "type": "string" 2712 + }, 2713 + "requiredAndReadOnly": { 2714 + "type": "string", 2715 + "readOnly": true 2716 + }, 2717 + "requiredAndNullable": { 2718 + "type": ["string", "null"] 2719 + }, 2720 + "string": { 2721 + "type": "string" 2722 + }, 2723 + "number": { 2724 + "type": "number" 2725 + }, 2726 + "boolean": { 2727 + "type": "boolean" 2728 + }, 2729 + "reference": { 2730 + "$ref": "#/components/schemas/ModelWithString" 2731 + }, 2732 + "property with space": { 2733 + "type": "string" 2734 + }, 2735 + "default": { 2736 + "type": "string" 2737 + }, 2738 + "try": { 2739 + "type": "string" 2740 + }, 2741 + "@namespace.string": { 2742 + "type": "string", 2743 + "readOnly": true 2744 + }, 2745 + "@namespace.integer": { 2746 + "type": "integer", 2747 + "readOnly": true 2748 + } 2749 + } 2750 + }, 2751 + "ModelWithNestedProperties": { 2752 + "description": "This is a model with one nested property", 2753 + "type": "object", 2754 + "required": ["first"], 2755 + "properties": { 2756 + "first": { 2757 + "type": ["object", "null"], 2758 + "required": ["second"], 2759 + "readOnly": true, 2760 + "properties": { 2761 + "second": { 2762 + "type": ["object", "null"], 2763 + "required": ["third"], 2764 + "readOnly": true, 2765 + "properties": { 2766 + "third": { 2767 + "type": ["string", "null"], 2768 + "required": true, 2769 + "readOnly": true 2770 + } 2771 + } 2772 + } 2773 + } 2774 + } 2775 + } 2776 + }, 2777 + "ModelWithDuplicateProperties": { 2778 + "description": "This is a model with duplicated properties", 2779 + "type": "object", 2780 + "properties": { 2781 + "prop": { 2782 + "$ref": "#/components/schemas/ModelWithString" 2783 + }, 2784 + "prop": { 2785 + "$ref": "#/components/schemas/ModelWithString" 2786 + }, 2787 + "prop": { 2788 + "$ref": "#/components/schemas/ModelWithString" 2789 + } 2790 + } 2791 + }, 2792 + "ModelWithOrderedProperties": { 2793 + "description": "This is a model with ordered properties", 2794 + "type": "object", 2795 + "properties": { 2796 + "zebra": { 2797 + "type": "string" 2798 + }, 2799 + "apple": { 2800 + "type": "string" 2801 + }, 2802 + "hawaii": { 2803 + "type": "string" 2804 + } 2805 + } 2806 + }, 2807 + "ModelWithDuplicateImports": { 2808 + "description": "This is a model with duplicated imports", 2809 + "type": "object", 2810 + "properties": { 2811 + "propA": { 2812 + "$ref": "#/components/schemas/ModelWithString" 2813 + }, 2814 + "propB": { 2815 + "$ref": "#/components/schemas/ModelWithString" 2816 + }, 2817 + "propC": { 2818 + "$ref": "#/components/schemas/ModelWithString" 2819 + } 2820 + } 2821 + }, 2822 + "ModelThatExtends": { 2823 + "description": "This is a model that extends another model", 2824 + "type": "object", 2825 + "allOf": [ 2826 + { 2827 + "$ref": "#/components/schemas/ModelWithString" 2828 + }, 2829 + { 2830 + "type": "object", 2831 + "properties": { 2832 + "propExtendsA": { 2833 + "type": "string" 2834 + }, 2835 + "propExtendsB": { 2836 + "$ref": "#/components/schemas/ModelWithString" 2837 + } 2838 + } 2839 + } 2840 + ] 2841 + }, 2842 + "ModelThatExtendsExtends": { 2843 + "description": "This is a model that extends another model", 2844 + "type": "object", 2845 + "allOf": [ 2846 + { 2847 + "$ref": "#/components/schemas/ModelWithString" 2848 + }, 2849 + { 2850 + "$ref": "#/components/schemas/ModelThatExtends" 2851 + }, 2852 + { 2853 + "type": "object", 2854 + "properties": { 2855 + "propExtendsC": { 2856 + "type": "string" 2857 + }, 2858 + "propExtendsD": { 2859 + "$ref": "#/components/schemas/ModelWithString" 2860 + } 2861 + } 2862 + } 2863 + ] 2864 + }, 2865 + "ModelWithPattern": { 2866 + "description": "This is a model that contains a some patterns", 2867 + "type": "object", 2868 + "required": ["key", "name"], 2869 + "properties": { 2870 + "key": { 2871 + "maxLength": 64, 2872 + "pattern": "^[a-zA-Z0-9_]*$", 2873 + "type": "string" 2874 + }, 2875 + "name": { 2876 + "maxLength": 255, 2877 + "type": "string" 2878 + }, 2879 + "enabled": { 2880 + "type": "boolean", 2881 + "readOnly": true 2882 + }, 2883 + "modified": { 2884 + "type": "string", 2885 + "format": "date-time", 2886 + "readOnly": true 2887 + }, 2888 + "id": { 2889 + "type": "string", 2890 + "pattern": "^\\d{2}-\\d{3}-\\d{4}$" 2891 + }, 2892 + "text": { 2893 + "type": "string", 2894 + "pattern": "^\\w+$" 2895 + }, 2896 + "patternWithSingleQuotes": { 2897 + "type": "string", 2898 + "pattern": "^[a-zA-Z0-9']*$" 2899 + }, 2900 + "patternWithNewline": { 2901 + "type": "string", 2902 + "pattern": "aaa\nbbb" 2903 + }, 2904 + "patternWithBacktick": { 2905 + "type": "string", 2906 + "pattern": "aaa`bbb" 2907 + } 2908 + } 2909 + }, 2910 + "File": { 2911 + "required": ["mime"], 2912 + "type": "object", 2913 + "properties": { 2914 + "id": { 2915 + "title": "Id", 2916 + "type": "string", 2917 + "readOnly": true, 2918 + "minLength": 1 2919 + }, 2920 + "updated_at": { 2921 + "title": "Updated at", 2922 + "type": "string", 2923 + "format": "date-time", 2924 + "readOnly": true 2925 + }, 2926 + "created_at": { 2927 + "title": "Created at", 2928 + "type": "string", 2929 + "format": "date-time", 2930 + "readOnly": true 2931 + }, 2932 + "mime": { 2933 + "title": "Mime", 2934 + "type": "string", 2935 + "maxLength": 24, 2936 + "minLength": 1 2937 + }, 2938 + "file": { 2939 + "title": "File", 2940 + "type": "string", 2941 + "readOnly": true, 2942 + "format": "uri" 2943 + } 2944 + } 2945 + }, 2946 + "default": { 2947 + "type": "object", 2948 + "properties": { 2949 + "name": { 2950 + "type": "string" 2951 + } 2952 + } 2953 + }, 2954 + "Pageable": { 2955 + "type": "object", 2956 + "properties": { 2957 + "page": { 2958 + "minimum": 0, 2959 + "type": "integer", 2960 + "format": "int32", 2961 + "default": 0 2962 + }, 2963 + "size": { 2964 + "minimum": 1, 2965 + "type": "integer", 2966 + "format": "int32" 2967 + }, 2968 + "sort": { 2969 + "type": "array", 2970 + "items": { 2971 + "type": "string" 2972 + } 2973 + } 2974 + } 2975 + }, 2976 + "FreeFormObjectWithoutAdditionalProperties": { 2977 + "description": "This is a free-form object without additionalProperties.", 2978 + "type": "object" 2979 + }, 2980 + "FreeFormObjectWithAdditionalPropertiesEqTrue": { 2981 + "description": "This is a free-form object with additionalProperties: true.", 2982 + "type": "object", 2983 + "additionalProperties": true 2984 + }, 2985 + "FreeFormObjectWithAdditionalPropertiesEqEmptyObject": { 2986 + "description": "This is a free-form object with additionalProperties: {}.", 2987 + "type": "object", 2988 + "additionalProperties": {} 2989 + }, 2990 + "ModelWithConst": { 2991 + "type": "object", 2992 + "properties": { 2993 + "String": { 2994 + "const": "String" 2995 + }, 2996 + "number": { 2997 + "const": 0 2998 + }, 2999 + "null": { 3000 + "const": null 3001 + }, 3002 + "withType": { 3003 + "type": "string", 3004 + "const": "Some string" 3005 + } 3006 + } 3007 + }, 3008 + "ModelWithAdditionalPropertiesEqTrue": { 3009 + "description": "This is a model with one property and additionalProperties: true", 3010 + "type": "object", 3011 + "properties": { 3012 + "prop": { 3013 + "description": "This is a simple string property", 3014 + "type": "string" 3015 + } 3016 + }, 3017 + "additionalProperties": true 3018 + }, 3019 + "NestedAnyOfArraysNullable": { 3020 + "properties": { 3021 + "nullableArray": { 3022 + "anyOf": [ 3023 + { 3024 + "items": { 3025 + "anyOf": [ 3026 + { 3027 + "type": "string" 3028 + }, 3029 + { 3030 + "type": "boolean" 3031 + } 3032 + ] 3033 + }, 3034 + "type": "array" 3035 + }, 3036 + { 3037 + "type": "null" 3038 + } 3039 + ] 3040 + } 3041 + }, 3042 + "type": "object" 3043 + }, 3044 + "CompositionWithOneOfAndProperties": { 3045 + "type": "object", 3046 + "oneOf": [ 3047 + { 3048 + "type": "object", 3049 + "required": ["foo"], 3050 + "properties": { 3051 + "foo": { 3052 + "$ref": "#/components/parameters/SimpleParameter" 3053 + } 3054 + }, 3055 + "additionalProperties": false 3056 + }, 3057 + { 3058 + "type": "object", 3059 + "required": ["bar"], 3060 + "properties": { 3061 + "bar": { 3062 + "$ref": "#/components/schemas/NonAsciiStringæøåÆØÅöôêÊ字符串" 3063 + } 3064 + }, 3065 + "additionalProperties": false 3066 + } 3067 + ], 3068 + "required": ["baz", "qux"], 3069 + "properties": { 3070 + "baz": { 3071 + "type": ["integer", "null"], 3072 + "format": "uint16", 3073 + "minimum": 0.0 3074 + }, 3075 + "qux": { 3076 + "type": "integer", 3077 + "format": "uint8", 3078 + "minimum": 0.0 3079 + } 3080 + } 3081 + }, 3082 + "NullableObject": { 3083 + "type": ["object", "null"], 3084 + "description": "An object that can be null", 3085 + "properties": { 3086 + "foo": { 3087 + "type": "string" 3088 + } 3089 + }, 3090 + "default": null 3091 + }, 3092 + "CharactersInDescription": { 3093 + "type": "string", 3094 + "description": "Some % character" 3095 + }, 3096 + "ModelWithNullableObject": { 3097 + "type": "object", 3098 + "properties": { 3099 + "data": { 3100 + "$ref": "#/components/schemas/NullableObject" 3101 + } 3102 + } 3103 + }, 3104 + "ModelWithOneOfEnum": { 3105 + "oneOf": [ 3106 + { 3107 + "type": "object", 3108 + "required": ["foo"], 3109 + "properties": { 3110 + "foo": { 3111 + "type": "string", 3112 + "enum": ["Bar"] 3113 + } 3114 + } 3115 + }, 3116 + { 3117 + "type": "object", 3118 + "required": ["foo"], 3119 + "properties": { 3120 + "foo": { 3121 + "type": "string", 3122 + "enum": ["Baz"] 3123 + } 3124 + } 3125 + }, 3126 + { 3127 + "type": "object", 3128 + "required": ["foo"], 3129 + "properties": { 3130 + "foo": { 3131 + "type": "string", 3132 + "enum": ["Qux"] 3133 + } 3134 + } 3135 + }, 3136 + { 3137 + "type": "object", 3138 + "required": ["content", "foo"], 3139 + "properties": { 3140 + "content": { 3141 + "type": "string", 3142 + "format": "date-time" 3143 + }, 3144 + "foo": { 3145 + "type": "string", 3146 + "enum": ["Quux"] 3147 + } 3148 + } 3149 + }, 3150 + { 3151 + "type": "object", 3152 + "required": ["content", "foo"], 3153 + "properties": { 3154 + "content": { 3155 + "type": "array", 3156 + "prefixItems": [ 3157 + { 3158 + "type": "string", 3159 + "format": "date-time" 3160 + }, 3161 + { 3162 + "type": "string" 3163 + } 3164 + ], 3165 + "maxItems": 2, 3166 + "minItems": 2 3167 + }, 3168 + "foo": { 3169 + "type": "string", 3170 + "enum": ["Corge"] 3171 + } 3172 + } 3173 + } 3174 + ] 3175 + }, 3176 + "ModelWithNestedArrayEnumsDataFoo": { 3177 + "enum": ["foo", "bar"], 3178 + "type": "string" 3179 + }, 3180 + "ModelWithNestedArrayEnumsDataBar": { 3181 + "enum": ["baz", "qux"], 3182 + "type": "string" 3183 + }, 3184 + "ModelWithNestedArrayEnumsData": { 3185 + "type": "object", 3186 + "properties": { 3187 + "foo": { 3188 + "type": "array", 3189 + "items": { 3190 + "$ref": "#/components/schemas/ModelWithNestedArrayEnumsDataFoo" 3191 + } 3192 + }, 3193 + "bar": { 3194 + "type": "array", 3195 + "items": { 3196 + "$ref": "#/components/schemas/ModelWithNestedArrayEnumsDataBar" 3197 + } 3198 + } 3199 + } 3200 + }, 3201 + "ModelWithNestedArrayEnums": { 3202 + "type": "object", 3203 + "properties": { 3204 + "array_strings": { 3205 + "type": "array", 3206 + "items": { 3207 + "type": "string" 3208 + } 3209 + }, 3210 + "data": { 3211 + "allOf": [ 3212 + { 3213 + "$ref": "#/components/schemas/ModelWithNestedArrayEnumsData" 3214 + } 3215 + ] 3216 + } 3217 + } 3218 + }, 3219 + "ModelWithNestedCompositionEnums": { 3220 + "type": "object", 3221 + "properties": { 3222 + "foo": { 3223 + "allOf": [ 3224 + { 3225 + "$ref": "#/components/schemas/ModelWithNestedArrayEnumsDataFoo" 3226 + } 3227 + ] 3228 + } 3229 + } 3230 + }, 3231 + "ModelWithReadOnlyAndWriteOnly": { 3232 + "type": "object", 3233 + "required": ["foo", "bar", "baz"], 3234 + "properties": { 3235 + "foo": { 3236 + "type": "string" 3237 + }, 3238 + "bar": { 3239 + "readOnly": true, 3240 + "type": "string" 3241 + }, 3242 + "baz": { 3243 + "type": "string", 3244 + "writeOnly": true 3245 + } 3246 + } 3247 + }, 3248 + "ModelWithConstantSizeArray": { 3249 + "type": "array", 3250 + "items": { 3251 + "type": "number" 3252 + }, 3253 + "minItems": 2, 3254 + "maxItems": 2 3255 + }, 3256 + "ModelWithAnyOfConstantSizeArray": { 3257 + "type": "array", 3258 + "items": { 3259 + "oneOf": [ 3260 + { 3261 + "type": "number" 3262 + }, 3263 + { 3264 + "type": "string" 3265 + } 3266 + ] 3267 + }, 3268 + "minItems": 3, 3269 + "maxItems": 3 3270 + }, 3271 + "ModelWithPrefixItemsConstantSizeArray": { 3272 + "type": "array", 3273 + "prefixItems": [ 3274 + { 3275 + "$ref": "#/components/schemas/ModelWithInteger" 3276 + }, 3277 + { 3278 + "oneOf": [ 3279 + { 3280 + "type": "number" 3281 + }, 3282 + { 3283 + "type": "string" 3284 + } 3285 + ] 3286 + }, 3287 + { 3288 + "type": "string" 3289 + } 3290 + ] 3291 + }, 3292 + "ModelWithAnyOfConstantSizeArrayNullable": { 3293 + "type": ["array"], 3294 + "items": { 3295 + "oneOf": [ 3296 + { 3297 + "type": ["number", "null"] 3298 + }, 3299 + { 3300 + "type": "string" 3301 + } 3302 + ] 3303 + }, 3304 + "minItems": 3, 3305 + "maxItems": 3 3306 + }, 3307 + "ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions": { 3308 + "type": "array", 3309 + "items": { 3310 + "oneOf": [ 3311 + { 3312 + "type": "number" 3313 + }, 3314 + { 3315 + "$ref": "#/components/schemas/import" 3316 + } 3317 + ] 3318 + }, 3319 + "minItems": 2, 3320 + "maxItems": 2 3321 + }, 3322 + "ModelWithAnyOfConstantSizeArrayAndIntersect": { 3323 + "type": "array", 3324 + "items": { 3325 + "allOf": [ 3326 + { 3327 + "type": "number" 3328 + }, 3329 + { 3330 + "type": "string" 3331 + } 3332 + ] 3333 + }, 3334 + "minItems": 2, 3335 + "maxItems": 2 3336 + }, 3337 + "ModelWithNumericEnumUnion": { 3338 + "type": "object", 3339 + "properties": { 3340 + "value": { 3341 + "type": "number", 3342 + "description": "Период", 3343 + "enum": [-10, -1, 0, 1, 3, 6, 12] 3344 + } 3345 + } 3346 + }, 3347 + "ModelWithBackticksInDescription": { 3348 + "description": "Some description with `back ticks`", 3349 + "type": "object", 3350 + "properties": { 3351 + "template": { 3352 + "type": "string", 3353 + "description": "The template `that` should be used for parsing and importing the contents of the CSV file.\n\n<br/><p>There is one placeholder currently supported:<ul> <li><b>${x}</b> - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)</li></ul><p>Example of a correct JSON template:</p>\n<pre>\n[\n {\n \"resourceType\": \"Asset\",\n \"identifier\": {\n \"name\": \"${1}\",\n \"domain\": {\n \"name\": \"${2}\",\n \"community\": {\n \"name\": \"Some Community\"\n }\n }\n },\n \"attributes\" : {\n \"00000000-0000-0000-0000-000000003115\" : [ {\n \"value\" : \"${3}\" \n } ],\n \"00000000-0000-0000-0000-000000000222\" : [ {\n \"value\" : \"${4}\"\n } ]\n }\n }\n]\n</pre>" 3354 + } 3355 + } 3356 + }, 3357 + "ModelWithOneOfAndProperties": { 3358 + "type": "object", 3359 + "oneOf": [ 3360 + { 3361 + "$ref": "#/components/parameters/SimpleParameter" 3362 + }, 3363 + { 3364 + "$ref": "#/components/schemas/NonAsciiStringæøåÆØÅöôêÊ字符串" 3365 + } 3366 + ], 3367 + "required": ["baz", "qux"], 3368 + "properties": { 3369 + "baz": { 3370 + "type": ["integer", "null"], 3371 + "format": "uint16", 3372 + "minimum": 0.0 3373 + }, 3374 + "qux": { 3375 + "type": "integer", 3376 + "format": "uint8", 3377 + "minimum": 0.0 3378 + } 3379 + } 3380 + }, 3381 + "ParameterSimpleParameterUnused": { 3382 + "description": "Model used to test deduplication strategy (unused)", 3383 + "type": "string" 3384 + }, 3385 + "PostServiceWithEmptyTagResponse": { 3386 + "description": "Model used to test deduplication strategy", 3387 + "type": "string" 3388 + }, 3389 + "PostServiceWithEmptyTagResponse2": { 3390 + "description": "Model used to test deduplication strategy", 3391 + "type": "string" 3392 + }, 3393 + "DeleteFooData": { 3394 + "description": "Model used to test deduplication strategy", 3395 + "type": "string" 3396 + }, 3397 + "DeleteFooData2": { 3398 + "description": "Model used to test deduplication strategy", 3399 + "type": "string" 3400 + }, 3401 + "import": { 3402 + "description": "Model with restricted keyword name", 3403 + "type": "string" 3404 + }, 3405 + "400": { 3406 + "description": "Model with number-only name", 3407 + "type": "string" 3408 + }, 3409 + "SchemaWithFormRestrictedKeys": { 3410 + "type": "object", 3411 + "properties": { 3412 + "description": { 3413 + "type": "string" 3414 + }, 3415 + "x-enum-descriptions": { 3416 + "type": "string" 3417 + }, 3418 + "x-enum-varnames": { 3419 + "type": "string" 3420 + }, 3421 + "x-enumNames": { 3422 + "type": "string" 3423 + }, 3424 + "title": { 3425 + "type": "string" 3426 + }, 3427 + "object": { 3428 + "type": "object", 3429 + "properties": { 3430 + "description": { 3431 + "type": "string" 3432 + }, 3433 + "x-enum-descriptions": { 3434 + "type": "string" 3435 + }, 3436 + "x-enum-varnames": { 3437 + "type": "string" 3438 + }, 3439 + "x-enumNames": { 3440 + "type": "string" 3441 + }, 3442 + "title": { 3443 + "type": "string" 3444 + } 3445 + } 3446 + }, 3447 + "array": { 3448 + "type": "array", 3449 + "items": { 3450 + "type": "object", 3451 + "properties": { 3452 + "description": { 3453 + "type": "string" 3454 + }, 3455 + "x-enum-descriptions": { 3456 + "type": "string" 3457 + }, 3458 + "x-enum-varnames": { 3459 + "type": "string" 3460 + }, 3461 + "x-enumNames": { 3462 + "type": "string" 3463 + }, 3464 + "title": { 3465 + "type": "string" 3466 + } 3467 + } 3468 + } 3469 + } 3470 + } 3471 + }, 3472 + "io.k8s.apimachinery.pkg.apis.meta.v1.DeleteOptions": { 3473 + "description": "This schema was giving PascalCase transformations a hard time", 3474 + "properties": { 3475 + "preconditions": { 3476 + "allOf": [ 3477 + { 3478 + "$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions" 3479 + } 3480 + ], 3481 + "description": "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned." 3482 + } 3483 + }, 3484 + "type": "object" 3485 + }, 3486 + "io.k8s.apimachinery.pkg.apis.meta.v1.Preconditions": { 3487 + "description": "This schema was giving PascalCase transformations a hard time", 3488 + "properties": { 3489 + "resourceVersion": { 3490 + "description": "Specifies the target ResourceVersion", 3491 + "type": "string" 3492 + }, 3493 + "uid": { 3494 + "description": "Specifies the target UID.", 3495 + "type": "string" 3496 + } 3497 + }, 3498 + "type": "object" 3499 + }, 3500 + "AdditionalPropertiesUnknownIssue": { 3501 + "type": "object", 3502 + "properties": {}, 3503 + "additionalProperties": { 3504 + "anyOf": [ 3505 + { 3506 + "type": "string" 3507 + }, 3508 + { 3509 + "type": "number" 3510 + } 3511 + ] 3512 + } 3513 + }, 3514 + "AdditionalPropertiesUnknownIssue2": { 3515 + "type": "object", 3516 + "additionalProperties": { 3517 + "anyOf": [ 3518 + { 3519 + "type": "string" 3520 + }, 3521 + { 3522 + "type": "number" 3523 + } 3524 + ] 3525 + } 3526 + }, 3527 + "AdditionalPropertiesUnknownIssue3": { 3528 + "type": "object", 3529 + "allOf": [ 3530 + { 3531 + "type": "string" 3532 + }, 3533 + { 3534 + "type": "object", 3535 + "required": ["entries"], 3536 + "properties": { 3537 + "entries": { 3538 + "type": "object", 3539 + "additionalProperties": { 3540 + "$ref": "#/components/schemas/AdditionalPropertiesUnknownIssue" 3541 + } 3542 + } 3543 + } 3544 + } 3545 + ] 3546 + }, 3547 + "AdditionalPropertiesIntegerIssue": { 3548 + "type": "object", 3549 + "required": ["value"], 3550 + "properties": { 3551 + "value": { 3552 + "type": "integer" 3553 + } 3554 + }, 3555 + "additionalProperties": { 3556 + "type": "integer" 3557 + } 3558 + }, 3559 + "OneOfAllOfIssue": { 3560 + "oneOf": [ 3561 + { 3562 + "allOf": [ 3563 + { 3564 + "oneOf": [ 3565 + { 3566 + "$ref": "#/components/schemas/ConstValue" 3567 + }, 3568 + { 3569 + "$ref": "#/components/schemas/Generic.Schema.Duplicate.Issue`1[System.Boolean]" 3570 + } 3571 + ] 3572 + }, 3573 + { 3574 + "$ref": "#/components/schemas/3e-num_1Период" 3575 + } 3576 + ] 3577 + }, 3578 + { 3579 + "$ref": "#/components/schemas/Generic.Schema.Duplicate.Issue`1[System.String]" 3580 + } 3581 + ] 3582 + }, 3583 + "Generic.Schema.Duplicate.Issue`1[System.Boolean]": { 3584 + "type": "object", 3585 + "properties": { 3586 + "item": { 3587 + "type": "boolean" 3588 + }, 3589 + "error": { 3590 + "type": ["string", "null"] 3591 + }, 3592 + "hasError": { 3593 + "type": "boolean", 3594 + "readOnly": true 3595 + }, 3596 + "data": { 3597 + "type": "object", 3598 + "properties": {}, 3599 + "additionalProperties": false 3600 + } 3601 + }, 3602 + "additionalProperties": false 3603 + }, 3604 + "Generic.Schema.Duplicate.Issue`1[System.String]": { 3605 + "type": "object", 3606 + "properties": { 3607 + "item": { 3608 + "type": ["string", "null"] 3609 + }, 3610 + "error": { 3611 + "type": ["string", "null"] 3612 + }, 3613 + "hasError": { 3614 + "type": "boolean", 3615 + "readOnly": true 3616 + } 3617 + }, 3618 + "additionalProperties": false 3619 + } 3620 + } 3621 + } 3622 + }
+68 -36
pnpm-lock.yaml
··· 568 568 typescript: 569 569 specifier: 5.5.3 570 570 version: 5.5.3 571 + zod: 572 + specifier: 3.23.8 573 + version: 3.23.8 571 574 572 575 packages: 573 576 ··· 8426 8429 dependencies: 8427 8430 '@ampproject/remapping': 2.3.0 8428 8431 '@angular-devkit/architect': 0.1703.7(chokidar@3.6.0) 8429 - '@angular-devkit/build-webpack': 0.1703.7(chokidar@3.6.0)(webpack-dev-server@4.15.1(webpack@5.90.3(esbuild@0.20.1)))(webpack@5.90.3(esbuild@0.20.1)) 8432 + '@angular-devkit/build-webpack': 0.1703.7(chokidar@3.6.0)(webpack-dev-server@4.15.1(webpack@5.90.3))(webpack@5.90.3(esbuild@0.20.1)) 8430 8433 '@angular-devkit/core': 17.3.7(chokidar@3.6.0) 8431 8434 '@angular/compiler-cli': 17.3.9(@angular/compiler@17.3.9(@angular/core@17.3.9(rxjs@7.8.1)(zone.js@0.14.7)))(typescript@5.5.3) 8432 8435 '@babel/core': 7.24.0 ··· 8484 8487 undici: 6.11.1 8485 8488 vite: 5.1.7(@types/node@20.14.10)(less@4.2.0)(sass@1.71.1)(terser@5.29.1) 8486 8489 watchpack: 2.4.0 8487 - webpack: 5.90.3(esbuild@0.23.1) 8490 + webpack: 5.90.3(esbuild@0.20.1) 8488 8491 webpack-dev-middleware: 6.1.2(webpack@5.90.3(esbuild@0.20.1)) 8489 - webpack-dev-server: 4.15.1(webpack@5.90.3(esbuild@0.20.1)) 8492 + webpack-dev-server: 4.15.1(webpack@5.90.3) 8490 8493 webpack-merge: 5.10.0 8491 8494 webpack-subresource-integrity: 5.1.0(webpack@5.90.3(esbuild@0.20.1)) 8492 8495 optionalDependencies: ··· 8511 8514 - utf-8-validate 8512 8515 - webpack-cli 8513 8516 8514 - '@angular-devkit/build-webpack@0.1703.7(chokidar@3.6.0)(webpack-dev-server@4.15.1(webpack@5.90.3(esbuild@0.20.1)))(webpack@5.90.3(esbuild@0.20.1))': 8517 + '@angular-devkit/build-webpack@0.1703.7(chokidar@3.6.0)(webpack-dev-server@4.15.1(webpack@5.90.3))(webpack@5.90.3(esbuild@0.20.1))': 8515 8518 dependencies: 8516 8519 '@angular-devkit/architect': 0.1703.7(chokidar@3.6.0) 8517 8520 rxjs: 7.8.1 8518 - webpack: 5.90.3(esbuild@0.23.1) 8519 - webpack-dev-server: 4.15.1(webpack@5.90.3(esbuild@0.20.1)) 8521 + webpack: 5.90.3(esbuild@0.20.1) 8522 + webpack-dev-server: 4.15.1(webpack@5.90.3) 8520 8523 transitivePeerDependencies: 8521 8524 - chokidar 8522 8525 ··· 10326 10329 dependencies: 10327 10330 '@angular/compiler-cli': 17.3.9(@angular/compiler@17.3.9(@angular/core@17.3.9(rxjs@7.8.1)(zone.js@0.14.7)))(typescript@5.5.3) 10328 10331 typescript: 5.5.3 10329 - webpack: 5.90.3(esbuild@0.23.1) 10332 + webpack: 5.90.3(esbuild@0.20.1) 10330 10333 10331 10334 '@nodelib/fs.scandir@2.1.5': 10332 10335 dependencies: ··· 12419 12422 '@babel/core': 7.24.0 12420 12423 find-cache-dir: 4.0.0 12421 12424 schema-utils: 4.2.0 12422 - webpack: 5.90.3(esbuild@0.23.1) 12425 + webpack: 5.90.3(esbuild@0.20.1) 12423 12426 12424 12427 babel-plugin-istanbul@6.1.1: 12425 12428 dependencies: ··· 12858 12861 normalize-path: 3.0.0 12859 12862 schema-utils: 4.2.0 12860 12863 serialize-javascript: 6.0.2 12861 - webpack: 5.90.3(esbuild@0.23.1) 12864 + webpack: 5.90.3(esbuild@0.20.1) 12862 12865 12863 12866 core-js-compat@3.37.1: 12864 12867 dependencies: ··· 12910 12913 postcss-value-parser: 4.2.0 12911 12914 semver: 7.6.2 12912 12915 optionalDependencies: 12913 - webpack: 5.90.3(esbuild@0.23.1) 12916 + webpack: 5.90.3(esbuild@0.20.1) 12914 12917 12915 12918 css-select@5.1.0: 12916 12919 dependencies: ··· 12923 12926 css-tree@2.3.1: 12924 12927 dependencies: 12925 12928 mdn-data: 2.0.30 12926 - source-map-js: 1.2.0 12929 + source-map-js: 1.2.1 12927 12930 12928 12931 css-what@6.1.0: {} 12929 12932 ··· 14331 14334 dependencies: 14332 14335 klona: 2.0.6 14333 14336 less: 4.2.0 14334 - webpack: 5.90.3(esbuild@0.23.1) 14337 + webpack: 5.90.3(esbuild@0.20.1) 14335 14338 14336 14339 less@4.2.0: 14337 14340 dependencies: ··· 14356 14359 dependencies: 14357 14360 webpack-sources: 3.2.3 14358 14361 optionalDependencies: 14359 - webpack: 5.90.3(esbuild@0.23.1) 14362 + webpack: 5.90.3(esbuild@0.20.1) 14360 14363 14361 14364 lilconfig@2.1.0: {} 14362 14365 ··· 14575 14578 dependencies: 14576 14579 schema-utils: 4.2.0 14577 14580 tapable: 2.2.1 14578 - webpack: 5.90.3(esbuild@0.23.1) 14581 + webpack: 5.90.3(esbuild@0.20.1) 14579 14582 14580 14583 minimalistic-assert@1.0.1: {} 14581 14584 ··· 15124 15127 read-cache: 1.0.0 15125 15128 resolve: 1.22.8 15126 15129 15130 + postcss-import@15.1.0(postcss@8.4.47): 15131 + dependencies: 15132 + postcss: 8.4.47 15133 + postcss-value-parser: 4.2.0 15134 + read-cache: 1.0.0 15135 + resolve: 1.22.8 15136 + optional: true 15137 + 15127 15138 postcss-js@4.0.1(postcss@8.4.39): 15128 15139 dependencies: 15129 15140 camelcase-css: 2.0.1 15130 15141 postcss: 8.4.39 15142 + 15143 + postcss-js@4.0.1(postcss@8.4.47): 15144 + dependencies: 15145 + camelcase-css: 2.0.1 15146 + postcss: 8.4.47 15147 + optional: true 15131 15148 15132 15149 postcss-load-config@3.1.4(postcss@8.4.39)(ts-node@10.9.2(@types/node@20.14.10)(typescript@5.5.3)): 15133 15150 dependencies: ··· 15153 15170 postcss: 8.4.39 15154 15171 ts-node: 10.9.2(@types/node@20.14.5)(typescript@5.5.3) 15155 15172 15173 + postcss-load-config@4.0.2(postcss@8.4.47)(ts-node@10.9.2(@types/node@20.14.10)(typescript@5.5.3)): 15174 + dependencies: 15175 + lilconfig: 3.1.2 15176 + yaml: 2.4.5 15177 + optionalDependencies: 15178 + postcss: 8.4.47 15179 + ts-node: 10.9.2(@types/node@20.14.10)(typescript@5.5.3) 15180 + optional: true 15181 + 15156 15182 postcss-load-config@6.0.1(jiti@2.3.1)(postcss@8.4.47)(tsx@4.19.1)(yaml@2.4.5): 15157 15183 dependencies: 15158 15184 lilconfig: 3.1.2 ··· 15169 15195 postcss: 8.4.35 15170 15196 semver: 7.6.2 15171 15197 optionalDependencies: 15172 - webpack: 5.90.3(esbuild@0.23.1) 15198 + webpack: 5.90.3(esbuild@0.20.1) 15173 15199 transitivePeerDependencies: 15174 15200 - typescript 15175 15201 ··· 15200 15226 dependencies: 15201 15227 postcss: 8.4.39 15202 15228 postcss-selector-parser: 6.1.0 15229 + 15230 + postcss-nested@6.0.1(postcss@8.4.47): 15231 + dependencies: 15232 + postcss: 8.4.47 15233 + postcss-selector-parser: 6.1.0 15234 + optional: true 15203 15235 15204 15236 postcss-safe-parser@6.0.0(postcss@8.4.39): 15205 15237 dependencies: ··· 15601 15633 neo-async: 2.6.2 15602 15634 optionalDependencies: 15603 15635 sass: 1.71.1 15604 - webpack: 5.90.3(esbuild@0.23.1) 15636 + webpack: 5.90.3(esbuild@0.20.1) 15605 15637 15606 15638 sass@1.71.1: 15607 15639 dependencies: ··· 15835 15867 dependencies: 15836 15868 iconv-lite: 0.6.3 15837 15869 source-map-js: 1.2.0 15838 - webpack: 5.90.3(esbuild@0.23.1) 15870 + webpack: 5.90.3(esbuild@0.20.1) 15839 15871 15840 15872 source-map-support@0.5.21: 15841 15873 dependencies: ··· 16059 16091 '@jridgewell/sourcemap-codec': 1.5.0 16060 16092 '@jridgewell/trace-mapping': 0.3.25 16061 16093 '@types/estree': 1.0.5 16062 - acorn: 8.12.0 16094 + acorn: 8.12.1 16063 16095 aria-query: 5.3.0 16064 16096 axobject-query: 4.1.0 16065 16097 code-red: 1.0.4 ··· 16125 16157 micromatch: 4.0.7 16126 16158 normalize-path: 3.0.0 16127 16159 object-hash: 3.0.0 16128 - picocolors: 1.0.1 16129 - postcss: 8.4.39 16130 - postcss-import: 15.1.0(postcss@8.4.39) 16131 - postcss-js: 4.0.1(postcss@8.4.39) 16132 - postcss-load-config: 4.0.2(postcss@8.4.39)(ts-node@10.9.2(@types/node@20.14.10)(typescript@5.5.3)) 16133 - postcss-nested: 6.0.1(postcss@8.4.39) 16160 + picocolors: 1.1.0 16161 + postcss: 8.4.47 16162 + postcss-import: 15.1.0(postcss@8.4.47) 16163 + postcss-js: 4.0.1(postcss@8.4.47) 16164 + postcss-load-config: 4.0.2(postcss@8.4.47)(ts-node@10.9.2(@types/node@20.14.10)(typescript@5.5.3)) 16165 + postcss-nested: 6.0.1(postcss@8.4.47) 16134 16166 postcss-selector-parser: 6.1.0 16135 16167 resolve: 1.22.8 16136 16168 sucrase: 3.35.0 ··· 16192 16224 16193 16225 term-size@2.2.1: {} 16194 16226 16195 - terser-webpack-plugin@5.3.10(esbuild@0.23.1)(webpack@5.90.3(esbuild@0.20.1)): 16227 + terser-webpack-plugin@5.3.10(esbuild@0.20.1)(webpack@5.90.3): 16196 16228 dependencies: 16197 16229 '@jridgewell/trace-mapping': 0.3.25 16198 16230 jest-worker: 27.5.1 16199 16231 schema-utils: 3.3.0 16200 16232 serialize-javascript: 6.0.2 16201 16233 terser: 5.29.1 16202 - webpack: 5.90.3(esbuild@0.23.1) 16234 + webpack: 5.90.3(esbuild@0.20.1) 16203 16235 optionalDependencies: 16204 - esbuild: 0.23.1 16236 + esbuild: 0.20.1 16205 16237 16206 16238 terser@5.29.1: 16207 16239 dependencies: ··· 16915 16947 16916 16948 webidl-conversions@7.0.0: {} 16917 16949 16918 - webpack-dev-middleware@5.3.4(webpack@5.90.3(esbuild@0.20.1)): 16950 + webpack-dev-middleware@5.3.4(webpack@5.90.3): 16919 16951 dependencies: 16920 16952 colorette: 2.0.20 16921 16953 memfs: 3.5.3 16922 16954 mime-types: 2.1.35 16923 16955 range-parser: 1.2.1 16924 16956 schema-utils: 4.2.0 16925 - webpack: 5.90.3(esbuild@0.23.1) 16957 + webpack: 5.90.3(esbuild@0.20.1) 16926 16958 16927 16959 webpack-dev-middleware@6.1.2(webpack@5.90.3(esbuild@0.20.1)): 16928 16960 dependencies: ··· 16932 16964 range-parser: 1.2.1 16933 16965 schema-utils: 4.2.0 16934 16966 optionalDependencies: 16935 - webpack: 5.90.3(esbuild@0.23.1) 16967 + webpack: 5.90.3(esbuild@0.20.1) 16936 16968 16937 - webpack-dev-server@4.15.1(webpack@5.90.3(esbuild@0.20.1)): 16969 + webpack-dev-server@4.15.1(webpack@5.90.3): 16938 16970 dependencies: 16939 16971 '@types/bonjour': 3.5.13 16940 16972 '@types/connect-history-api-fallback': 1.5.4 ··· 16964 16996 serve-index: 1.9.1 16965 16997 sockjs: 0.3.24 16966 16998 spdy: 4.0.2 16967 - webpack-dev-middleware: 5.3.4(webpack@5.90.3(esbuild@0.20.1)) 16999 + webpack-dev-middleware: 5.3.4(webpack@5.90.3) 16968 17000 ws: 8.17.1 16969 17001 optionalDependencies: 16970 - webpack: 5.90.3(esbuild@0.23.1) 17002 + webpack: 5.90.3(esbuild@0.20.1) 16971 17003 transitivePeerDependencies: 16972 17004 - bufferutil 16973 17005 - debug ··· 16985 17017 webpack-subresource-integrity@5.1.0(webpack@5.90.3(esbuild@0.20.1)): 16986 17018 dependencies: 16987 17019 typed-assert: 1.0.9 16988 - webpack: 5.90.3(esbuild@0.23.1) 17020 + webpack: 5.90.3(esbuild@0.20.1) 16989 17021 16990 - webpack@5.90.3(esbuild@0.23.1): 17022 + webpack@5.90.3(esbuild@0.20.1): 16991 17023 dependencies: 16992 17024 '@types/eslint-scope': 3.7.7 16993 17025 '@types/estree': 1.0.5 ··· 17010 17042 neo-async: 2.6.2 17011 17043 schema-utils: 3.3.0 17012 17044 tapable: 2.2.1 17013 - terser-webpack-plugin: 5.3.10(esbuild@0.23.1)(webpack@5.90.3(esbuild@0.20.1)) 17045 + terser-webpack-plugin: 5.3.10(esbuild@0.20.1)(webpack@5.90.3) 17014 17046 watchpack: 2.4.0 17015 17047 webpack-sources: 3.2.3 17016 17048 transitivePeerDependencies: