From 0a53a7c8b2e7214e58a5e4ffc45d479559430af9 Mon Sep 17 00:00:00 2001 From: Ro Ramtohul Date: Tue, 13 Feb 2024 11:04:04 +0000 Subject: [PATCH 1/2] feat(api): export SDK In some use cases, the SDK class needs to be instantiated several times. For instance, in a multi-tenancy scenario, there may be multiple instances of the same API server, but serving different data from different base URLs. In this case, we need to instantiate multiple clients with different server URLs. --- packages/api/src/codegen/languages/typescript/index.ts | 1 + packages/test-utils/sdks/alby/src/index.ts | 2 +- packages/test-utils/sdks/metrotransit/src/index.ts | 2 +- packages/test-utils/sdks/operationid-quirks/src/index.ts | 2 +- packages/test-utils/sdks/optional-payload/src/index.ts | 2 +- packages/test-utils/sdks/petstore/src/index.ts | 2 +- packages/test-utils/sdks/readme/src/index.ts | 2 +- packages/test-utils/sdks/response-title-quirks/src/index.ts | 2 +- packages/test-utils/sdks/simple/src/index.ts | 2 +- packages/test-utils/sdks/star-trek/src/index.ts | 2 +- 10 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/api/src/codegen/languages/typescript/index.ts b/packages/api/src/codegen/languages/typescript/index.ts index 06be2183..2ac76beb 100644 --- a/packages/api/src/codegen/languages/typescript/index.ts +++ b/packages/api/src/codegen/languages/typescript/index.ts @@ -302,6 +302,7 @@ export default class TSGenerator extends CodeGenerator { this.sdk = sourceFile.addClass({ name: 'SDK', properties: [{ name: 'core', type: 'APICore' }], + isExported: true, }); this.sdk.addConstructor({ diff --git a/packages/test-utils/sdks/alby/src/index.ts b/packages/test-utils/sdks/alby/src/index.ts index 8c589012..7ef16293 100644 --- a/packages/test-utils/sdks/alby/src/index.ts +++ b/packages/test-utils/sdks/alby/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@api/test-utils/definitions/alby.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/metrotransit/src/index.ts b/packages/test-utils/sdks/metrotransit/src/index.ts index 7e223df9..eaa6ddd6 100644 --- a/packages/test-utils/sdks/metrotransit/src/index.ts +++ b/packages/test-utils/sdks/metrotransit/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@api/test-utils/definitions/metrotransit.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/operationid-quirks/src/index.ts b/packages/test-utils/sdks/operationid-quirks/src/index.ts index ea1eab28..30917ff2 100644 --- a/packages/test-utils/sdks/operationid-quirks/src/index.ts +++ b/packages/test-utils/sdks/operationid-quirks/src/index.ts @@ -2,7 +2,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@api/test-utils/definitions/operationid-quirks.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/optional-payload/src/index.ts b/packages/test-utils/sdks/optional-payload/src/index.ts index b9a61b98..68fd8b17 100644 --- a/packages/test-utils/sdks/optional-payload/src/index.ts +++ b/packages/test-utils/sdks/optional-payload/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@api/test-utils/definitions/optional-payload.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/petstore/src/index.ts b/packages/test-utils/sdks/petstore/src/index.ts index 7fa46010..170aae4e 100644 --- a/packages/test-utils/sdks/petstore/src/index.ts +++ b/packages/test-utils/sdks/petstore/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@readme/oas-examples/3.0/json/petstore.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/readme/src/index.ts b/packages/test-utils/sdks/readme/src/index.ts index 7404db08..20a93779 100644 --- a/packages/test-utils/sdks/readme/src/index.ts +++ b/packages/test-utils/sdks/readme/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@readme/oas-examples/3.0/json/readme.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/response-title-quirks/src/index.ts b/packages/test-utils/sdks/response-title-quirks/src/index.ts index 2a1db243..9baf9188 100644 --- a/packages/test-utils/sdks/response-title-quirks/src/index.ts +++ b/packages/test-utils/sdks/response-title-quirks/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse, HTTPMethodRange } from '@readme/api- import APICore from '@readme/api-core'; import definition from '@api/test-utils/definitions/response-title-quirks.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/simple/src/index.ts b/packages/test-utils/sdks/simple/src/index.ts index 466df99e..d44b0679 100644 --- a/packages/test-utils/sdks/simple/src/index.ts +++ b/packages/test-utils/sdks/simple/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@api/test-utils/definitions/simple.json'; -class SDK { +export class SDK { core: APICore; constructor() { diff --git a/packages/test-utils/sdks/star-trek/src/index.ts b/packages/test-utils/sdks/star-trek/src/index.ts index 9a426234..e40890d4 100644 --- a/packages/test-utils/sdks/star-trek/src/index.ts +++ b/packages/test-utils/sdks/star-trek/src/index.ts @@ -3,7 +3,7 @@ import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; import APICore from '@readme/api-core'; import definition from '@readme/oas-examples/3.0/json/star-trek.json'; -class SDK { +export class SDK { core: APICore; constructor() { From 0740bbc04b2299e8ae01af17ca28f131058613ca Mon Sep 17 00:00:00 2001 From: Ro Ramtohul Date: Wed, 14 Feb 2024 11:54:39 +0000 Subject: [PATCH 2/2] fix(api): export sdk in a separate file --- .../src/codegen/languages/typescript/index.ts | 29 +- packages/test-utils/sdks/alby/package.json | 5 + packages/test-utils/sdks/alby/src/index.ts | 382 +----- packages/test-utils/sdks/alby/src/sdk.ts | 381 ++++++ .../test-utils/sdks/metrotransit/package.json | 5 + .../test-utils/sdks/metrotransit/src/index.ts | 108 +- .../test-utils/sdks/metrotransit/src/sdk.ts | 107 ++ .../sdks/operationid-quirks/package.json | 7 +- .../sdks/operationid-quirks/src/index.ts | 108 +- .../sdks/operationid-quirks/src/sdk.ts | 107 ++ .../sdks/optional-payload/package.json | 5 + .../sdks/optional-payload/src/index.ts | 83 +- .../sdks/optional-payload/src/sdk.ts | 82 ++ .../test-utils/sdks/petstore/package.json | 5 + .../test-utils/sdks/petstore/src/index.ts | 249 +--- packages/test-utils/sdks/petstore/src/sdk.ts | 248 ++++ packages/test-utils/sdks/readme/package.json | 5 + packages/test-utils/sdks/readme/src/index.ts | 478 +------- packages/test-utils/sdks/readme/src/sdk.ts | 477 ++++++++ .../sdks/response-title-quirks/package.json | 5 + .../sdks/response-title-quirks/src/index.ts | 77 +- .../sdks/response-title-quirks/src/sdk.ts | 76 ++ packages/test-utils/sdks/simple/package.json | 5 + packages/test-utils/sdks/simple/src/index.ts | 82 +- packages/test-utils/sdks/simple/src/sdk.ts | 81 ++ .../test-utils/sdks/star-trek/package.json | 5 + .../test-utils/sdks/star-trek/src/index.ts | 1033 +---------------- packages/test-utils/sdks/star-trek/src/sdk.ts | 1032 ++++++++++++++++ 28 files changed, 2672 insertions(+), 2595 deletions(-) create mode 100644 packages/test-utils/sdks/alby/src/sdk.ts create mode 100644 packages/test-utils/sdks/metrotransit/src/sdk.ts create mode 100644 packages/test-utils/sdks/operationid-quirks/src/sdk.ts create mode 100644 packages/test-utils/sdks/optional-payload/src/sdk.ts create mode 100644 packages/test-utils/sdks/petstore/src/sdk.ts create mode 100644 packages/test-utils/sdks/readme/src/sdk.ts create mode 100644 packages/test-utils/sdks/response-title-quirks/src/sdk.ts create mode 100644 packages/test-utils/sdks/simple/src/sdk.ts create mode 100644 packages/test-utils/sdks/star-trek/src/sdk.ts diff --git a/packages/api/src/codegen/languages/typescript/index.ts b/packages/api/src/codegen/languages/typescript/index.ts index 2ac76beb..beb779f8 100644 --- a/packages/api/src/codegen/languages/typescript/index.ts +++ b/packages/api/src/codegen/languages/typescript/index.ts @@ -210,6 +210,7 @@ export default class TSGenerator extends CodeGenerator { async generate() { const srcDirectory = this.project.createDirectory('src'); const sdkSource = this.createSDKSource(srcDirectory); + this.createIndexSource(srcDirectory); this.createGitIgnore(); this.createPackageJSON(); @@ -278,6 +279,24 @@ export default class TSGenerator extends CodeGenerator { return snippet; } + /** + * Create our main `index.ts` file that will be the entrypoint for our SDK. + * This file will be used to export the SDK and any types that are generated. + * + */ + private createIndexSource(sourceDirectory: Directory) { + const sourceFile = sourceDirectory.createSourceFile('index.ts', ''); + + sourceFile.addImportDeclaration({ + defaultImport: 'SDK', + moduleSpecifier: './sdk.js', + }); + + this.createSDKExport(sourceFile); + + return sourceFile; + } + /** * Create our main SDK source file. * @@ -285,7 +304,7 @@ export default class TSGenerator extends CodeGenerator { private createSDKSource(sourceDirectory: Directory) { const { operations } = this.loadOperationsAndMethods(); - const sourceFile = sourceDirectory.createSourceFile('index.ts', ''); + const sourceFile = sourceDirectory.createSourceFile('sdk.ts', ''); sourceFile.addImportDeclarations([ // This import will be automatically removed later if the SDK ends up not having any types. @@ -302,6 +321,7 @@ export default class TSGenerator extends CodeGenerator { this.sdk = sourceFile.addClass({ name: 'SDK', properties: [{ name: 'core', type: 'APICore' }], + isDefaultExport: true, isExported: true, }); @@ -406,8 +426,6 @@ sdk.server('https://eu.api.example.com/v14');`), this.createOperationAccessor(data.operation, operationId, data.types.params, data.types.responses); }); - this.createSDKExport(sourceFile); - return sourceFile; } @@ -596,6 +614,7 @@ dist/ dts: true, entry: [ './src/index.ts', + './src/sdk.ts', // If this SDK has schemas and generated types then we should also export those too so // they're available to use. hasTypes ? './src/types.ts' : '', @@ -627,6 +646,10 @@ dist/ import: './dist/index.js', require: './dist/index.cjs', }, + './sdk': { + import: './dist/sdk.js', + require: './dist/sdk.cjs', + }, ...(hasTypes ? { './types': { diff --git a/packages/test-utils/sdks/alby/package.json b/packages/test-utils/sdks/alby/package.json index 4ea18278..bdf3b741 100644 --- a/packages/test-utils/sdks/alby/package.json +++ b/packages/test-utils/sdks/alby/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -36,6 +40,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/alby/src/index.ts b/packages/test-utils/sdks/alby/src/index.ts index 7ef16293..0c8ed372 100644 --- a/packages/test-utils/sdks/alby/src/index.ts +++ b/packages/test-utils/sdks/alby/src/index.ts @@ -1,384 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@api/test-utils/definitions/alby.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'alby/1.0.14 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** - * List all applications for the specified account ID. - * - * @summary Lists apps - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> Account not found - * @throws FetchError<500, types.Error> Internal server error - */ - getAccountsAccount_idApps(metadata: types.GetAccountsAccountIdAppsMetadataParam): Promise> { - return this.core.fetch('/accounts/{account_id}/apps', 'get', metadata); - } - - /** - * Creates an application with the specified properties. - * - * @summary Creates an app - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> Account not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - */ - postAccountsAccount_idApps(body: types.AppPost, metadata: types.PostAccountsAccountIdAppsMetadataParam): Promise> { - return this.core.fetch('/accounts/{account_id}/apps', 'post', body, metadata); - } - - /** - * Lists the API keys associated with the application ID. - * - * @summary Lists app keys - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - getAppsApp_idKeys(metadata: types.GetAppsAppIdKeysMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/keys', 'get', metadata); - } - - /** - * Creates an API key for the application specified. - * - * @summary Creates a key - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - */ - postAppsApp_idKeys(body: types.KeyPost, metadata: types.PostAppsAppIdKeysMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/keys', 'post', body, metadata); - } - - /** - * Update the API key with the specified key ID, for the application with the specified - * application ID. - * - * @summary Updates a key - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - patchAppsApp_idKeysKey_id(body: types.KeyPatch, metadata: types.PatchAppsAppIdKeysKeyIdMetadataParam): Promise>; - patchAppsApp_idKeysKey_id(metadata: types.PatchAppsAppIdKeysKeyIdMetadataParam): Promise>; - patchAppsApp_idKeysKey_id(body?: types.KeyPatch | types.PatchAppsAppIdKeysKeyIdMetadataParam, metadata?: types.PatchAppsAppIdKeysKeyIdMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/keys/{key_id}', 'patch', body, metadata); - } - - /** - * Revokes the API key with the specified ID, with the Application ID. This deletes the - * key. - * - * @summary Revokes a key - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> Not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - postAppsApp_idKeysKey_idRevoke(metadata: types.PostAppsAppIdKeysKeyIdRevokeMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/keys/{key_id}/revoke', 'post', metadata); - } - - /** - * List the namespaces for the specified application ID. - * - * @summary Lists namespaces - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - getAppsApp_idNamespaces(metadata: types.GetAppsAppIdNamespacesMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/namespaces', 'get', metadata); - } - - /** - * Creates a namespace for the specified application ID. - * - * @summary Creates a namespace - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - */ - postAppsApp_idNamespaces(body: types.NamespacePost, metadata: types.PostAppsAppIdNamespacesMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/namespaces', 'post', body, metadata); - } - - /** - * Deletes the namespace with the specified ID, for the specified application ID. - * - * @summary Deletes a namespace - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> Not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - deleteAppsApp_idNamespacesNamespace_id(metadata: types.DeleteAppsAppIdNamespacesNamespaceIdMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/namespaces/{namespace_id}', 'delete', metadata); - } - - /** - * Updates the namespace with the specified ID, for the application with the specified - * application ID. - * - * @summary Updates a namespace - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> Not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - patchAppsApp_idNamespacesNamespace_id(body: types.NamespacePatch, metadata: types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam): Promise>; - patchAppsApp_idNamespacesNamespace_id(metadata: types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam): Promise>; - patchAppsApp_idNamespacesNamespace_id(body?: types.NamespacePatch | types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam, metadata?: types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/namespaces/{namespace_id}', 'patch', body, metadata); - } - - /** - * Lists the queues associated with the specified application ID. - * - * @summary Lists queues - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<503, types.Error> 503 Service unavailable - * @throws FetchError<504, types.Error> Gateway timeout - */ - getAppsApp_idQueues(metadata: types.GetAppsAppIdQueuesMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/queues', 'get', metadata); - } - - /** - * Creates a queue for the application specified by application ID. The properties for the - * queue to be created are specified in the request body. - * - * @summary Creates a queue - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - */ - postAppsApp_idQueues(body: types.Queue, metadata: types.PostAppsAppIdQueuesMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/queues', 'post', body, metadata); - } - - /** - * Delete the queue with the specified queue name, from the application with the specified - * application ID. - * - * @summary Deletes a queue - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<503, types.Error> 503 Service unavailable - */ - deleteAppsApp_idQueuesQueue_id(metadata: types.DeleteAppsAppIdQueuesQueueIdMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/queues/{queue_id}', 'delete', metadata); - } - - /** - * Lists the rules for the application specified by the application ID. - * - * @summary Lists Reactor rules - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - getAppsApp_idRules(metadata: types.GetAppsAppIdRulesMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/rules', 'get', metadata); - } - - /** - * Creates a rule for the application with the specified application ID. - * - * @summary Creates a Reactor rule - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - postAppsApp_idRules(body: types.RulePost, metadata: types.PostAppsAppIdRulesMetadataParam): Promise>; - postAppsApp_idRules(metadata: types.PostAppsAppIdRulesMetadataParam): Promise>; - postAppsApp_idRules(body?: types.RulePost | types.PostAppsAppIdRulesMetadataParam, metadata?: types.PostAppsAppIdRulesMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/rules', 'post', body, metadata); - } - - /** - * Deletes a Reactor rule - * - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - deleteAppsApp_idRulesRule_id(metadata: types.DeleteAppsAppIdRulesRuleIdMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/rules/{rule_id}', 'delete', metadata); - } - - /** - * Returns the rule specified by the rule ID, for the application specified by application - * ID. - * - * @summary Gets a reactor rule by rule ID - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> Not found - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - getAppsApp_idRulesRule_id(metadata: types.GetAppsAppIdRulesRuleIdMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/rules/{rule_id}', 'get', metadata); - } - - /** - * Updates a Reactor rule - * - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - * @throws FetchError<504, types.Error> Gateway timeout - */ - patchAppsApp_idRulesRule_id(body: types.RulePatch, metadata: types.PatchAppsAppIdRulesRuleIdMetadataParam): Promise>; - patchAppsApp_idRulesRule_id(metadata: types.PatchAppsAppIdRulesRuleIdMetadataParam): Promise>; - patchAppsApp_idRulesRule_id(body?: types.RulePatch | types.PatchAppsAppIdRulesRuleIdMetadataParam, metadata?: types.PatchAppsAppIdRulesRuleIdMetadataParam): Promise> { - return this.core.fetch('/apps/{app_id}/rules/{rule_id}', 'patch', body, metadata); - } - - /** - * Deletes the application with the specified application ID. - * - * @summary Deletes an app - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<422, types.Error> Invalid request - * @throws FetchError<500, types.Error> Internal server error - */ - deleteAppsId(metadata: types.DeleteAppsIdMetadataParam): Promise> { - return this.core.fetch('/apps/{id}', 'delete', metadata); - } - - /** - * Updates the application with the specified application ID. - * - * @summary Updates an app - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - */ - patchAppsId(body: types.AppPatch, metadata: types.PatchAppsIdMetadataParam): Promise>; - patchAppsId(metadata: types.PatchAppsIdMetadataParam): Promise>; - patchAppsId(body?: types.AppPatch | types.PatchAppsIdMetadataParam, metadata?: types.PatchAppsIdMetadataParam): Promise> { - return this.core.fetch('/apps/{id}', 'patch', body, metadata); - } - - /** - * Updates the application's Apple Push Notification service (APNs) information. - * - * @summary Updates app's APNs info from a `.p12` file - * @throws FetchError<400, types.Error> Bad request - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<404, types.Error> App not found - * @throws FetchError<500, types.Error> Internal server error - */ - postAppsIdPkcs12(body: types.AppPkcs12, metadata: types.PostAppsIdPkcs12MetadataParam): Promise> { - return this.core.fetch('/apps/{id}/pkcs12', 'post', body, metadata); - } - - /** - * Get token details - * - * @throws FetchError<401, types.Error> Authentication failed - * @throws FetchError<500, types.Error> Internal server error - */ - getMe(): Promise> { - return this.core.fetch('/me', 'get'); - } -} +import SDK from './sdk.js'; /** * Control API v1 diff --git a/packages/test-utils/sdks/alby/src/sdk.ts b/packages/test-utils/sdks/alby/src/sdk.ts new file mode 100644 index 00000000..27d037d0 --- /dev/null +++ b/packages/test-utils/sdks/alby/src/sdk.ts @@ -0,0 +1,381 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@api/test-utils/definitions/alby.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'alby/1.0.14 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** + * List all applications for the specified account ID. + * + * @summary Lists apps + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> Account not found + * @throws FetchError<500, types.Error> Internal server error + */ + getAccountsAccount_idApps(metadata: types.GetAccountsAccountIdAppsMetadataParam): Promise> { + return this.core.fetch('/accounts/{account_id}/apps', 'get', metadata); + } + + /** + * Creates an application with the specified properties. + * + * @summary Creates an app + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> Account not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + */ + postAccountsAccount_idApps(body: types.AppPost, metadata: types.PostAccountsAccountIdAppsMetadataParam): Promise> { + return this.core.fetch('/accounts/{account_id}/apps', 'post', body, metadata); + } + + /** + * Lists the API keys associated with the application ID. + * + * @summary Lists app keys + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + getAppsApp_idKeys(metadata: types.GetAppsAppIdKeysMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/keys', 'get', metadata); + } + + /** + * Creates an API key for the application specified. + * + * @summary Creates a key + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + */ + postAppsApp_idKeys(body: types.KeyPost, metadata: types.PostAppsAppIdKeysMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/keys', 'post', body, metadata); + } + + /** + * Update the API key with the specified key ID, for the application with the specified + * application ID. + * + * @summary Updates a key + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + patchAppsApp_idKeysKey_id(body: types.KeyPatch, metadata: types.PatchAppsAppIdKeysKeyIdMetadataParam): Promise>; + patchAppsApp_idKeysKey_id(metadata: types.PatchAppsAppIdKeysKeyIdMetadataParam): Promise>; + patchAppsApp_idKeysKey_id(body?: types.KeyPatch | types.PatchAppsAppIdKeysKeyIdMetadataParam, metadata?: types.PatchAppsAppIdKeysKeyIdMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/keys/{key_id}', 'patch', body, metadata); + } + + /** + * Revokes the API key with the specified ID, with the Application ID. This deletes the + * key. + * + * @summary Revokes a key + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> Not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + postAppsApp_idKeysKey_idRevoke(metadata: types.PostAppsAppIdKeysKeyIdRevokeMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/keys/{key_id}/revoke', 'post', metadata); + } + + /** + * List the namespaces for the specified application ID. + * + * @summary Lists namespaces + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + getAppsApp_idNamespaces(metadata: types.GetAppsAppIdNamespacesMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/namespaces', 'get', metadata); + } + + /** + * Creates a namespace for the specified application ID. + * + * @summary Creates a namespace + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + */ + postAppsApp_idNamespaces(body: types.NamespacePost, metadata: types.PostAppsAppIdNamespacesMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/namespaces', 'post', body, metadata); + } + + /** + * Deletes the namespace with the specified ID, for the specified application ID. + * + * @summary Deletes a namespace + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> Not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + deleteAppsApp_idNamespacesNamespace_id(metadata: types.DeleteAppsAppIdNamespacesNamespaceIdMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/namespaces/{namespace_id}', 'delete', metadata); + } + + /** + * Updates the namespace with the specified ID, for the application with the specified + * application ID. + * + * @summary Updates a namespace + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> Not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + patchAppsApp_idNamespacesNamespace_id(body: types.NamespacePatch, metadata: types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam): Promise>; + patchAppsApp_idNamespacesNamespace_id(metadata: types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam): Promise>; + patchAppsApp_idNamespacesNamespace_id(body?: types.NamespacePatch | types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam, metadata?: types.PatchAppsAppIdNamespacesNamespaceIdMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/namespaces/{namespace_id}', 'patch', body, metadata); + } + + /** + * Lists the queues associated with the specified application ID. + * + * @summary Lists queues + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<503, types.Error> 503 Service unavailable + * @throws FetchError<504, types.Error> Gateway timeout + */ + getAppsApp_idQueues(metadata: types.GetAppsAppIdQueuesMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/queues', 'get', metadata); + } + + /** + * Creates a queue for the application specified by application ID. The properties for the + * queue to be created are specified in the request body. + * + * @summary Creates a queue + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + */ + postAppsApp_idQueues(body: types.Queue, metadata: types.PostAppsAppIdQueuesMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/queues', 'post', body, metadata); + } + + /** + * Delete the queue with the specified queue name, from the application with the specified + * application ID. + * + * @summary Deletes a queue + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<503, types.Error> 503 Service unavailable + */ + deleteAppsApp_idQueuesQueue_id(metadata: types.DeleteAppsAppIdQueuesQueueIdMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/queues/{queue_id}', 'delete', metadata); + } + + /** + * Lists the rules for the application specified by the application ID. + * + * @summary Lists Reactor rules + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + getAppsApp_idRules(metadata: types.GetAppsAppIdRulesMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/rules', 'get', metadata); + } + + /** + * Creates a rule for the application with the specified application ID. + * + * @summary Creates a Reactor rule + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + postAppsApp_idRules(body: types.RulePost, metadata: types.PostAppsAppIdRulesMetadataParam): Promise>; + postAppsApp_idRules(metadata: types.PostAppsAppIdRulesMetadataParam): Promise>; + postAppsApp_idRules(body?: types.RulePost | types.PostAppsAppIdRulesMetadataParam, metadata?: types.PostAppsAppIdRulesMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/rules', 'post', body, metadata); + } + + /** + * Deletes a Reactor rule + * + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + deleteAppsApp_idRulesRule_id(metadata: types.DeleteAppsAppIdRulesRuleIdMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/rules/{rule_id}', 'delete', metadata); + } + + /** + * Returns the rule specified by the rule ID, for the application specified by application + * ID. + * + * @summary Gets a reactor rule by rule ID + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> Not found + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + getAppsApp_idRulesRule_id(metadata: types.GetAppsAppIdRulesRuleIdMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/rules/{rule_id}', 'get', metadata); + } + + /** + * Updates a Reactor rule + * + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + * @throws FetchError<504, types.Error> Gateway timeout + */ + patchAppsApp_idRulesRule_id(body: types.RulePatch, metadata: types.PatchAppsAppIdRulesRuleIdMetadataParam): Promise>; + patchAppsApp_idRulesRule_id(metadata: types.PatchAppsAppIdRulesRuleIdMetadataParam): Promise>; + patchAppsApp_idRulesRule_id(body?: types.RulePatch | types.PatchAppsAppIdRulesRuleIdMetadataParam, metadata?: types.PatchAppsAppIdRulesRuleIdMetadataParam): Promise> { + return this.core.fetch('/apps/{app_id}/rules/{rule_id}', 'patch', body, metadata); + } + + /** + * Deletes the application with the specified application ID. + * + * @summary Deletes an app + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<422, types.Error> Invalid request + * @throws FetchError<500, types.Error> Internal server error + */ + deleteAppsId(metadata: types.DeleteAppsIdMetadataParam): Promise> { + return this.core.fetch('/apps/{id}', 'delete', metadata); + } + + /** + * Updates the application with the specified application ID. + * + * @summary Updates an app + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + */ + patchAppsId(body: types.AppPatch, metadata: types.PatchAppsIdMetadataParam): Promise>; + patchAppsId(metadata: types.PatchAppsIdMetadataParam): Promise>; + patchAppsId(body?: types.AppPatch | types.PatchAppsIdMetadataParam, metadata?: types.PatchAppsIdMetadataParam): Promise> { + return this.core.fetch('/apps/{id}', 'patch', body, metadata); + } + + /** + * Updates the application's Apple Push Notification service (APNs) information. + * + * @summary Updates app's APNs info from a `.p12` file + * @throws FetchError<400, types.Error> Bad request + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<404, types.Error> App not found + * @throws FetchError<500, types.Error> Internal server error + */ + postAppsIdPkcs12(body: types.AppPkcs12, metadata: types.PostAppsIdPkcs12MetadataParam): Promise> { + return this.core.fetch('/apps/{id}/pkcs12', 'post', body, metadata); + } + + /** + * Get token details + * + * @throws FetchError<401, types.Error> Authentication failed + * @throws FetchError<500, types.Error> Internal server error + */ + getMe(): Promise> { + return this.core.fetch('/me', 'get'); + } +} diff --git a/packages/test-utils/sdks/metrotransit/package.json b/packages/test-utils/sdks/metrotransit/package.json index cbc69a52..12da217c 100644 --- a/packages/test-utils/sdks/metrotransit/package.json +++ b/packages/test-utils/sdks/metrotransit/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -36,6 +40,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/metrotransit/src/index.ts b/packages/test-utils/sdks/metrotransit/src/index.ts index eaa6ddd6..f900e5a4 100644 --- a/packages/test-utils/sdks/metrotransit/src/index.ts +++ b/packages/test-utils/sdks/metrotransit/src/index.ts @@ -1,110 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@api/test-utils/definitions/metrotransit.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'metrotransit/2 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** @throws FetchError<400, types.ProblemDetails> Bad Request */ - getNextripAgencies(): Promise> { - return this.core.fetch('/nextrip/agencies', 'get'); - } - - /** @throws FetchError<400, types.ProblemDetails> Bad Request */ - getNextripRoutes(): Promise> { - return this.core.fetch('/nextrip/routes', 'get'); - } - - /** @throws FetchError<400, types.ProblemDetails> Bad Request */ - getNextripDirectionsRoute_id(metadata: types.GetNextripDirectionsRouteIdMetadataParam): Promise> { - return this.core.fetch('/nextrip/directions/{route_id}', 'get', metadata); - } - - /** @throws FetchError<400, types.ProblemDetails> Bad Request */ - getNextripStopsRoute_idDirection_id(metadata: types.GetNextripStopsRouteIdDirectionIdMetadataParam): Promise> { - return this.core.fetch('/nextrip/stops/{route_id}/{direction_id}', 'get', metadata); - } - - /** @throws FetchError<400, types.ProblemDetails> Bad Request */ - getNextripStop_id(metadata: types.GetNextripStopIdMetadataParam): Promise> { - return this.core.fetch('/nextrip/{stop_id}', 'get', metadata); - } - - /** @throws FetchError<400, types.ProblemDetails> Bad Request */ - getNextripRoute_idDirection_idPlace_code(metadata: types.GetNextripRouteIdDirectionIdPlaceCodeMetadataParam): Promise> { - return this.core.fetch('/nextrip/{route_id}/{direction_id}/{place_code}', 'get', metadata); - } - - /** @throws FetchError<400, types.ProblemDetails> Bad Request */ - getNextripVehiclesRoute_id(metadata: types.GetNextripVehiclesRouteIdMetadataParam): Promise> { - return this.core.fetch('/nextrip/vehicles/{route_id}', 'get', metadata); - } -} +import SDK from './sdk.js'; /** * NexTrip API diff --git a/packages/test-utils/sdks/metrotransit/src/sdk.ts b/packages/test-utils/sdks/metrotransit/src/sdk.ts new file mode 100644 index 00000000..65fe54ef --- /dev/null +++ b/packages/test-utils/sdks/metrotransit/src/sdk.ts @@ -0,0 +1,107 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@api/test-utils/definitions/metrotransit.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'metrotransit/2 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** @throws FetchError<400, types.ProblemDetails> Bad Request */ + getNextripAgencies(): Promise> { + return this.core.fetch('/nextrip/agencies', 'get'); + } + + /** @throws FetchError<400, types.ProblemDetails> Bad Request */ + getNextripRoutes(): Promise> { + return this.core.fetch('/nextrip/routes', 'get'); + } + + /** @throws FetchError<400, types.ProblemDetails> Bad Request */ + getNextripDirectionsRoute_id(metadata: types.GetNextripDirectionsRouteIdMetadataParam): Promise> { + return this.core.fetch('/nextrip/directions/{route_id}', 'get', metadata); + } + + /** @throws FetchError<400, types.ProblemDetails> Bad Request */ + getNextripStopsRoute_idDirection_id(metadata: types.GetNextripStopsRouteIdDirectionIdMetadataParam): Promise> { + return this.core.fetch('/nextrip/stops/{route_id}/{direction_id}', 'get', metadata); + } + + /** @throws FetchError<400, types.ProblemDetails> Bad Request */ + getNextripStop_id(metadata: types.GetNextripStopIdMetadataParam): Promise> { + return this.core.fetch('/nextrip/{stop_id}', 'get', metadata); + } + + /** @throws FetchError<400, types.ProblemDetails> Bad Request */ + getNextripRoute_idDirection_idPlace_code(metadata: types.GetNextripRouteIdDirectionIdPlaceCodeMetadataParam): Promise> { + return this.core.fetch('/nextrip/{route_id}/{direction_id}/{place_code}', 'get', metadata); + } + + /** @throws FetchError<400, types.ProblemDetails> Bad Request */ + getNextripVehiclesRoute_id(metadata: types.GetNextripVehiclesRouteIdMetadataParam): Promise> { + return this.core.fetch('/nextrip/vehicles/{route_id}', 'get', metadata); + } +} diff --git a/packages/test-utils/sdks/operationid-quirks/package.json b/packages/test-utils/sdks/operationid-quirks/package.json index 2bc4252d..fdabd474 100644 --- a/packages/test-utils/sdks/operationid-quirks/package.json +++ b/packages/test-utils/sdks/operationid-quirks/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./package.json": "./package.json" }, "files": [ @@ -31,7 +35,8 @@ "clean": true, "dts": true, "entry": [ - "./src/index.ts" + "./src/index.ts", + "./src/sdk.ts" ], "format": [ "esm", diff --git a/packages/test-utils/sdks/operationid-quirks/src/index.ts b/packages/test-utils/sdks/operationid-quirks/src/index.ts index 30917ff2..930c46bf 100644 --- a/packages/test-utils/sdks/operationid-quirks/src/index.ts +++ b/packages/test-utils/sdks/operationid-quirks/src/index.ts @@ -1,110 +1,4 @@ -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@api/test-utils/definitions/operationid-quirks.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'operationid-quirks/1.0.0 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** - * This mess of a string is intentionally nasty so we can be sure that we're not including - * anything that wouldn't look right as an operationID for a potential method accessor in - * `api`. - * - */ - quirky_OperationId_string(): Promise> { - return this.core.fetch('/quirky-operationId', 'get'); - } - - /** - * This operation doesn't have an `operationId` so we should create one. - * - */ - getNoOperationId(): Promise> { - return this.core.fetch('/no-operation-id', 'get'); - } - - /** - * This operation has no `operationId` but because path starts with an HTTP method when we - * generate an `operationId` that has `get` doubled. - * - */ - getOperationPathStartsWithAnHttpMethod(): Promise> { - return this.core.fetch('/get-operation-path-starts-with-an-http-method', 'get'); - } - - /** - * This operation has an `operationId` with hypens yet it should still be accessible in the - * dynamic `api` flow. - * - */ - hyphenatedOperationId(): Promise> { - return this.core.fetch('/hyphenated-operation-id', 'get'); - } -} +import SDK from './sdk.js'; /** * Quirky `operationID` cases diff --git a/packages/test-utils/sdks/operationid-quirks/src/sdk.ts b/packages/test-utils/sdks/operationid-quirks/src/sdk.ts new file mode 100644 index 00000000..46409041 --- /dev/null +++ b/packages/test-utils/sdks/operationid-quirks/src/sdk.ts @@ -0,0 +1,107 @@ +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@api/test-utils/definitions/operationid-quirks.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'operationid-quirks/1.0.0 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** + * This mess of a string is intentionally nasty so we can be sure that we're not including + * anything that wouldn't look right as an operationID for a potential method accessor in + * `api`. + * + */ + quirky_OperationId_string(): Promise> { + return this.core.fetch('/quirky-operationId', 'get'); + } + + /** + * This operation doesn't have an `operationId` so we should create one. + * + */ + getNoOperationId(): Promise> { + return this.core.fetch('/no-operation-id', 'get'); + } + + /** + * This operation has no `operationId` but because path starts with an HTTP method when we + * generate an `operationId` that has `get` doubled. + * + */ + getOperationPathStartsWithAnHttpMethod(): Promise> { + return this.core.fetch('/get-operation-path-starts-with-an-http-method', 'get'); + } + + /** + * This operation has an `operationId` with hypens yet it should still be accessible in the + * dynamic `api` flow. + * + */ + hyphenatedOperationId(): Promise> { + return this.core.fetch('/hyphenated-operation-id', 'get'); + } +} diff --git a/packages/test-utils/sdks/optional-payload/package.json b/packages/test-utils/sdks/optional-payload/package.json index 5e84cb10..807a366c 100644 --- a/packages/test-utils/sdks/optional-payload/package.json +++ b/packages/test-utils/sdks/optional-payload/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -36,6 +40,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/optional-payload/src/index.ts b/packages/test-utils/sdks/optional-payload/src/index.ts index 68fd8b17..034818a1 100644 --- a/packages/test-utils/sdks/optional-payload/src/index.ts +++ b/packages/test-utils/sdks/optional-payload/src/index.ts @@ -1,85 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@api/test-utils/definitions/optional-payload.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'optional-payload/1.0.0 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** - * Updates a pet in the store with form data - * - */ - updatePetWithForm(body: types.UpdatePetWithFormFormDataParam, metadata: types.UpdatePetWithFormMetadataParam): Promise>; - updatePetWithForm(metadata: types.UpdatePetWithFormMetadataParam): Promise>; - updatePetWithForm(body?: types.UpdatePetWithFormFormDataParam | types.UpdatePetWithFormMetadataParam, metadata?: types.UpdatePetWithFormMetadataParam): Promise> { - return this.core.fetch('/pet/{petId}', 'post', body, metadata); - } -} +import SDK from './sdk.js'; /** * Example API with a requestBody payload that's optional. diff --git a/packages/test-utils/sdks/optional-payload/src/sdk.ts b/packages/test-utils/sdks/optional-payload/src/sdk.ts new file mode 100644 index 00000000..771a126b --- /dev/null +++ b/packages/test-utils/sdks/optional-payload/src/sdk.ts @@ -0,0 +1,82 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@api/test-utils/definitions/optional-payload.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'optional-payload/1.0.0 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** + * Updates a pet in the store with form data + * + */ + updatePetWithForm(body: types.UpdatePetWithFormFormDataParam, metadata: types.UpdatePetWithFormMetadataParam): Promise>; + updatePetWithForm(metadata: types.UpdatePetWithFormMetadataParam): Promise>; + updatePetWithForm(body?: types.UpdatePetWithFormFormDataParam | types.UpdatePetWithFormMetadataParam, metadata?: types.UpdatePetWithFormMetadataParam): Promise> { + return this.core.fetch('/pet/{petId}', 'post', body, metadata); + } +} diff --git a/packages/test-utils/sdks/petstore/package.json b/packages/test-utils/sdks/petstore/package.json index f054d3fc..c316c3ba 100644 --- a/packages/test-utils/sdks/petstore/package.json +++ b/packages/test-utils/sdks/petstore/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -37,6 +41,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/petstore/src/index.ts b/packages/test-utils/sdks/petstore/src/index.ts index 170aae4e..d9df27f4 100644 --- a/packages/test-utils/sdks/petstore/src/index.ts +++ b/packages/test-utils/sdks/petstore/src/index.ts @@ -1,251 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@readme/oas-examples/3.0/json/petstore.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'petstore/1.0.0 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** - * Add a new pet to the store - * - */ - addPet(body: types.Pet): Promise> { - return this.core.fetch('/pet', 'post', body); - } - - /** - * Update an existing pet - * - */ - updatePet(body: types.Pet): Promise> { - return this.core.fetch('/pet', 'put', body); - } - - /** - * Multiple status values can be provided with comma separated strings - * - * @summary Finds Pets by status - */ - findPetsByStatus(metadata: types.FindPetsByStatusMetadataParam): Promise> { - return this.core.fetch('/pet/findByStatus', 'get', metadata); - } - - /** - * Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for - * testing. - * - * @summary Finds Pets by tags - */ - findPetsByTags(metadata: types.FindPetsByTagsMetadataParam): Promise> { - return this.core.fetch('/pet/findByTags', 'get', metadata); - } - - /** - * Returns a single pet - * - * @summary Find pet by ID - */ - getPetById(metadata: types.GetPetByIdMetadataParam): Promise> { - return this.core.fetch('/pet/{petId}', 'get', metadata); - } - - /** - * Updates a pet in the store with form data - * - */ - updatePetWithForm(body: types.UpdatePetWithFormFormDataParam, metadata: types.UpdatePetWithFormMetadataParam): Promise>; - updatePetWithForm(metadata: types.UpdatePetWithFormMetadataParam): Promise>; - updatePetWithForm(body?: types.UpdatePetWithFormFormDataParam | types.UpdatePetWithFormMetadataParam, metadata?: types.UpdatePetWithFormMetadataParam): Promise> { - return this.core.fetch('/pet/{petId}', 'post', body, metadata); - } - - /** - * Deletes a pet - * - */ - deletePet(metadata: types.DeletePetMetadataParam): Promise> { - return this.core.fetch('/pet/{petId}', 'delete', metadata); - } - - /** - * Uploads an image - * - */ - uploadFile(body: types.UploadFileBodyParam, metadata: types.UploadFileMetadataParam): Promise>; - uploadFile(metadata: types.UploadFileMetadataParam): Promise>; - uploadFile(body?: types.UploadFileBodyParam | types.UploadFileMetadataParam, metadata?: types.UploadFileMetadataParam): Promise> { - return this.core.fetch('/pet/{petId}/uploadImage', 'post', body, metadata); - } - - /** - * Returns a map of status codes to quantities - * - * @summary Returns pet inventories by status - */ - getInventory(): Promise> { - return this.core.fetch('/store/inventory', 'get'); - } - - /** - * Place an order for a pet - * - */ - placeOrder(body: types.Order): Promise> { - return this.core.fetch('/store/order', 'post', body); - } - - /** - * For valid response try integer IDs with value >= 1 and <= 10. Other values will - * generated exceptions - * - * @summary Find purchase order by ID - */ - getOrderById(metadata: types.GetOrderByIdMetadataParam): Promise> { - return this.core.fetch('/store/order/{orderId}', 'get', metadata); - } - - /** - * For valid response try integer IDs with positive integer value. Negative or non-integer - * values will generate API errors - * - * @summary Delete purchase order by ID - */ - deleteOrder(metadata: types.DeleteOrderMetadataParam): Promise> { - return this.core.fetch('/store/order/{orderId}', 'delete', metadata); - } - - /** - * This can only be done by the logged in user. - * - * @summary Create user - */ - createUser(body: types.User): Promise> { - return this.core.fetch('/user', 'post', body); - } - - /** - * Creates list of users with given input array - * - */ - createUsersWithArrayInput(body: types.CreateUsersWithArrayInputBodyParam): Promise> { - return this.core.fetch('/user/createWithArray', 'post', body); - } - - /** - * Creates list of users with given input array - * - */ - createUsersWithListInput(body: types.CreateUsersWithListInputBodyParam): Promise> { - return this.core.fetch('/user/createWithList', 'post', body); - } - - /** - * Logs user into the system - * - */ - loginUser(metadata: types.LoginUserMetadataParam): Promise> { - return this.core.fetch('/user/login', 'get', metadata); - } - - /** - * Logs out current logged in user session - * - */ - logoutUser(): Promise> { - return this.core.fetch('/user/logout', 'get'); - } - - /** - * Get user by user name - * - */ - getUserByName(metadata: types.GetUserByNameMetadataParam): Promise> { - return this.core.fetch('/user/{username}', 'get', metadata); - } - - /** - * This can only be done by the logged in user. - * - * @summary Updated user - */ - updateUser(body: types.User, metadata: types.UpdateUserMetadataParam): Promise> { - return this.core.fetch('/user/{username}', 'put', body, metadata); - } - - /** - * This can only be done by the logged in user. - * - * @summary Delete user - */ - deleteUser(metadata: types.DeleteUserMetadataParam): Promise> { - return this.core.fetch('/user/{username}', 'delete', metadata); - } -} +import SDK from './sdk.js'; /** * Swagger Petstore diff --git a/packages/test-utils/sdks/petstore/src/sdk.ts b/packages/test-utils/sdks/petstore/src/sdk.ts new file mode 100644 index 00000000..41c791c6 --- /dev/null +++ b/packages/test-utils/sdks/petstore/src/sdk.ts @@ -0,0 +1,248 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@readme/oas-examples/3.0/json/petstore.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'petstore/1.0.0 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** + * Add a new pet to the store + * + */ + addPet(body: types.Pet): Promise> { + return this.core.fetch('/pet', 'post', body); + } + + /** + * Update an existing pet + * + */ + updatePet(body: types.Pet): Promise> { + return this.core.fetch('/pet', 'put', body); + } + + /** + * Multiple status values can be provided with comma separated strings + * + * @summary Finds Pets by status + */ + findPetsByStatus(metadata: types.FindPetsByStatusMetadataParam): Promise> { + return this.core.fetch('/pet/findByStatus', 'get', metadata); + } + + /** + * Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for + * testing. + * + * @summary Finds Pets by tags + */ + findPetsByTags(metadata: types.FindPetsByTagsMetadataParam): Promise> { + return this.core.fetch('/pet/findByTags', 'get', metadata); + } + + /** + * Returns a single pet + * + * @summary Find pet by ID + */ + getPetById(metadata: types.GetPetByIdMetadataParam): Promise> { + return this.core.fetch('/pet/{petId}', 'get', metadata); + } + + /** + * Updates a pet in the store with form data + * + */ + updatePetWithForm(body: types.UpdatePetWithFormFormDataParam, metadata: types.UpdatePetWithFormMetadataParam): Promise>; + updatePetWithForm(metadata: types.UpdatePetWithFormMetadataParam): Promise>; + updatePetWithForm(body?: types.UpdatePetWithFormFormDataParam | types.UpdatePetWithFormMetadataParam, metadata?: types.UpdatePetWithFormMetadataParam): Promise> { + return this.core.fetch('/pet/{petId}', 'post', body, metadata); + } + + /** + * Deletes a pet + * + */ + deletePet(metadata: types.DeletePetMetadataParam): Promise> { + return this.core.fetch('/pet/{petId}', 'delete', metadata); + } + + /** + * Uploads an image + * + */ + uploadFile(body: types.UploadFileBodyParam, metadata: types.UploadFileMetadataParam): Promise>; + uploadFile(metadata: types.UploadFileMetadataParam): Promise>; + uploadFile(body?: types.UploadFileBodyParam | types.UploadFileMetadataParam, metadata?: types.UploadFileMetadataParam): Promise> { + return this.core.fetch('/pet/{petId}/uploadImage', 'post', body, metadata); + } + + /** + * Returns a map of status codes to quantities + * + * @summary Returns pet inventories by status + */ + getInventory(): Promise> { + return this.core.fetch('/store/inventory', 'get'); + } + + /** + * Place an order for a pet + * + */ + placeOrder(body: types.Order): Promise> { + return this.core.fetch('/store/order', 'post', body); + } + + /** + * For valid response try integer IDs with value >= 1 and <= 10. Other values will + * generated exceptions + * + * @summary Find purchase order by ID + */ + getOrderById(metadata: types.GetOrderByIdMetadataParam): Promise> { + return this.core.fetch('/store/order/{orderId}', 'get', metadata); + } + + /** + * For valid response try integer IDs with positive integer value. Negative or non-integer + * values will generate API errors + * + * @summary Delete purchase order by ID + */ + deleteOrder(metadata: types.DeleteOrderMetadataParam): Promise> { + return this.core.fetch('/store/order/{orderId}', 'delete', metadata); + } + + /** + * This can only be done by the logged in user. + * + * @summary Create user + */ + createUser(body: types.User): Promise> { + return this.core.fetch('/user', 'post', body); + } + + /** + * Creates list of users with given input array + * + */ + createUsersWithArrayInput(body: types.CreateUsersWithArrayInputBodyParam): Promise> { + return this.core.fetch('/user/createWithArray', 'post', body); + } + + /** + * Creates list of users with given input array + * + */ + createUsersWithListInput(body: types.CreateUsersWithListInputBodyParam): Promise> { + return this.core.fetch('/user/createWithList', 'post', body); + } + + /** + * Logs user into the system + * + */ + loginUser(metadata: types.LoginUserMetadataParam): Promise> { + return this.core.fetch('/user/login', 'get', metadata); + } + + /** + * Logs out current logged in user session + * + */ + logoutUser(): Promise> { + return this.core.fetch('/user/logout', 'get'); + } + + /** + * Get user by user name + * + */ + getUserByName(metadata: types.GetUserByNameMetadataParam): Promise> { + return this.core.fetch('/user/{username}', 'get', metadata); + } + + /** + * This can only be done by the logged in user. + * + * @summary Updated user + */ + updateUser(body: types.User, metadata: types.UpdateUserMetadataParam): Promise> { + return this.core.fetch('/user/{username}', 'put', body, metadata); + } + + /** + * This can only be done by the logged in user. + * + * @summary Delete user + */ + deleteUser(metadata: types.DeleteUserMetadataParam): Promise> { + return this.core.fetch('/user/{username}', 'delete', metadata); + } +} diff --git a/packages/test-utils/sdks/readme/package.json b/packages/test-utils/sdks/readme/package.json index 5268bbb6..1afb429a 100644 --- a/packages/test-utils/sdks/readme/package.json +++ b/packages/test-utils/sdks/readme/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -36,6 +40,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/readme/src/index.ts b/packages/test-utils/sdks/readme/src/index.ts index 20a93779..b0573903 100644 --- a/packages/test-utils/sdks/readme/src/index.ts +++ b/packages/test-utils/sdks/readme/src/index.ts @@ -1,480 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@readme/oas-examples/3.0/json/readme.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'readme/4.355.0 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** - * Get an API definition file that's been uploaded to ReadMe. - * - * @summary Retrieve an entry from the API Registry - * @throws FetchError<404, types.ErrorRegistryNotfound> The registry entry couldn't be found. - */ - getAPIRegistry(metadata: types.GetApiRegistryMetadataParam): Promise> { - return this.core.fetch('/api-registry/{uuid}', 'get', metadata); - } - - /** - * Get API specification metadata. - * - * @summary Get metadata - * @throws FetchError<400, types.ErrorVersionEmpty> No version was supplied. - * @throws FetchError<401, types.GetApiSpecificationResponse401> Unauthorized - * @throws FetchError<403, types.GetApiSpecificationResponse403> Unauthorized - * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. - */ - getAPISpecification(metadata?: types.GetApiSpecificationMetadataParam): Promise> { - return this.core.fetch('/api-specification', 'get', metadata); - } - - /** - * Upload an API specification to ReadMe. Or, to use a newer solution see - * https://docs.readme.com/main/docs/rdme. - * - * @summary Upload specification - * @throws FetchError<400, types.UploadApiSpecificationResponse400> There was a validation error during upload. - * @throws FetchError<401, types.UploadApiSpecificationResponse401> Unauthorized - * @throws FetchError<403, types.UploadApiSpecificationResponse403> Unauthorized - * @throws FetchError<408, types.ErrorSpecTimeout> The spec upload timed out. - */ - uploadAPISpecification(body: types.UploadApiSpecificationBodyParam, metadata?: types.UploadApiSpecificationMetadataParam): Promise> { - return this.core.fetch('/api-specification', 'post', body, metadata); - } - - /** - * Update an API specification in ReadMe. - * - * @summary Update specification - * @throws FetchError<400, types.UpdateApiSpecificationResponse400> There was a validation error during upload. - * @throws FetchError<401, types.UpdateApiSpecificationResponse401> Unauthorized - * @throws FetchError<403, types.UpdateApiSpecificationResponse403> Unauthorized - * @throws FetchError<408, types.ErrorSpecTimeout> The spec upload timed out. - */ - updateAPISpecification(body: types.UpdateApiSpecificationBodyParam, metadata: types.UpdateApiSpecificationMetadataParam): Promise> { - return this.core.fetch('/api-specification/{id}', 'put', body, metadata); - } - - /** - * Delete an API specification in ReadMe. - * - * @summary Delete specification - * @throws FetchError<400, types.ErrorSpecIdInvalid> The spec ID isn't valid. - * @throws FetchError<401, types.DeleteApiSpecificationResponse401> Unauthorized - * @throws FetchError<403, types.DeleteApiSpecificationResponse403> Unauthorized - * @throws FetchError<404, types.ErrorSpecNotfound> The spec couldn't be found. - */ - deleteAPISpecification(metadata: types.DeleteApiSpecificationMetadataParam): Promise> { - return this.core.fetch('/api-specification/{id}', 'delete', metadata); - } - - /** - * Returns all the roles we're hiring for at ReadMe! - * - * @summary Get open roles - */ - getOpenRoles(): Promise> { - return this.core.fetch('/apply', 'get'); - } - - /** - * This endpoint will let you apply to a job at ReadMe programatically, without having to - * go through our UI! - * - * @summary Submit your application! - */ - applyToReadMe(body: types.Apply): Promise> { - return this.core.fetch('/apply', 'post', body); - } - - /** - * Returns all the categories for a specified version. - * - * @summary Get all categories - */ - getCategories(metadata?: types.GetCategoriesMetadataParam): Promise> { - return this.core.fetch('/categories', 'get', metadata); - } - - /** - * Create a new category inside of this project. - * - * @summary Create category - * @throws FetchError<400, types.ErrorCategoryInvalid> The category couldn't be saved. - */ - createCategory(body: types.Category, metadata?: types.CreateCategoryMetadataParam): Promise> { - return this.core.fetch('/categories', 'post', body, metadata); - } - - /** - * Returns the category with this slug. - * - * @summary Get category - * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. - */ - getCategory(metadata: types.GetCategoryMetadataParam): Promise> { - return this.core.fetch('/categories/{slug}', 'get', metadata); - } - - /** - * Change the properties of a category. - * - * @summary Update category - * @throws FetchError<400, types.ErrorCategoryInvalid> The category couldn't be saved. - * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. - */ - updateCategory(body: types.Category, metadata: types.UpdateCategoryMetadataParam): Promise> { - return this.core.fetch('/categories/{slug}', 'put', body, metadata); - } - - /** - * Delete the category with this slug. - * >⚠️Heads Up! - * > This will also delete all of the docs within this category. - * - * @summary Delete category - * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. - */ - deleteCategory(metadata: types.DeleteCategoryMetadataParam): Promise> { - return this.core.fetch('/categories/{slug}', 'delete', metadata); - } - - /** - * Returns the docs and children docs within this category. - * - * @summary Get docs for category - * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. - */ - getCategoryDocs(metadata: types.GetCategoryDocsMetadataParam): Promise> { - return this.core.fetch('/categories/{slug}/docs', 'get', metadata); - } - - /** - * Returns a list of changelogs. - * - * @summary Get changelogs - */ - getChangelogs(metadata?: types.GetChangelogsMetadataParam): Promise> { - return this.core.fetch('/changelogs', 'get', metadata); - } - - /** - * Create a new changelog entry. - * - * @summary Create changelog - */ - createChangelog(body: types.Changelog): Promise> { - return this.core.fetch('/changelogs', 'post', body); - } - - /** - * Returns the changelog with this slug. - * - * @summary Get changelog - */ - getChangelog(metadata: types.GetChangelogMetadataParam): Promise> { - return this.core.fetch('/changelogs/{slug}', 'get', metadata); - } - - /** - * Update a changelog with this slug. - * - * @summary Update changelog - */ - updateChangelog(body: types.Changelog, metadata: types.UpdateChangelogMetadataParam): Promise> { - return this.core.fetch('/changelogs/{slug}', 'put', body, metadata); - } - - /** - * Delete the changelog with this slug. - * - * @summary Delete changelog - */ - deleteChangelog(metadata: types.DeleteChangelogMetadataParam): Promise> { - return this.core.fetch('/changelogs/{slug}', 'delete', metadata); - } - - /** - * Returns a list of custom pages. - * - * @summary Get custom pages - * @throws FetchError<401, types.GetCustomPagesResponse401> Unauthorized - * @throws FetchError<403, types.GetCustomPagesResponse403> Unauthorized - */ - getCustomPages(metadata?: types.GetCustomPagesMetadataParam): Promise> { - return this.core.fetch('/custompages', 'get', metadata); - } - - /** - * Create a new custom page inside of this project. - * - * @summary Create custom page - * @throws FetchError<400, types.ErrorCustompageInvalid> The page couldn't be saved. - * @throws FetchError<401, types.CreateCustomPageResponse401> Unauthorized - * @throws FetchError<403, types.CreateCustomPageResponse403> Unauthorized - */ - createCustomPage(body: types.CustomPage): Promise> { - return this.core.fetch('/custompages', 'post', body); - } - - /** - * Returns the custom page with this slug. - * - * @summary Get custom page - * @throws FetchError<401, types.GetCustomPageResponse401> Unauthorized - * @throws FetchError<403, types.GetCustomPageResponse403> Unauthorized - * @throws FetchError<404, types.ErrorCustompageNotfound> The custom page couldn't be found. - */ - getCustomPage(metadata: types.GetCustomPageMetadataParam): Promise> { - return this.core.fetch('/custompages/{slug}', 'get', metadata); - } - - /** - * Update a custom page with this slug. - * - * @summary Update custom page - * @throws FetchError<400, types.ErrorCustompageInvalid> The page couldn't be saved. - * @throws FetchError<401, types.UpdateCustomPageResponse401> Unauthorized - * @throws FetchError<403, types.UpdateCustomPageResponse403> Unauthorized - * @throws FetchError<404, types.ErrorCustompageNotfound> The custom page couldn't be found. - */ - updateCustomPage(body: types.CustomPage, metadata: types.UpdateCustomPageMetadataParam): Promise> { - return this.core.fetch('/custompages/{slug}', 'put', body, metadata); - } - - /** - * Delete the custom page with this slug. - * - * @summary Delete custom page - * @throws FetchError<401, types.DeleteCustomPageResponse401> Unauthorized - * @throws FetchError<403, types.DeleteCustomPageResponse403> Unauthorized - * @throws FetchError<404, types.ErrorCustompageNotfound> The custom page couldn't be found. - */ - deleteCustomPage(metadata: types.DeleteCustomPageMetadataParam): Promise> { - return this.core.fetch('/custompages/{slug}', 'delete', metadata); - } - - /** - * Returns the doc with this slug. - * - * @summary Get doc - * @throws FetchError<401, types.GetDocResponse401> Unauthorized - * @throws FetchError<403, types.GetDocResponse403> Unauthorized - * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. - */ - getDoc(metadata: types.GetDocMetadataParam): Promise> { - return this.core.fetch('/docs/{slug}', 'get', metadata); - } - - /** - * Update a doc with this slug. - * - * @summary Update doc - * @throws FetchError<400, types.ErrorDocInvalid> The doc couldn't be saved. - * @throws FetchError<401, types.UpdateDocResponse401> Unauthorized - * @throws FetchError<403, types.UpdateDocResponse403> Unauthorized - * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. - */ - updateDoc(body: types.DocSchemaPut, metadata: types.UpdateDocMetadataParam): Promise> { - return this.core.fetch('/docs/{slug}', 'put', body, metadata); - } - - /** - * Delete the doc with this slug. - * - * @summary Delete doc - * @throws FetchError<401, types.DeleteDocResponse401> Unauthorized - * @throws FetchError<403, types.DeleteDocResponse403> Unauthorized - * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. - */ - deleteDoc(metadata: types.DeleteDocMetadataParam): Promise> { - return this.core.fetch('/docs/{slug}', 'delete', metadata); - } - - /** - * This is intended for use by enterprise users with staging enabled. This endpoint will - * return the live version of your document, whereas the standard endpoint will always - * return staging. - * - * @summary Get production doc - * @throws FetchError<401, types.GetProductionDocResponse401> Unauthorized - * @throws FetchError<403, types.GetProductionDocResponse403> Unauthorized - * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. - */ - getProductionDoc(metadata: types.GetProductionDocMetadataParam): Promise> { - return this.core.fetch('/docs/{slug}/production', 'get', metadata); - } - - /** - * Create a new doc inside of this project. - * - * @summary Create doc - * @throws FetchError<400, types.ErrorDocInvalid> The doc couldn't be saved. - * @throws FetchError<401, types.CreateDocResponse401> Unauthorized - * @throws FetchError<403, types.CreateDocResponse403> Unauthorized - */ - createDoc(body: types.DocSchemaPost, metadata?: types.CreateDocMetadataParam): Promise> { - return this.core.fetch('/docs', 'post', body, metadata); - } - - /** - * Returns all docs that match the search. - * - * @summary Search docs - * @throws FetchError<401, types.SearchDocsResponse401> Unauthorized - * @throws FetchError<403, types.SearchDocsResponse403> Unauthorized - */ - searchDocs(metadata: types.SearchDocsMetadataParam): Promise> { - return this.core.fetch('/docs/search', 'post', metadata); - } - - /** - * Returns project data for the API key. - * - * @summary Get metadata about the current project - * @throws FetchError<401, types.GetProjectResponse401> Unauthorized - * @throws FetchError<403, types.GetProjectResponse403> Unauthorized - */ - getProject(): Promise> { - return this.core.fetch('/', 'get'); - } - - /** - * Returns a copy of our OpenAPI Definition. - * - * @summary Get our OpenAPI Definition - */ - getAPISchema(): Promise> { - return this.core.fetch('/schema', 'get'); - } - - /** - * Retrieve a list of versions associated with a project API key. - * - * @summary Get versions - * @throws FetchError<401, types.GetVersionsResponse401> Unauthorized - * @throws FetchError<403, types.GetVersionsResponse403> Unauthorized - */ - getVersions(): Promise> { - return this.core.fetch('/version', 'get'); - } - - /** - * Create a new version. - * - * @summary Create version - * @throws FetchError<400, types.CreateVersionResponse400> There was a validation error during creation. - * @throws FetchError<401, types.CreateVersionResponse401> Unauthorized - * @throws FetchError<403, types.CreateVersionResponse403> Unauthorized - * @throws FetchError<404, types.ErrorVersionForkNotfound> The version couldn't be found. - */ - createVersion(body: types.Version): Promise> { - return this.core.fetch('/version', 'post', body); - } - - /** - * Returns the version with this version ID. - * - * @summary Get version - * @throws FetchError<401, types.GetVersionResponse401> Unauthorized - * @throws FetchError<403, types.GetVersionResponse403> Unauthorized - * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. - */ - getVersion(metadata: types.GetVersionMetadataParam): Promise> { - return this.core.fetch('/version/{versionId}', 'get', metadata); - } - - /** - * Update an existing version. - * - * @summary Update version - * @throws FetchError<400, types.ErrorVersionCantDemoteStable> A stable version can't be demoted. - * @throws FetchError<401, types.UpdateVersionResponse401> Unauthorized - * @throws FetchError<403, types.UpdateVersionResponse403> Unauthorized - * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. - */ - updateVersion(body: types.Version, metadata: types.UpdateVersionMetadataParam): Promise> { - return this.core.fetch('/version/{versionId}', 'put', body, metadata); - } - - /** - * Delete a version - * - * @summary Delete version - * @throws FetchError<400, types.ErrorVersionCantRemoveStable> A stable version can't be removed. - * @throws FetchError<401, types.DeleteVersionResponse401> Unauthorized - * @throws FetchError<403, types.DeleteVersionResponse403> Unauthorized - * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. - */ - deleteVersion(metadata: types.DeleteVersionMetadataParam): Promise> { - return this.core.fetch('/version/{versionId}', 'delete', metadata); - } -} +import SDK from './sdk.js'; /** * ReadMe API 🦉 diff --git a/packages/test-utils/sdks/readme/src/sdk.ts b/packages/test-utils/sdks/readme/src/sdk.ts new file mode 100644 index 00000000..a1c05f5c --- /dev/null +++ b/packages/test-utils/sdks/readme/src/sdk.ts @@ -0,0 +1,477 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@readme/oas-examples/3.0/json/readme.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'readme/4.355.0 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** + * Get an API definition file that's been uploaded to ReadMe. + * + * @summary Retrieve an entry from the API Registry + * @throws FetchError<404, types.ErrorRegistryNotfound> The registry entry couldn't be found. + */ + getAPIRegistry(metadata: types.GetApiRegistryMetadataParam): Promise> { + return this.core.fetch('/api-registry/{uuid}', 'get', metadata); + } + + /** + * Get API specification metadata. + * + * @summary Get metadata + * @throws FetchError<400, types.ErrorVersionEmpty> No version was supplied. + * @throws FetchError<401, types.GetApiSpecificationResponse401> Unauthorized + * @throws FetchError<403, types.GetApiSpecificationResponse403> Unauthorized + * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. + */ + getAPISpecification(metadata?: types.GetApiSpecificationMetadataParam): Promise> { + return this.core.fetch('/api-specification', 'get', metadata); + } + + /** + * Upload an API specification to ReadMe. Or, to use a newer solution see + * https://docs.readme.com/main/docs/rdme. + * + * @summary Upload specification + * @throws FetchError<400, types.UploadApiSpecificationResponse400> There was a validation error during upload. + * @throws FetchError<401, types.UploadApiSpecificationResponse401> Unauthorized + * @throws FetchError<403, types.UploadApiSpecificationResponse403> Unauthorized + * @throws FetchError<408, types.ErrorSpecTimeout> The spec upload timed out. + */ + uploadAPISpecification(body: types.UploadApiSpecificationBodyParam, metadata?: types.UploadApiSpecificationMetadataParam): Promise> { + return this.core.fetch('/api-specification', 'post', body, metadata); + } + + /** + * Update an API specification in ReadMe. + * + * @summary Update specification + * @throws FetchError<400, types.UpdateApiSpecificationResponse400> There was a validation error during upload. + * @throws FetchError<401, types.UpdateApiSpecificationResponse401> Unauthorized + * @throws FetchError<403, types.UpdateApiSpecificationResponse403> Unauthorized + * @throws FetchError<408, types.ErrorSpecTimeout> The spec upload timed out. + */ + updateAPISpecification(body: types.UpdateApiSpecificationBodyParam, metadata: types.UpdateApiSpecificationMetadataParam): Promise> { + return this.core.fetch('/api-specification/{id}', 'put', body, metadata); + } + + /** + * Delete an API specification in ReadMe. + * + * @summary Delete specification + * @throws FetchError<400, types.ErrorSpecIdInvalid> The spec ID isn't valid. + * @throws FetchError<401, types.DeleteApiSpecificationResponse401> Unauthorized + * @throws FetchError<403, types.DeleteApiSpecificationResponse403> Unauthorized + * @throws FetchError<404, types.ErrorSpecNotfound> The spec couldn't be found. + */ + deleteAPISpecification(metadata: types.DeleteApiSpecificationMetadataParam): Promise> { + return this.core.fetch('/api-specification/{id}', 'delete', metadata); + } + + /** + * Returns all the roles we're hiring for at ReadMe! + * + * @summary Get open roles + */ + getOpenRoles(): Promise> { + return this.core.fetch('/apply', 'get'); + } + + /** + * This endpoint will let you apply to a job at ReadMe programatically, without having to + * go through our UI! + * + * @summary Submit your application! + */ + applyToReadMe(body: types.Apply): Promise> { + return this.core.fetch('/apply', 'post', body); + } + + /** + * Returns all the categories for a specified version. + * + * @summary Get all categories + */ + getCategories(metadata?: types.GetCategoriesMetadataParam): Promise> { + return this.core.fetch('/categories', 'get', metadata); + } + + /** + * Create a new category inside of this project. + * + * @summary Create category + * @throws FetchError<400, types.ErrorCategoryInvalid> The category couldn't be saved. + */ + createCategory(body: types.Category, metadata?: types.CreateCategoryMetadataParam): Promise> { + return this.core.fetch('/categories', 'post', body, metadata); + } + + /** + * Returns the category with this slug. + * + * @summary Get category + * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. + */ + getCategory(metadata: types.GetCategoryMetadataParam): Promise> { + return this.core.fetch('/categories/{slug}', 'get', metadata); + } + + /** + * Change the properties of a category. + * + * @summary Update category + * @throws FetchError<400, types.ErrorCategoryInvalid> The category couldn't be saved. + * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. + */ + updateCategory(body: types.Category, metadata: types.UpdateCategoryMetadataParam): Promise> { + return this.core.fetch('/categories/{slug}', 'put', body, metadata); + } + + /** + * Delete the category with this slug. + * >⚠️Heads Up! + * > This will also delete all of the docs within this category. + * + * @summary Delete category + * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. + */ + deleteCategory(metadata: types.DeleteCategoryMetadataParam): Promise> { + return this.core.fetch('/categories/{slug}', 'delete', metadata); + } + + /** + * Returns the docs and children docs within this category. + * + * @summary Get docs for category + * @throws FetchError<404, types.ErrorCategoryNotfound> The category couldn't be found. + */ + getCategoryDocs(metadata: types.GetCategoryDocsMetadataParam): Promise> { + return this.core.fetch('/categories/{slug}/docs', 'get', metadata); + } + + /** + * Returns a list of changelogs. + * + * @summary Get changelogs + */ + getChangelogs(metadata?: types.GetChangelogsMetadataParam): Promise> { + return this.core.fetch('/changelogs', 'get', metadata); + } + + /** + * Create a new changelog entry. + * + * @summary Create changelog + */ + createChangelog(body: types.Changelog): Promise> { + return this.core.fetch('/changelogs', 'post', body); + } + + /** + * Returns the changelog with this slug. + * + * @summary Get changelog + */ + getChangelog(metadata: types.GetChangelogMetadataParam): Promise> { + return this.core.fetch('/changelogs/{slug}', 'get', metadata); + } + + /** + * Update a changelog with this slug. + * + * @summary Update changelog + */ + updateChangelog(body: types.Changelog, metadata: types.UpdateChangelogMetadataParam): Promise> { + return this.core.fetch('/changelogs/{slug}', 'put', body, metadata); + } + + /** + * Delete the changelog with this slug. + * + * @summary Delete changelog + */ + deleteChangelog(metadata: types.DeleteChangelogMetadataParam): Promise> { + return this.core.fetch('/changelogs/{slug}', 'delete', metadata); + } + + /** + * Returns a list of custom pages. + * + * @summary Get custom pages + * @throws FetchError<401, types.GetCustomPagesResponse401> Unauthorized + * @throws FetchError<403, types.GetCustomPagesResponse403> Unauthorized + */ + getCustomPages(metadata?: types.GetCustomPagesMetadataParam): Promise> { + return this.core.fetch('/custompages', 'get', metadata); + } + + /** + * Create a new custom page inside of this project. + * + * @summary Create custom page + * @throws FetchError<400, types.ErrorCustompageInvalid> The page couldn't be saved. + * @throws FetchError<401, types.CreateCustomPageResponse401> Unauthorized + * @throws FetchError<403, types.CreateCustomPageResponse403> Unauthorized + */ + createCustomPage(body: types.CustomPage): Promise> { + return this.core.fetch('/custompages', 'post', body); + } + + /** + * Returns the custom page with this slug. + * + * @summary Get custom page + * @throws FetchError<401, types.GetCustomPageResponse401> Unauthorized + * @throws FetchError<403, types.GetCustomPageResponse403> Unauthorized + * @throws FetchError<404, types.ErrorCustompageNotfound> The custom page couldn't be found. + */ + getCustomPage(metadata: types.GetCustomPageMetadataParam): Promise> { + return this.core.fetch('/custompages/{slug}', 'get', metadata); + } + + /** + * Update a custom page with this slug. + * + * @summary Update custom page + * @throws FetchError<400, types.ErrorCustompageInvalid> The page couldn't be saved. + * @throws FetchError<401, types.UpdateCustomPageResponse401> Unauthorized + * @throws FetchError<403, types.UpdateCustomPageResponse403> Unauthorized + * @throws FetchError<404, types.ErrorCustompageNotfound> The custom page couldn't be found. + */ + updateCustomPage(body: types.CustomPage, metadata: types.UpdateCustomPageMetadataParam): Promise> { + return this.core.fetch('/custompages/{slug}', 'put', body, metadata); + } + + /** + * Delete the custom page with this slug. + * + * @summary Delete custom page + * @throws FetchError<401, types.DeleteCustomPageResponse401> Unauthorized + * @throws FetchError<403, types.DeleteCustomPageResponse403> Unauthorized + * @throws FetchError<404, types.ErrorCustompageNotfound> The custom page couldn't be found. + */ + deleteCustomPage(metadata: types.DeleteCustomPageMetadataParam): Promise> { + return this.core.fetch('/custompages/{slug}', 'delete', metadata); + } + + /** + * Returns the doc with this slug. + * + * @summary Get doc + * @throws FetchError<401, types.GetDocResponse401> Unauthorized + * @throws FetchError<403, types.GetDocResponse403> Unauthorized + * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. + */ + getDoc(metadata: types.GetDocMetadataParam): Promise> { + return this.core.fetch('/docs/{slug}', 'get', metadata); + } + + /** + * Update a doc with this slug. + * + * @summary Update doc + * @throws FetchError<400, types.ErrorDocInvalid> The doc couldn't be saved. + * @throws FetchError<401, types.UpdateDocResponse401> Unauthorized + * @throws FetchError<403, types.UpdateDocResponse403> Unauthorized + * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. + */ + updateDoc(body: types.DocSchemaPut, metadata: types.UpdateDocMetadataParam): Promise> { + return this.core.fetch('/docs/{slug}', 'put', body, metadata); + } + + /** + * Delete the doc with this slug. + * + * @summary Delete doc + * @throws FetchError<401, types.DeleteDocResponse401> Unauthorized + * @throws FetchError<403, types.DeleteDocResponse403> Unauthorized + * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. + */ + deleteDoc(metadata: types.DeleteDocMetadataParam): Promise> { + return this.core.fetch('/docs/{slug}', 'delete', metadata); + } + + /** + * This is intended for use by enterprise users with staging enabled. This endpoint will + * return the live version of your document, whereas the standard endpoint will always + * return staging. + * + * @summary Get production doc + * @throws FetchError<401, types.GetProductionDocResponse401> Unauthorized + * @throws FetchError<403, types.GetProductionDocResponse403> Unauthorized + * @throws FetchError<404, types.ErrorDocNotfound> The doc couldn't be found. + */ + getProductionDoc(metadata: types.GetProductionDocMetadataParam): Promise> { + return this.core.fetch('/docs/{slug}/production', 'get', metadata); + } + + /** + * Create a new doc inside of this project. + * + * @summary Create doc + * @throws FetchError<400, types.ErrorDocInvalid> The doc couldn't be saved. + * @throws FetchError<401, types.CreateDocResponse401> Unauthorized + * @throws FetchError<403, types.CreateDocResponse403> Unauthorized + */ + createDoc(body: types.DocSchemaPost, metadata?: types.CreateDocMetadataParam): Promise> { + return this.core.fetch('/docs', 'post', body, metadata); + } + + /** + * Returns all docs that match the search. + * + * @summary Search docs + * @throws FetchError<401, types.SearchDocsResponse401> Unauthorized + * @throws FetchError<403, types.SearchDocsResponse403> Unauthorized + */ + searchDocs(metadata: types.SearchDocsMetadataParam): Promise> { + return this.core.fetch('/docs/search', 'post', metadata); + } + + /** + * Returns project data for the API key. + * + * @summary Get metadata about the current project + * @throws FetchError<401, types.GetProjectResponse401> Unauthorized + * @throws FetchError<403, types.GetProjectResponse403> Unauthorized + */ + getProject(): Promise> { + return this.core.fetch('/', 'get'); + } + + /** + * Returns a copy of our OpenAPI Definition. + * + * @summary Get our OpenAPI Definition + */ + getAPISchema(): Promise> { + return this.core.fetch('/schema', 'get'); + } + + /** + * Retrieve a list of versions associated with a project API key. + * + * @summary Get versions + * @throws FetchError<401, types.GetVersionsResponse401> Unauthorized + * @throws FetchError<403, types.GetVersionsResponse403> Unauthorized + */ + getVersions(): Promise> { + return this.core.fetch('/version', 'get'); + } + + /** + * Create a new version. + * + * @summary Create version + * @throws FetchError<400, types.CreateVersionResponse400> There was a validation error during creation. + * @throws FetchError<401, types.CreateVersionResponse401> Unauthorized + * @throws FetchError<403, types.CreateVersionResponse403> Unauthorized + * @throws FetchError<404, types.ErrorVersionForkNotfound> The version couldn't be found. + */ + createVersion(body: types.Version): Promise> { + return this.core.fetch('/version', 'post', body); + } + + /** + * Returns the version with this version ID. + * + * @summary Get version + * @throws FetchError<401, types.GetVersionResponse401> Unauthorized + * @throws FetchError<403, types.GetVersionResponse403> Unauthorized + * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. + */ + getVersion(metadata: types.GetVersionMetadataParam): Promise> { + return this.core.fetch('/version/{versionId}', 'get', metadata); + } + + /** + * Update an existing version. + * + * @summary Update version + * @throws FetchError<400, types.ErrorVersionCantDemoteStable> A stable version can't be demoted. + * @throws FetchError<401, types.UpdateVersionResponse401> Unauthorized + * @throws FetchError<403, types.UpdateVersionResponse403> Unauthorized + * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. + */ + updateVersion(body: types.Version, metadata: types.UpdateVersionMetadataParam): Promise> { + return this.core.fetch('/version/{versionId}', 'put', body, metadata); + } + + /** + * Delete a version + * + * @summary Delete version + * @throws FetchError<400, types.ErrorVersionCantRemoveStable> A stable version can't be removed. + * @throws FetchError<401, types.DeleteVersionResponse401> Unauthorized + * @throws FetchError<403, types.DeleteVersionResponse403> Unauthorized + * @throws FetchError<404, types.ErrorVersionNotfound> The version couldn't be found. + */ + deleteVersion(metadata: types.DeleteVersionMetadataParam): Promise> { + return this.core.fetch('/version/{versionId}', 'delete', metadata); + } +} diff --git a/packages/test-utils/sdks/response-title-quirks/package.json b/packages/test-utils/sdks/response-title-quirks/package.json index 61dda717..f1180e06 100644 --- a/packages/test-utils/sdks/response-title-quirks/package.json +++ b/packages/test-utils/sdks/response-title-quirks/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -36,6 +40,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/response-title-quirks/src/index.ts b/packages/test-utils/sdks/response-title-quirks/src/index.ts index 9baf9188..200f03b6 100644 --- a/packages/test-utils/sdks/response-title-quirks/src/index.ts +++ b/packages/test-utils/sdks/response-title-quirks/src/index.ts @@ -1,79 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse, HTTPMethodRange } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@api/test-utils/definitions/response-title-quirks.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'response-title-quirks/1.0.0 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - getAnything(metadata: types.GetAnythingMetadataParam): Promise, types.GetAnythingResponse2XX>> { - return this.core.fetch('/anything', 'get', metadata); - } -} +import SDK from './sdk.js'; /** * Testing an OAS that has response `title` props that start with a number diff --git a/packages/test-utils/sdks/response-title-quirks/src/sdk.ts b/packages/test-utils/sdks/response-title-quirks/src/sdk.ts new file mode 100644 index 00000000..47b3e26e --- /dev/null +++ b/packages/test-utils/sdks/response-title-quirks/src/sdk.ts @@ -0,0 +1,76 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse, HTTPMethodRange } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@api/test-utils/definitions/response-title-quirks.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'response-title-quirks/1.0.0 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + getAnything(metadata: types.GetAnythingMetadataParam): Promise, types.GetAnythingResponse2XX>> { + return this.core.fetch('/anything', 'get', metadata); + } +} diff --git a/packages/test-utils/sdks/simple/package.json b/packages/test-utils/sdks/simple/package.json index 99556fbb..b102ded9 100644 --- a/packages/test-utils/sdks/simple/package.json +++ b/packages/test-utils/sdks/simple/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -36,6 +40,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/simple/src/index.ts b/packages/test-utils/sdks/simple/src/index.ts index d44b0679..a28cf67c 100644 --- a/packages/test-utils/sdks/simple/src/index.ts +++ b/packages/test-utils/sdks/simple/src/index.ts @@ -1,84 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@api/test-utils/definitions/simple.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'simple/1.0.0 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** - * Multiple status values can be provided with comma separated strings - * - * @summary Finds Pets by status - */ - findPetsByStatus(metadata: types.FindPetsByStatusMetadataParam): Promise> { - return this.core.fetch('/pet/findByStatus', 'get', metadata); - } -} +import SDK from './sdk.js'; /** * Swagger Petstore diff --git a/packages/test-utils/sdks/simple/src/sdk.ts b/packages/test-utils/sdks/simple/src/sdk.ts new file mode 100644 index 00000000..a72dd598 --- /dev/null +++ b/packages/test-utils/sdks/simple/src/sdk.ts @@ -0,0 +1,81 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@api/test-utils/definitions/simple.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'simple/1.0.0 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** + * Multiple status values can be provided with comma separated strings + * + * @summary Finds Pets by status + */ + findPetsByStatus(metadata: types.FindPetsByStatusMetadataParam): Promise> { + return this.core.fetch('/pet/findByStatus', 'get', metadata); + } +} diff --git a/packages/test-utils/sdks/star-trek/package.json b/packages/test-utils/sdks/star-trek/package.json index ce7f6e3e..7167c690 100644 --- a/packages/test-utils/sdks/star-trek/package.json +++ b/packages/test-utils/sdks/star-trek/package.json @@ -10,6 +10,10 @@ "import": "./dist/index.js", "require": "./dist/index.cjs" }, + "./sdk": { + "import": "./dist/sdk.js", + "require": "./dist/sdk.cjs" + }, "./types": { "import": "./dist/types.js", "require": "./dist/types.cjs" @@ -36,6 +40,7 @@ "dts": true, "entry": [ "./src/index.ts", + "./src/sdk.ts", "./src/types.ts" ], "format": [ diff --git a/packages/test-utils/sdks/star-trek/src/index.ts b/packages/test-utils/sdks/star-trek/src/index.ts index e40890d4..2a665122 100644 --- a/packages/test-utils/sdks/star-trek/src/index.ts +++ b/packages/test-utils/sdks/star-trek/src/index.ts @@ -1,1035 +1,4 @@ -import type * as types from './types.js'; -import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; -import APICore from '@readme/api-core'; -import definition from '@readme/oas-examples/3.0/json/star-trek.json'; - -export class SDK { - core: APICore; - - constructor() { - this.core = new APICore(definition, 'star-trek/1.0.0 (api/7.0.0-mock)'); - } - - /** - * Optionally configure various options that the SDK allows. - * - * @param config Object of supported SDK options and toggles. - * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number - * should be represented in milliseconds. - */ - config(config: ConfigOptions) { - this.core.setConfig(config); - } - - /** - * If the API you're using requires authentication you can supply the required credentials - * through this method and the library will magically determine how they should be used - * within your API request. - * - * With the exception of OpenID and MutualTLS, it supports all forms of authentication - * supported by the OpenAPI specification. - * - * @example HTTP Basic auth - * sdk.auth('username', 'password'); - * - * @example Bearer tokens (HTTP or OAuth 2) - * sdk.auth('myBearerToken'); - * - * @example API Keys - * sdk.auth('myApiKey'); - * - * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} - * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} - * @param values Your auth credentials for the API; can specify up to two strings or numbers. - */ - auth(...values: string[] | number[]) { - this.core.setAuth(...values); - return this; - } - - /** - * If the API you're using offers alternate server URLs, and server variables, you can tell - * the SDK which one to use with this method. To use it you can supply either one of the - * server URLs that are contained within the OpenAPI definition (along with any server - * variables), or you can pass it a fully qualified URL to use (that may or may not exist - * within the OpenAPI definition). - * - * @example Server URL with server variables - * sdk.server('https://{region}.api.example.com/{basePath}', { - * name: 'eu', - * basePath: 'v14', - * }); - * - * @example Fully qualified server URL - * sdk.server('https://eu.api.example.com/v14'); - * - * @param url Server URL - * @param variables An object of variables to replace into the server URL. - */ - server(url: string, variables = {}) { - this.core.setServer(url, variables); - } - - /** - * Retrival of a single animal - * - */ - getAnimal(metadata: types.GetAnimalMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/animal', 'get', metadata); - } - - /** - * Pagination over animals - * - */ - getAnimalSearch(metadata?: types.GetAnimalSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/animal/search', 'get', metadata); - } - - /** - * Searching animals - * - */ - postAnimalSearch(body?: types.PostAnimalSearchFormDataParam, metadata?: types.PostAnimalSearchMetadataParam): Promise> { - return this.core.fetch('/animal/search', 'post', body, metadata); - } - - /** - * Retrival of a single astronomical object - * - */ - getAstronomicalobject(metadata: types.GetAstronomicalobjectMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/astronomicalObject', 'get', metadata); - } - - /** - * Pagination over astronomical objects - * - */ - getAstronomicalobjectSearch(metadata?: types.GetAstronomicalobjectSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/astronomicalObject/search', 'get', metadata); - } - - /** - * Searching astronomical objects - * - */ - postAstronomicalobjectSearch(body?: types.PostAstronomicalobjectSearchFormDataParam, metadata?: types.PostAstronomicalobjectSearchMetadataParam): Promise> { - return this.core.fetch('/astronomicalObject/search', 'post', body, metadata); - } - - /** - * Retrival of a single book - * - */ - getBook(metadata: types.GetBookMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/book', 'get', metadata); - } - - /** - * Pagination over books - * - */ - getBookSearch(metadata?: types.GetBookSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/book/search', 'get', metadata); - } - - /** - * Searching books - * - */ - postBookSearch(body?: types.PostBookSearchFormDataParam, metadata?: types.PostBookSearchMetadataParam): Promise> { - return this.core.fetch('/book/search', 'post', body, metadata); - } - - /** - * Retrival of a single book collection - * - */ - getBookcollection(metadata: types.GetBookcollectionMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/bookCollection', 'get', metadata); - } - - /** - * Pagination over book collections - * - */ - getBookcollectionSearch(metadata?: types.GetBookcollectionSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/bookCollection/search', 'get', metadata); - } - - /** - * Searching book collections - * - */ - postBookcollectionSearch(body?: types.PostBookcollectionSearchFormDataParam, metadata?: types.PostBookcollectionSearchMetadataParam): Promise> { - return this.core.fetch('/bookCollection/search', 'post', body, metadata); - } - - /** - * Retrival of a single book series - * - */ - getBookseries(metadata: types.GetBookseriesMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/bookSeries', 'get', metadata); - } - - /** - * Pagination over book series - * - */ - getBookseriesSearch(metadata?: types.GetBookseriesSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/bookSeries/search', 'get', metadata); - } - - /** - * Searching book series - * - */ - postBookseriesSearch(body?: types.PostBookseriesSearchFormDataParam, metadata?: types.PostBookseriesSearchMetadataParam): Promise> { - return this.core.fetch('/bookSeries/search', 'post', body, metadata); - } - - /** - * Retrival of a single character - * - */ - getCharacter(metadata: types.GetCharacterMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/character', 'get', metadata); - } - - /** - * Pagination over characters - * - */ - getCharacterSearch(metadata?: types.GetCharacterSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/character/search', 'get', metadata); - } - - /** - * Searching characters - * - */ - postCharacterSearch(body?: types.PostCharacterSearchFormDataParam, metadata?: types.PostCharacterSearchMetadataParam): Promise> { - return this.core.fetch('/character/search', 'post', body, metadata); - } - - /** - * Retrival of a single comics - * - */ - getComics(metadata: types.GetComicsMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comics', 'get', metadata); - } - - /** - * Pagination over comics - * - */ - getComicsSearch(metadata?: types.GetComicsSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comics/search', 'get', metadata); - } - - /** - * Searching comics - * - */ - postComicsSearch(body?: types.PostComicsSearchFormDataParam, metadata?: types.PostComicsSearchMetadataParam): Promise> { - return this.core.fetch('/comics/search', 'post', body, metadata); - } - - /** - * Retrival of a single comic collection - * - */ - getComiccollection(metadata: types.GetComiccollectionMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comicCollection', 'get', metadata); - } - - /** - * Pagination over comic collections - * - */ - getComiccollectionSearch(metadata?: types.GetComiccollectionSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comicCollection/search', 'get', metadata); - } - - /** - * Searching comic collections - * - */ - postComiccollectionSearch(body?: types.PostComiccollectionSearchFormDataParam, metadata?: types.PostComiccollectionSearchMetadataParam): Promise> { - return this.core.fetch('/comicCollection/search', 'post', body, metadata); - } - - /** - * Retrival of a single comic series - * - */ - getComicseries(metadata: types.GetComicseriesMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comicSeries', 'get', metadata); - } - - /** - * Pagination over comic series - * - */ - getComicseriesSearch(metadata?: types.GetComicseriesSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comicSeries/search', 'get', metadata); - } - - /** - * Searching comic series - * - */ - postComicseriesSearch(body?: types.PostComicseriesSearchFormDataParam, metadata?: types.PostComicseriesSearchMetadataParam): Promise> { - return this.core.fetch('/comicSeries/search', 'post', body, metadata); - } - - /** - * Retrival of a single comic strip - * - */ - getComicstrip(metadata: types.GetComicstripMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comicStrip', 'get', metadata); - } - - /** - * Pagination over comic strips - * - */ - getComicstripSearch(metadata?: types.GetComicstripSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/comicStrip/search', 'get', metadata); - } - - /** - * Searching comic strips - * - */ - postComicstripSearch(body?: types.PostComicstripSearchFormDataParam, metadata?: types.PostComicstripSearchMetadataParam): Promise> { - return this.core.fetch('/comicStrip/search', 'post', body, metadata); - } - - /** - * Retrival of a single company - * - */ - getCompany(metadata: types.GetCompanyMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/company', 'get', metadata); - } - - /** - * Pagination over companies - * - */ - getCompanySearch(metadata?: types.GetCompanySearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/company/search', 'get', metadata); - } - - /** - * Searching companies - * - */ - postCompanySearch(body?: types.PostCompanySearchFormDataParam, metadata?: types.PostCompanySearchMetadataParam): Promise> { - return this.core.fetch('/company/search', 'post', body, metadata); - } - - /** - * Retrival of a single conflict - * - */ - getConflict(metadata: types.GetConflictMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/conflict', 'get', metadata); - } - - /** - * Pagination over conflicts - * - */ - getConflictSearch(metadata?: types.GetConflictSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/conflict/search', 'get', metadata); - } - - /** - * Searching conflicts - * - */ - postConflictSearch(body?: types.PostConflictSearchFormDataParam, metadata?: types.PostConflictSearchMetadataParam): Promise> { - return this.core.fetch('/conflict/search', 'post', body, metadata); - } - - /** - * Retrival of a single element - * - */ - getElement(metadata: types.GetElementMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/element', 'get', metadata); - } - - /** - * Pagination over elements - * - */ - getElementSearch(metadata?: types.GetElementSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/element/search', 'get', metadata); - } - - /** - * Searching elements - * - */ - postElementSearch(body?: types.PostElementSearchFormDataParam, metadata?: types.PostElementSearchMetadataParam): Promise> { - return this.core.fetch('/element/search', 'post', body, metadata); - } - - /** - * Retrival of a single episode - * - */ - getEpisode(metadata: types.GetEpisodeMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/episode', 'get', metadata); - } - - /** - * Pagination over episodes - * - */ - getEpisodeSearch(metadata?: types.GetEpisodeSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/episode/search', 'get', metadata); - } - - /** - * Searching episodes - * - */ - postEpisodeSearch(body?: types.PostEpisodeSearchFormDataParam, metadata?: types.PostEpisodeSearchMetadataParam): Promise> { - return this.core.fetch('/episode/search', 'post', body, metadata); - } - - /** - * Retrival of a single food - * - */ - getFood(metadata: types.GetFoodMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/food', 'get', metadata); - } - - /** - * Pagination over foods - * - */ - getFoodSearch(metadata?: types.GetFoodSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/food/search', 'get', metadata); - } - - /** - * Searching foods - * - */ - postFoodSearch(body?: types.PostFoodSearchFormDataParam, metadata?: types.PostFoodSearchMetadataParam): Promise> { - return this.core.fetch('/food/search', 'post', body, metadata); - } - - /** - * Retrival of a single literature - * - */ - getLiterature(metadata: types.GetLiteratureMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/literature', 'get', metadata); - } - - /** - * Pagination over literature - * - */ - getLiteratureSearch(metadata?: types.GetLiteratureSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/literature/search', 'get', metadata); - } - - /** - * Searching literature - * - */ - postLiteratureSearch(body?: types.PostLiteratureSearchFormDataParam, metadata?: types.PostLiteratureSearchMetadataParam): Promise> { - return this.core.fetch('/literature/search', 'post', body, metadata); - } - - /** - * Retrival of a single location - * - */ - getLocation(metadata: types.GetLocationMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/location', 'get', metadata); - } - - /** - * Pagination over locations - * - */ - getLocationSearch(metadata?: types.GetLocationSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/location/search', 'get', metadata); - } - - /** - * Searching locations - * - */ - postLocationSearch(body?: types.PostLocationSearchFormDataParam, metadata?: types.PostLocationSearchMetadataParam): Promise> { - return this.core.fetch('/location/search', 'post', body, metadata); - } - - /** - * Retrival of a single magazine - * - */ - getMagazine(metadata: types.GetMagazineMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/magazine', 'get', metadata); - } - - /** - * Pagination over magazines - * - */ - getMagazineSearch(metadata?: types.GetMagazineSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/magazine/search', 'get', metadata); - } - - /** - * Searching magazines - * - */ - postMagazineSearch(body?: types.PostMagazineSearchFormDataParam, metadata?: types.PostMagazineSearchMetadataParam): Promise> { - return this.core.fetch('/magazine/search', 'post', body, metadata); - } - - /** - * Retrival of a single magazine series - * - */ - getMagazineseries(metadata: types.GetMagazineseriesMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/magazineSeries', 'get', metadata); - } - - /** - * Pagination over magazine series - * - */ - getMagazineseriesSearch(metadata?: types.GetMagazineseriesSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/magazineSeries/search', 'get', metadata); - } - - /** - * Searching magazine series - * - */ - postMagazineseriesSearch(body?: types.PostMagazineseriesSearchFormDataParam, metadata?: types.PostMagazineseriesSearchMetadataParam): Promise> { - return this.core.fetch('/magazineSeries/search', 'post', body, metadata); - } - - /** - * Retrival of a single material - * - */ - getMaterial(metadata: types.GetMaterialMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/material', 'get', metadata); - } - - /** - * Pagination over materials - * - */ - getMaterialSearch(metadata?: types.GetMaterialSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/material/search', 'get', metadata); - } - - /** - * Searching materials - * - */ - postMaterialSearch(body?: types.PostMaterialSearchFormDataParam, metadata?: types.PostMaterialSearchMetadataParam): Promise> { - return this.core.fetch('/material/search', 'post', body, metadata); - } - - /** - * Retrival of a single medical condition - * - */ - getMedicalcondition(metadata: types.GetMedicalconditionMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/medicalCondition', 'get', metadata); - } - - /** - * Pagination over medical conditions - * - */ - getMedicalconditionSearch(metadata?: types.GetMedicalconditionSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/medicalCondition/search', 'get', metadata); - } - - /** - * Searching medical conditions - * - */ - postMedicalconditionSearch(body?: types.PostMedicalconditionSearchFormDataParam, metadata?: types.PostMedicalconditionSearchMetadataParam): Promise> { - return this.core.fetch('/medicalCondition/search', 'post', body, metadata); - } - - /** - * Retrival of a single movie - * - */ - getMovie(metadata: types.GetMovieMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/movie', 'get', metadata); - } - - /** - * Pagination over movies - * - */ - getMovieSearch(metadata?: types.GetMovieSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/movie/search', 'get', metadata); - } - - /** - * Searching movies - * - */ - postMovieSearch(body?: types.PostMovieSearchFormDataParam, metadata?: types.PostMovieSearchMetadataParam): Promise> { - return this.core.fetch('/movie/search', 'post', body, metadata); - } - - /** - * Retrival of a single occupation - * - */ - getOccupation(metadata: types.GetOccupationMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/occupation', 'get', metadata); - } - - /** - * Pagination over occupations - * - */ - getOccupationSearch(metadata?: types.GetOccupationSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/occupation/search', 'get', metadata); - } - - /** - * Searching occupations - * - */ - postOccupationSearch(body?: types.PostOccupationSearchFormDataParam, metadata?: types.PostOccupationSearchMetadataParam): Promise> { - return this.core.fetch('/occupation/search', 'post', body, metadata); - } - - /** - * Retrival of a single organization - * - */ - getOrganization(metadata: types.GetOrganizationMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/organization', 'get', metadata); - } - - /** - * Pagination over organizations - * - */ - getOrganizationSearch(metadata?: types.GetOrganizationSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/organization/search', 'get', metadata); - } - - /** - * Searching organizations - * - */ - postOrganizationSearch(body?: types.PostOrganizationSearchFormDataParam, metadata?: types.PostOrganizationSearchMetadataParam): Promise> { - return this.core.fetch('/organization/search', 'post', body, metadata); - } - - /** - * Retrival of a single performer - * - */ - getPerformer(metadata: types.GetPerformerMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/performer', 'get', metadata); - } - - /** - * Pagination over performers - * - */ - getPerformerSearch(metadata?: types.GetPerformerSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/performer/search', 'get', metadata); - } - - /** - * Searching performers - * - */ - postPerformerSearch(body?: types.PostPerformerSearchFormDataParam, metadata?: types.PostPerformerSearchMetadataParam): Promise> { - return this.core.fetch('/performer/search', 'post', body, metadata); - } - - /** - * Retrival of a single season - * - */ - getSeason(metadata: types.GetSeasonMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/season', 'get', metadata); - } - - /** - * Pagination over seasons - * - */ - getSeasonSearch(metadata?: types.GetSeasonSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/season/search', 'get', metadata); - } - - /** - * Searching seasons - * - */ - postSeasonSearch(body?: types.PostSeasonSearchFormDataParam, metadata?: types.PostSeasonSearchMetadataParam): Promise> { - return this.core.fetch('/season/search', 'post', body, metadata); - } - - /** - * Retrival of a single series - * - */ - getSeries(metadata: types.GetSeriesMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/series', 'get', metadata); - } - - /** - * Pagination over series - * - */ - getSeriesSearch(metadata?: types.GetSeriesSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/series/search', 'get', metadata); - } - - /** - * Searching series - * - */ - postSeriesSearch(body?: types.PostSeriesSearchFormDataParam, metadata?: types.PostSeriesSearchMetadataParam): Promise> { - return this.core.fetch('/series/search', 'post', body, metadata); - } - - /** - * Retrival of a single soundtrack - * - */ - getSoundtrack(metadata: types.GetSoundtrackMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/soundtrack', 'get', metadata); - } - - /** - * Pagination over soundtracks - * - */ - getSoundtrackSearch(metadata?: types.GetSoundtrackSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/soundtrack/search', 'get', metadata); - } - - /** - * Searching soundtracks - * - */ - postSoundtrackSearch(body?: types.PostSoundtrackSearchFormDataParam, metadata?: types.PostSoundtrackSearchMetadataParam): Promise> { - return this.core.fetch('/soundtrack/search', 'post', body, metadata); - } - - /** - * Retrival of a single spacecraft - * - */ - getSpacecraft(metadata: types.GetSpacecraftMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/spacecraft', 'get', metadata); - } - - /** - * Pagination over spacecrafts - * - */ - getSpacecraftSearch(metadata?: types.GetSpacecraftSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/spacecraft/search', 'get', metadata); - } - - /** - * Searching spacecrafts - * - */ - postSpacecraftSearch(body?: types.PostSpacecraftSearchFormDataParam, metadata?: types.PostSpacecraftSearchMetadataParam): Promise> { - return this.core.fetch('/spacecraft/search', 'post', body, metadata); - } - - /** - * Retrival of a single spacecraft class - * - */ - getSpacecraftclass(metadata: types.GetSpacecraftclassMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/spacecraftClass', 'get', metadata); - } - - /** - * Pagination over spacecraft classes - * - */ - getSpacecraftclassSearch(metadata?: types.GetSpacecraftclassSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/spacecraftClass/search', 'get', metadata); - } - - /** - * Searching spacecraft classes - * - */ - postSpacecraftclassSearch(body?: types.PostSpacecraftclassSearchFormDataParam, metadata?: types.PostSpacecraftclassSearchMetadataParam): Promise> { - return this.core.fetch('/spacecraftClass/search', 'post', body, metadata); - } - - /** - * Retrival of a single species - * - */ - getSpecies(metadata: types.GetSpeciesMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/species', 'get', metadata); - } - - /** - * Pagination over species - * - */ - getSpeciesSearch(metadata?: types.GetSpeciesSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/species/search', 'get', metadata); - } - - /** - * Searching species - * - */ - postSpeciesSearch(body?: types.PostSpeciesSearchFormDataParam, metadata?: types.PostSpeciesSearchMetadataParam): Promise> { - return this.core.fetch('/species/search', 'post', body, metadata); - } - - /** - * Retrival of a single staff - * - */ - getStaff(metadata: types.GetStaffMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/staff', 'get', metadata); - } - - /** - * Pagination over staff - * - */ - getStaffSearch(metadata?: types.GetStaffSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/staff/search', 'get', metadata); - } - - /** - * Searching staff - * - */ - postStaffSearch(body?: types.PostStaffSearchFormDataParam, metadata?: types.PostStaffSearchMetadataParam): Promise> { - return this.core.fetch('/staff/search', 'post', body, metadata); - } - - /** - * Retrival of a single technology - * - */ - getTechnology(metadata: types.GetTechnologyMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/technology', 'get', metadata); - } - - /** - * Pagination over technology - * - */ - getTechnologySearch(metadata?: types.GetTechnologySearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/technology/search', 'get', metadata); - } - - /** - * Searching technology - * - */ - postTechnologySearch(body?: types.PostTechnologySearchFormDataParam, metadata?: types.PostTechnologySearchMetadataParam): Promise> { - return this.core.fetch('/technology/search', 'post', body, metadata); - } - - /** - * Retrival of a single title - * - */ - getTitle(metadata: types.GetTitleMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/title', 'get', metadata); - } - - /** - * Pagination over titles - * - */ - getTitleSearch(metadata?: types.GetTitleSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/title/search', 'get', metadata); - } - - /** - * Searching titles - * - */ - postTitleSearch(body?: types.PostTitleSearchFormDataParam, metadata?: types.PostTitleSearchMetadataParam): Promise> { - return this.core.fetch('/title/search', 'post', body, metadata); - } - - /** - * Retrival of a single trading card - * - */ - getTradingcard(metadata: types.GetTradingcardMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/tradingCard', 'get', metadata); - } - - /** - * Pagination over trading cards - * - */ - getTradingcardSearch(metadata?: types.GetTradingcardSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/tradingCard/search', 'get', metadata); - } - - /** - * Searching trading cards - * - */ - postTradingcardSearch(body?: types.PostTradingcardSearchFormDataParam, metadata?: types.PostTradingcardSearchMetadataParam): Promise> { - return this.core.fetch('/tradingCard/search', 'post', body, metadata); - } - - /** - * Retrival of a single trading card deck - * - */ - getTradingcarddeck(metadata: types.GetTradingcarddeckMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/tradingCardDeck', 'get', metadata); - } - - /** - * Pagination over trading card decks - * - */ - getTradingcarddeckSearch(metadata?: types.GetTradingcarddeckSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/tradingCardDeck/search', 'get', metadata); - } - - /** - * Searching trading card decks - * - */ - postTradingcarddeckSearch(body?: types.PostTradingcarddeckSearchFormDataParam, metadata?: types.PostTradingcarddeckSearchMetadataParam): Promise> { - return this.core.fetch('/tradingCardDeck/search', 'post', body, metadata); - } - - /** - * Retrival of a single trading card set - * - */ - getTradingcardset(metadata: types.GetTradingcardsetMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/tradingCardSet', 'get', metadata); - } - - /** - * Pagination over trading card sets - * - */ - getTradingcardsetSearch(metadata?: types.GetTradingcardsetSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/tradingCardSet/search', 'get', metadata); - } - - /** - * Searching trading card sets - * - */ - postTradingcardsetSearch(body?: types.PostTradingcardsetSearchFormDataParam, metadata?: types.PostTradingcardsetSearchMetadataParam): Promise> { - return this.core.fetch('/tradingCardSet/search', 'post', body, metadata); - } - - /** - * Retrival of a single video game - * - */ - getVideogame(metadata: types.GetVideogameMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/videoGame', 'get', metadata); - } - - /** - * Pagination over video games - * - */ - getVideogameSearch(metadata?: types.GetVideogameSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/videoGame/search', 'get', metadata); - } - - /** - * Searching video games - * - */ - postVideogameSearch(body?: types.PostVideogameSearchFormDataParam, metadata?: types.PostVideogameSearchMetadataParam): Promise> { - return this.core.fetch('/videoGame/search', 'post', body, metadata); - } - - /** - * Retrival of a single video release - * - */ - getVideorelease(metadata: types.GetVideoreleaseMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/videoRelease', 'get', metadata); - } - - /** - * Pagination over video releases - * - */ - getVideoreleaseSearch(metadata?: types.GetVideoreleaseSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/videoRelease/search', 'get', metadata); - } - - /** - * Searching video releases - * - */ - postVideoreleaseSearch(body?: types.PostVideoreleaseSearchFormDataParam, metadata?: types.PostVideoreleaseSearchMetadataParam): Promise> { - return this.core.fetch('/videoRelease/search', 'post', body, metadata); - } - - /** - * Retrival of a single weapon - * - */ - getWeapon(metadata: types.GetWeaponMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/weapon', 'get', metadata); - } - - /** - * Pagination over weapons - * - */ - getWeaponSearch(metadata?: types.GetWeaponSearchMetadataParam): Promise | FetchResponse> { - return this.core.fetch('/weapon/search', 'get', metadata); - } - - /** - * Searching weapons - * - */ - postWeaponSearch(body?: types.PostWeaponSearchFormDataParam, metadata?: types.PostWeaponSearchMetadataParam): Promise> { - return this.core.fetch('/weapon/search', 'post', body, metadata); - } -} +import SDK from './sdk.js'; /** * STAPI diff --git a/packages/test-utils/sdks/star-trek/src/sdk.ts b/packages/test-utils/sdks/star-trek/src/sdk.ts new file mode 100644 index 00000000..38178b28 --- /dev/null +++ b/packages/test-utils/sdks/star-trek/src/sdk.ts @@ -0,0 +1,1032 @@ +import type * as types from './types.js'; +import type { ConfigOptions, FetchResponse } from '@readme/api-core/types'; +import APICore from '@readme/api-core'; +import definition from '@readme/oas-examples/3.0/json/star-trek.json'; + +export default class SDK { + core: APICore; + + constructor() { + this.core = new APICore(definition, 'star-trek/1.0.0 (api/7.0.0-mock)'); + } + + /** + * Optionally configure various options that the SDK allows. + * + * @param config Object of supported SDK options and toggles. + * @param config.timeout Override the default `fetch` request timeout of 30 seconds. This number + * should be represented in milliseconds. + */ + config(config: ConfigOptions) { + this.core.setConfig(config); + } + + /** + * If the API you're using requires authentication you can supply the required credentials + * through this method and the library will magically determine how they should be used + * within your API request. + * + * With the exception of OpenID and MutualTLS, it supports all forms of authentication + * supported by the OpenAPI specification. + * + * @example HTTP Basic auth + * sdk.auth('username', 'password'); + * + * @example Bearer tokens (HTTP or OAuth 2) + * sdk.auth('myBearerToken'); + * + * @example API Keys + * sdk.auth('myApiKey'); + * + * @see {@link https://spec.openapis.org/oas/v3.0.3#fixed-fields-22} + * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-22} + * @param values Your auth credentials for the API; can specify up to two strings or numbers. + */ + auth(...values: string[] | number[]) { + this.core.setAuth(...values); + return this; + } + + /** + * If the API you're using offers alternate server URLs, and server variables, you can tell + * the SDK which one to use with this method. To use it you can supply either one of the + * server URLs that are contained within the OpenAPI definition (along with any server + * variables), or you can pass it a fully qualified URL to use (that may or may not exist + * within the OpenAPI definition). + * + * @example Server URL with server variables + * sdk.server('https://{region}.api.example.com/{basePath}', { + * name: 'eu', + * basePath: 'v14', + * }); + * + * @example Fully qualified server URL + * sdk.server('https://eu.api.example.com/v14'); + * + * @param url Server URL + * @param variables An object of variables to replace into the server URL. + */ + server(url: string, variables = {}) { + this.core.setServer(url, variables); + } + + /** + * Retrival of a single animal + * + */ + getAnimal(metadata: types.GetAnimalMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/animal', 'get', metadata); + } + + /** + * Pagination over animals + * + */ + getAnimalSearch(metadata?: types.GetAnimalSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/animal/search', 'get', metadata); + } + + /** + * Searching animals + * + */ + postAnimalSearch(body?: types.PostAnimalSearchFormDataParam, metadata?: types.PostAnimalSearchMetadataParam): Promise> { + return this.core.fetch('/animal/search', 'post', body, metadata); + } + + /** + * Retrival of a single astronomical object + * + */ + getAstronomicalobject(metadata: types.GetAstronomicalobjectMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/astronomicalObject', 'get', metadata); + } + + /** + * Pagination over astronomical objects + * + */ + getAstronomicalobjectSearch(metadata?: types.GetAstronomicalobjectSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/astronomicalObject/search', 'get', metadata); + } + + /** + * Searching astronomical objects + * + */ + postAstronomicalobjectSearch(body?: types.PostAstronomicalobjectSearchFormDataParam, metadata?: types.PostAstronomicalobjectSearchMetadataParam): Promise> { + return this.core.fetch('/astronomicalObject/search', 'post', body, metadata); + } + + /** + * Retrival of a single book + * + */ + getBook(metadata: types.GetBookMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/book', 'get', metadata); + } + + /** + * Pagination over books + * + */ + getBookSearch(metadata?: types.GetBookSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/book/search', 'get', metadata); + } + + /** + * Searching books + * + */ + postBookSearch(body?: types.PostBookSearchFormDataParam, metadata?: types.PostBookSearchMetadataParam): Promise> { + return this.core.fetch('/book/search', 'post', body, metadata); + } + + /** + * Retrival of a single book collection + * + */ + getBookcollection(metadata: types.GetBookcollectionMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/bookCollection', 'get', metadata); + } + + /** + * Pagination over book collections + * + */ + getBookcollectionSearch(metadata?: types.GetBookcollectionSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/bookCollection/search', 'get', metadata); + } + + /** + * Searching book collections + * + */ + postBookcollectionSearch(body?: types.PostBookcollectionSearchFormDataParam, metadata?: types.PostBookcollectionSearchMetadataParam): Promise> { + return this.core.fetch('/bookCollection/search', 'post', body, metadata); + } + + /** + * Retrival of a single book series + * + */ + getBookseries(metadata: types.GetBookseriesMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/bookSeries', 'get', metadata); + } + + /** + * Pagination over book series + * + */ + getBookseriesSearch(metadata?: types.GetBookseriesSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/bookSeries/search', 'get', metadata); + } + + /** + * Searching book series + * + */ + postBookseriesSearch(body?: types.PostBookseriesSearchFormDataParam, metadata?: types.PostBookseriesSearchMetadataParam): Promise> { + return this.core.fetch('/bookSeries/search', 'post', body, metadata); + } + + /** + * Retrival of a single character + * + */ + getCharacter(metadata: types.GetCharacterMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/character', 'get', metadata); + } + + /** + * Pagination over characters + * + */ + getCharacterSearch(metadata?: types.GetCharacterSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/character/search', 'get', metadata); + } + + /** + * Searching characters + * + */ + postCharacterSearch(body?: types.PostCharacterSearchFormDataParam, metadata?: types.PostCharacterSearchMetadataParam): Promise> { + return this.core.fetch('/character/search', 'post', body, metadata); + } + + /** + * Retrival of a single comics + * + */ + getComics(metadata: types.GetComicsMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comics', 'get', metadata); + } + + /** + * Pagination over comics + * + */ + getComicsSearch(metadata?: types.GetComicsSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comics/search', 'get', metadata); + } + + /** + * Searching comics + * + */ + postComicsSearch(body?: types.PostComicsSearchFormDataParam, metadata?: types.PostComicsSearchMetadataParam): Promise> { + return this.core.fetch('/comics/search', 'post', body, metadata); + } + + /** + * Retrival of a single comic collection + * + */ + getComiccollection(metadata: types.GetComiccollectionMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comicCollection', 'get', metadata); + } + + /** + * Pagination over comic collections + * + */ + getComiccollectionSearch(metadata?: types.GetComiccollectionSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comicCollection/search', 'get', metadata); + } + + /** + * Searching comic collections + * + */ + postComiccollectionSearch(body?: types.PostComiccollectionSearchFormDataParam, metadata?: types.PostComiccollectionSearchMetadataParam): Promise> { + return this.core.fetch('/comicCollection/search', 'post', body, metadata); + } + + /** + * Retrival of a single comic series + * + */ + getComicseries(metadata: types.GetComicseriesMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comicSeries', 'get', metadata); + } + + /** + * Pagination over comic series + * + */ + getComicseriesSearch(metadata?: types.GetComicseriesSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comicSeries/search', 'get', metadata); + } + + /** + * Searching comic series + * + */ + postComicseriesSearch(body?: types.PostComicseriesSearchFormDataParam, metadata?: types.PostComicseriesSearchMetadataParam): Promise> { + return this.core.fetch('/comicSeries/search', 'post', body, metadata); + } + + /** + * Retrival of a single comic strip + * + */ + getComicstrip(metadata: types.GetComicstripMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comicStrip', 'get', metadata); + } + + /** + * Pagination over comic strips + * + */ + getComicstripSearch(metadata?: types.GetComicstripSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/comicStrip/search', 'get', metadata); + } + + /** + * Searching comic strips + * + */ + postComicstripSearch(body?: types.PostComicstripSearchFormDataParam, metadata?: types.PostComicstripSearchMetadataParam): Promise> { + return this.core.fetch('/comicStrip/search', 'post', body, metadata); + } + + /** + * Retrival of a single company + * + */ + getCompany(metadata: types.GetCompanyMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/company', 'get', metadata); + } + + /** + * Pagination over companies + * + */ + getCompanySearch(metadata?: types.GetCompanySearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/company/search', 'get', metadata); + } + + /** + * Searching companies + * + */ + postCompanySearch(body?: types.PostCompanySearchFormDataParam, metadata?: types.PostCompanySearchMetadataParam): Promise> { + return this.core.fetch('/company/search', 'post', body, metadata); + } + + /** + * Retrival of a single conflict + * + */ + getConflict(metadata: types.GetConflictMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/conflict', 'get', metadata); + } + + /** + * Pagination over conflicts + * + */ + getConflictSearch(metadata?: types.GetConflictSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/conflict/search', 'get', metadata); + } + + /** + * Searching conflicts + * + */ + postConflictSearch(body?: types.PostConflictSearchFormDataParam, metadata?: types.PostConflictSearchMetadataParam): Promise> { + return this.core.fetch('/conflict/search', 'post', body, metadata); + } + + /** + * Retrival of a single element + * + */ + getElement(metadata: types.GetElementMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/element', 'get', metadata); + } + + /** + * Pagination over elements + * + */ + getElementSearch(metadata?: types.GetElementSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/element/search', 'get', metadata); + } + + /** + * Searching elements + * + */ + postElementSearch(body?: types.PostElementSearchFormDataParam, metadata?: types.PostElementSearchMetadataParam): Promise> { + return this.core.fetch('/element/search', 'post', body, metadata); + } + + /** + * Retrival of a single episode + * + */ + getEpisode(metadata: types.GetEpisodeMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/episode', 'get', metadata); + } + + /** + * Pagination over episodes + * + */ + getEpisodeSearch(metadata?: types.GetEpisodeSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/episode/search', 'get', metadata); + } + + /** + * Searching episodes + * + */ + postEpisodeSearch(body?: types.PostEpisodeSearchFormDataParam, metadata?: types.PostEpisodeSearchMetadataParam): Promise> { + return this.core.fetch('/episode/search', 'post', body, metadata); + } + + /** + * Retrival of a single food + * + */ + getFood(metadata: types.GetFoodMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/food', 'get', metadata); + } + + /** + * Pagination over foods + * + */ + getFoodSearch(metadata?: types.GetFoodSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/food/search', 'get', metadata); + } + + /** + * Searching foods + * + */ + postFoodSearch(body?: types.PostFoodSearchFormDataParam, metadata?: types.PostFoodSearchMetadataParam): Promise> { + return this.core.fetch('/food/search', 'post', body, metadata); + } + + /** + * Retrival of a single literature + * + */ + getLiterature(metadata: types.GetLiteratureMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/literature', 'get', metadata); + } + + /** + * Pagination over literature + * + */ + getLiteratureSearch(metadata?: types.GetLiteratureSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/literature/search', 'get', metadata); + } + + /** + * Searching literature + * + */ + postLiteratureSearch(body?: types.PostLiteratureSearchFormDataParam, metadata?: types.PostLiteratureSearchMetadataParam): Promise> { + return this.core.fetch('/literature/search', 'post', body, metadata); + } + + /** + * Retrival of a single location + * + */ + getLocation(metadata: types.GetLocationMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/location', 'get', metadata); + } + + /** + * Pagination over locations + * + */ + getLocationSearch(metadata?: types.GetLocationSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/location/search', 'get', metadata); + } + + /** + * Searching locations + * + */ + postLocationSearch(body?: types.PostLocationSearchFormDataParam, metadata?: types.PostLocationSearchMetadataParam): Promise> { + return this.core.fetch('/location/search', 'post', body, metadata); + } + + /** + * Retrival of a single magazine + * + */ + getMagazine(metadata: types.GetMagazineMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/magazine', 'get', metadata); + } + + /** + * Pagination over magazines + * + */ + getMagazineSearch(metadata?: types.GetMagazineSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/magazine/search', 'get', metadata); + } + + /** + * Searching magazines + * + */ + postMagazineSearch(body?: types.PostMagazineSearchFormDataParam, metadata?: types.PostMagazineSearchMetadataParam): Promise> { + return this.core.fetch('/magazine/search', 'post', body, metadata); + } + + /** + * Retrival of a single magazine series + * + */ + getMagazineseries(metadata: types.GetMagazineseriesMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/magazineSeries', 'get', metadata); + } + + /** + * Pagination over magazine series + * + */ + getMagazineseriesSearch(metadata?: types.GetMagazineseriesSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/magazineSeries/search', 'get', metadata); + } + + /** + * Searching magazine series + * + */ + postMagazineseriesSearch(body?: types.PostMagazineseriesSearchFormDataParam, metadata?: types.PostMagazineseriesSearchMetadataParam): Promise> { + return this.core.fetch('/magazineSeries/search', 'post', body, metadata); + } + + /** + * Retrival of a single material + * + */ + getMaterial(metadata: types.GetMaterialMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/material', 'get', metadata); + } + + /** + * Pagination over materials + * + */ + getMaterialSearch(metadata?: types.GetMaterialSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/material/search', 'get', metadata); + } + + /** + * Searching materials + * + */ + postMaterialSearch(body?: types.PostMaterialSearchFormDataParam, metadata?: types.PostMaterialSearchMetadataParam): Promise> { + return this.core.fetch('/material/search', 'post', body, metadata); + } + + /** + * Retrival of a single medical condition + * + */ + getMedicalcondition(metadata: types.GetMedicalconditionMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/medicalCondition', 'get', metadata); + } + + /** + * Pagination over medical conditions + * + */ + getMedicalconditionSearch(metadata?: types.GetMedicalconditionSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/medicalCondition/search', 'get', metadata); + } + + /** + * Searching medical conditions + * + */ + postMedicalconditionSearch(body?: types.PostMedicalconditionSearchFormDataParam, metadata?: types.PostMedicalconditionSearchMetadataParam): Promise> { + return this.core.fetch('/medicalCondition/search', 'post', body, metadata); + } + + /** + * Retrival of a single movie + * + */ + getMovie(metadata: types.GetMovieMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/movie', 'get', metadata); + } + + /** + * Pagination over movies + * + */ + getMovieSearch(metadata?: types.GetMovieSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/movie/search', 'get', metadata); + } + + /** + * Searching movies + * + */ + postMovieSearch(body?: types.PostMovieSearchFormDataParam, metadata?: types.PostMovieSearchMetadataParam): Promise> { + return this.core.fetch('/movie/search', 'post', body, metadata); + } + + /** + * Retrival of a single occupation + * + */ + getOccupation(metadata: types.GetOccupationMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/occupation', 'get', metadata); + } + + /** + * Pagination over occupations + * + */ + getOccupationSearch(metadata?: types.GetOccupationSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/occupation/search', 'get', metadata); + } + + /** + * Searching occupations + * + */ + postOccupationSearch(body?: types.PostOccupationSearchFormDataParam, metadata?: types.PostOccupationSearchMetadataParam): Promise> { + return this.core.fetch('/occupation/search', 'post', body, metadata); + } + + /** + * Retrival of a single organization + * + */ + getOrganization(metadata: types.GetOrganizationMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/organization', 'get', metadata); + } + + /** + * Pagination over organizations + * + */ + getOrganizationSearch(metadata?: types.GetOrganizationSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/organization/search', 'get', metadata); + } + + /** + * Searching organizations + * + */ + postOrganizationSearch(body?: types.PostOrganizationSearchFormDataParam, metadata?: types.PostOrganizationSearchMetadataParam): Promise> { + return this.core.fetch('/organization/search', 'post', body, metadata); + } + + /** + * Retrival of a single performer + * + */ + getPerformer(metadata: types.GetPerformerMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/performer', 'get', metadata); + } + + /** + * Pagination over performers + * + */ + getPerformerSearch(metadata?: types.GetPerformerSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/performer/search', 'get', metadata); + } + + /** + * Searching performers + * + */ + postPerformerSearch(body?: types.PostPerformerSearchFormDataParam, metadata?: types.PostPerformerSearchMetadataParam): Promise> { + return this.core.fetch('/performer/search', 'post', body, metadata); + } + + /** + * Retrival of a single season + * + */ + getSeason(metadata: types.GetSeasonMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/season', 'get', metadata); + } + + /** + * Pagination over seasons + * + */ + getSeasonSearch(metadata?: types.GetSeasonSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/season/search', 'get', metadata); + } + + /** + * Searching seasons + * + */ + postSeasonSearch(body?: types.PostSeasonSearchFormDataParam, metadata?: types.PostSeasonSearchMetadataParam): Promise> { + return this.core.fetch('/season/search', 'post', body, metadata); + } + + /** + * Retrival of a single series + * + */ + getSeries(metadata: types.GetSeriesMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/series', 'get', metadata); + } + + /** + * Pagination over series + * + */ + getSeriesSearch(metadata?: types.GetSeriesSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/series/search', 'get', metadata); + } + + /** + * Searching series + * + */ + postSeriesSearch(body?: types.PostSeriesSearchFormDataParam, metadata?: types.PostSeriesSearchMetadataParam): Promise> { + return this.core.fetch('/series/search', 'post', body, metadata); + } + + /** + * Retrival of a single soundtrack + * + */ + getSoundtrack(metadata: types.GetSoundtrackMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/soundtrack', 'get', metadata); + } + + /** + * Pagination over soundtracks + * + */ + getSoundtrackSearch(metadata?: types.GetSoundtrackSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/soundtrack/search', 'get', metadata); + } + + /** + * Searching soundtracks + * + */ + postSoundtrackSearch(body?: types.PostSoundtrackSearchFormDataParam, metadata?: types.PostSoundtrackSearchMetadataParam): Promise> { + return this.core.fetch('/soundtrack/search', 'post', body, metadata); + } + + /** + * Retrival of a single spacecraft + * + */ + getSpacecraft(metadata: types.GetSpacecraftMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/spacecraft', 'get', metadata); + } + + /** + * Pagination over spacecrafts + * + */ + getSpacecraftSearch(metadata?: types.GetSpacecraftSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/spacecraft/search', 'get', metadata); + } + + /** + * Searching spacecrafts + * + */ + postSpacecraftSearch(body?: types.PostSpacecraftSearchFormDataParam, metadata?: types.PostSpacecraftSearchMetadataParam): Promise> { + return this.core.fetch('/spacecraft/search', 'post', body, metadata); + } + + /** + * Retrival of a single spacecraft class + * + */ + getSpacecraftclass(metadata: types.GetSpacecraftclassMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/spacecraftClass', 'get', metadata); + } + + /** + * Pagination over spacecraft classes + * + */ + getSpacecraftclassSearch(metadata?: types.GetSpacecraftclassSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/spacecraftClass/search', 'get', metadata); + } + + /** + * Searching spacecraft classes + * + */ + postSpacecraftclassSearch(body?: types.PostSpacecraftclassSearchFormDataParam, metadata?: types.PostSpacecraftclassSearchMetadataParam): Promise> { + return this.core.fetch('/spacecraftClass/search', 'post', body, metadata); + } + + /** + * Retrival of a single species + * + */ + getSpecies(metadata: types.GetSpeciesMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/species', 'get', metadata); + } + + /** + * Pagination over species + * + */ + getSpeciesSearch(metadata?: types.GetSpeciesSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/species/search', 'get', metadata); + } + + /** + * Searching species + * + */ + postSpeciesSearch(body?: types.PostSpeciesSearchFormDataParam, metadata?: types.PostSpeciesSearchMetadataParam): Promise> { + return this.core.fetch('/species/search', 'post', body, metadata); + } + + /** + * Retrival of a single staff + * + */ + getStaff(metadata: types.GetStaffMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/staff', 'get', metadata); + } + + /** + * Pagination over staff + * + */ + getStaffSearch(metadata?: types.GetStaffSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/staff/search', 'get', metadata); + } + + /** + * Searching staff + * + */ + postStaffSearch(body?: types.PostStaffSearchFormDataParam, metadata?: types.PostStaffSearchMetadataParam): Promise> { + return this.core.fetch('/staff/search', 'post', body, metadata); + } + + /** + * Retrival of a single technology + * + */ + getTechnology(metadata: types.GetTechnologyMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/technology', 'get', metadata); + } + + /** + * Pagination over technology + * + */ + getTechnologySearch(metadata?: types.GetTechnologySearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/technology/search', 'get', metadata); + } + + /** + * Searching technology + * + */ + postTechnologySearch(body?: types.PostTechnologySearchFormDataParam, metadata?: types.PostTechnologySearchMetadataParam): Promise> { + return this.core.fetch('/technology/search', 'post', body, metadata); + } + + /** + * Retrival of a single title + * + */ + getTitle(metadata: types.GetTitleMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/title', 'get', metadata); + } + + /** + * Pagination over titles + * + */ + getTitleSearch(metadata?: types.GetTitleSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/title/search', 'get', metadata); + } + + /** + * Searching titles + * + */ + postTitleSearch(body?: types.PostTitleSearchFormDataParam, metadata?: types.PostTitleSearchMetadataParam): Promise> { + return this.core.fetch('/title/search', 'post', body, metadata); + } + + /** + * Retrival of a single trading card + * + */ + getTradingcard(metadata: types.GetTradingcardMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/tradingCard', 'get', metadata); + } + + /** + * Pagination over trading cards + * + */ + getTradingcardSearch(metadata?: types.GetTradingcardSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/tradingCard/search', 'get', metadata); + } + + /** + * Searching trading cards + * + */ + postTradingcardSearch(body?: types.PostTradingcardSearchFormDataParam, metadata?: types.PostTradingcardSearchMetadataParam): Promise> { + return this.core.fetch('/tradingCard/search', 'post', body, metadata); + } + + /** + * Retrival of a single trading card deck + * + */ + getTradingcarddeck(metadata: types.GetTradingcarddeckMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/tradingCardDeck', 'get', metadata); + } + + /** + * Pagination over trading card decks + * + */ + getTradingcarddeckSearch(metadata?: types.GetTradingcarddeckSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/tradingCardDeck/search', 'get', metadata); + } + + /** + * Searching trading card decks + * + */ + postTradingcarddeckSearch(body?: types.PostTradingcarddeckSearchFormDataParam, metadata?: types.PostTradingcarddeckSearchMetadataParam): Promise> { + return this.core.fetch('/tradingCardDeck/search', 'post', body, metadata); + } + + /** + * Retrival of a single trading card set + * + */ + getTradingcardset(metadata: types.GetTradingcardsetMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/tradingCardSet', 'get', metadata); + } + + /** + * Pagination over trading card sets + * + */ + getTradingcardsetSearch(metadata?: types.GetTradingcardsetSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/tradingCardSet/search', 'get', metadata); + } + + /** + * Searching trading card sets + * + */ + postTradingcardsetSearch(body?: types.PostTradingcardsetSearchFormDataParam, metadata?: types.PostTradingcardsetSearchMetadataParam): Promise> { + return this.core.fetch('/tradingCardSet/search', 'post', body, metadata); + } + + /** + * Retrival of a single video game + * + */ + getVideogame(metadata: types.GetVideogameMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/videoGame', 'get', metadata); + } + + /** + * Pagination over video games + * + */ + getVideogameSearch(metadata?: types.GetVideogameSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/videoGame/search', 'get', metadata); + } + + /** + * Searching video games + * + */ + postVideogameSearch(body?: types.PostVideogameSearchFormDataParam, metadata?: types.PostVideogameSearchMetadataParam): Promise> { + return this.core.fetch('/videoGame/search', 'post', body, metadata); + } + + /** + * Retrival of a single video release + * + */ + getVideorelease(metadata: types.GetVideoreleaseMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/videoRelease', 'get', metadata); + } + + /** + * Pagination over video releases + * + */ + getVideoreleaseSearch(metadata?: types.GetVideoreleaseSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/videoRelease/search', 'get', metadata); + } + + /** + * Searching video releases + * + */ + postVideoreleaseSearch(body?: types.PostVideoreleaseSearchFormDataParam, metadata?: types.PostVideoreleaseSearchMetadataParam): Promise> { + return this.core.fetch('/videoRelease/search', 'post', body, metadata); + } + + /** + * Retrival of a single weapon + * + */ + getWeapon(metadata: types.GetWeaponMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/weapon', 'get', metadata); + } + + /** + * Pagination over weapons + * + */ + getWeaponSearch(metadata?: types.GetWeaponSearchMetadataParam): Promise | FetchResponse> { + return this.core.fetch('/weapon/search', 'get', metadata); + } + + /** + * Searching weapons + * + */ + postWeaponSearch(body?: types.PostWeaponSearchFormDataParam, metadata?: types.PostWeaponSearchMetadataParam): Promise> { + return this.core.fetch('/weapon/search', 'post', body, metadata); + } +}