diff --git a/README.md b/README.md index d67d2cd..5bb8fb5 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ - + ## SDK Installation ### NPM @@ -20,16 +20,17 @@ npm add https://github.com/speakeasy-sdks/petstore-typescript-sdk ```bash yarn add https://github.com/speakeasy-sdks/petstore-typescript-sdk ``` - + + ## SDK Example Usage - + ### Example ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async () => { +async function run() { const sdk = new SwaggerPetstore(); const res = await sdk.pets.createPets(); @@ -37,39 +38,26 @@ import { SwaggerPetstore } from "Swagger-Petstore"; if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` - + - + ## Available Resources and Operations - ### [pets](docs/sdks/pets/README.md) * [createPets](docs/sdks/pets/README.md#createpets) - Create a pet * [listPets](docs/sdks/pets/README.md#listpets) - List all pets * [showPetById](docs/sdks/pets/README.md#showpetbyid) - Info for a specific pet - - - - - - - -# Pagination + -Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the -returned response object will have a `next` method that can be called to pull down the next group of results. If the -return value of `next` is `null`, then there are no more pages to be fetched. -Here's an example of one such pagination call: - - - - + ## Error Handling Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type. @@ -83,25 +71,32 @@ Example ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async () => { +async function run() { const sdk = new SwaggerPetstore(); let res; try { res = await sdk.pets.createPets(); - } catch (e) {} + } catch (err) { + if (err instanceof errors.SDKError) { + console.error(err); // handle exception + throw err; + } + } if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` - + - + ## Server Selection ### Select Server by Index @@ -117,7 +112,7 @@ You can override the default server globally by passing a server index to the `s ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async () => { +async function run() { const sdk = new SwaggerPetstore({ serverIdx: 0, }); @@ -127,7 +122,9 @@ import { SwaggerPetstore } from "Swagger-Petstore"; if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` @@ -138,7 +135,7 @@ The default server can also be overridden globally by passing a URL to the `serv ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async () => { +async function run() { const sdk = new SwaggerPetstore({ serverURL: "http://petstore.swagger.io/v1", }); @@ -148,23 +145,25 @@ import { SwaggerPetstore } from "Swagger-Petstore"; if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` - + - + ## Custom HTTP Client -The Typescript SDK makes API calls using the (axios)[https://axios-http.com/docs/intro] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `AxiosInstance` object. +The Typescript SDK makes API calls using the [axios](https://axios-http.com/docs/intro) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `AxiosInstance` object. For example, you could specify a header for every request that your sdk makes as follows: ```typescript -from Swagger-Petstore import SwaggerPetstore; -import axios; +import { Swagger-Petstore } from "SwaggerPetstore"; +import axios from "axios"; const httpClient = axios.create({ headers: {'x-custom-header': 'someValue'} @@ -172,7 +171,7 @@ const httpClient = axios.create({ const sdk = new SwaggerPetstore({defaultClient: httpClient}); ``` - + diff --git a/RELEASES.md b/RELEASES.md index b3e0dd1..392d806 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -70,4 +70,12 @@ Based on: - OpenAPI Doc 1.0.0 - Speakeasy CLI 1.121.1 (2.194.1) https://github.com/speakeasy-api/speakeasy ### Generated -- [typescript v0.4.4] . \ No newline at end of file +- [typescript v0.4.4] . + +## 2023-12-12 01:25:17 +### Changes +Based on: +- OpenAPI Doc 1.0.0 +- Speakeasy CLI 1.126.0 (2.213.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.5.0] . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index f597e99..f039d54 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1,8 +1,8 @@ - + ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async () => { +async function run() { const sdk = new SwaggerPetstore(); const res = await sdk.pets.createPets(); @@ -10,7 +10,9 @@ import { SwaggerPetstore } from "Swagger-Petstore"; if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` - \ No newline at end of file + \ No newline at end of file diff --git a/docs/sdks/pets/README.md b/docs/sdks/pets/README.md index 9ea7e02..9cbb4fd 100644 --- a/docs/sdks/pets/README.md +++ b/docs/sdks/pets/README.md @@ -16,7 +16,7 @@ Create a pet ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async() => { +async function run() { const sdk = new SwaggerPetstore(); const res = await sdk.pets.createPets(); @@ -24,7 +24,9 @@ import { SwaggerPetstore } from "Swagger-Petstore"; if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` ### Parameters @@ -52,7 +54,7 @@ List all pets ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async() => { +async function run() { const sdk = new SwaggerPetstore(); const res = await sdk.pets.listPets({}); @@ -60,7 +62,9 @@ import { SwaggerPetstore } from "Swagger-Petstore"; if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` ### Parameters @@ -89,7 +93,7 @@ Info for a specific pet ```typescript import { SwaggerPetstore } from "Swagger-Petstore"; -(async() => { +async function run() { const sdk = new SwaggerPetstore(); const res = await sdk.pets.showPetById({ @@ -99,7 +103,9 @@ import { SwaggerPetstore } from "Swagger-Petstore"; if (res.statusCode == 200) { // handle response } -})(); +} + +run(); ``` ### Parameters diff --git a/files.gen b/files.gen index 32047ca..5e8a71c 100755 --- a/files.gen +++ b/files.gen @@ -27,7 +27,6 @@ src/sdk/models/shared/pet.ts src/sdk/models/errors/index.ts src/sdk/models/operations/index.ts src/sdk/models/shared/index.ts -USAGE.md docs/sdk/models/operations/createpetsresponse.md docs/sdk/models/operations/listpetsrequest.md docs/sdk/models/operations/listpetsresponse.md @@ -37,4 +36,5 @@ docs/sdk/models/shared/errort.md docs/sdk/models/shared/pet.md docs/sdks/swaggerpetstore/README.md docs/sdks/pets/README.md +USAGE.md .gitattributes \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 898181c..a28d037 100644 --- a/gen.yaml +++ b/gen.yaml @@ -2,8 +2,8 @@ configVersion: 1.0.0 management: docChecksum: 2516596125ef223fbbef6c434d22eaac docVersion: 1.0.0 - speakeasyVersion: 1.121.1 - generationVersion: 2.194.1 + speakeasyVersion: 1.126.0 + generationVersion: 2.213.3 generation: comments: {} sdkClassName: Swagger-Petstore @@ -12,10 +12,10 @@ generation: optionalPropertyRendering: withExample features: typescript: - core: 3.1.4 + core: 3.3.0 globalServerURLs: 2.82.1 typescript: - version: 0.4.4 + version: 0.5.0 author: demo clientServerStatusCodesAsErrors: true flattenGlobalSecurity: true @@ -33,3 +33,4 @@ typescript: outputModelSuffix: output packageName: Swagger-Petstore repoSubDirectory: . + templateVersion: v1 diff --git a/package-lock.json b/package-lock.json index a48019d..c8de647 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "Swagger-Petstore", - "version": "0.4.4", + "version": "0.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "Swagger-Petstore", - "version": "0.4.4", + "version": "0.5.0", "dependencies": { "axios": "^1.1.3", "class-transformer": "^0.5.1", diff --git a/package.json b/package.json index 759cae7..97d3f19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Swagger-Petstore", - "version": "0.4.4", + "version": "0.5.0", "author": "demo", "scripts": { "prepare": "tsc --build", diff --git a/src/sdk/sdk.ts b/src/sdk/sdk.ts index 2eb994a..5726769 100644 --- a/src/sdk/sdk.ts +++ b/src/sdk/sdk.ts @@ -42,9 +42,9 @@ export class SDKConfiguration { serverDefaults: any; language = "typescript"; openapiDocVersion = "1.0.0"; - sdkVersion = "0.4.4"; - genVersion = "2.194.1"; - userAgent = "speakeasy-sdk/typescript 0.4.4 2.194.1 1.0.0 Swagger-Petstore"; + sdkVersion = "0.5.0"; + genVersion = "2.213.3"; + userAgent = "speakeasy-sdk/typescript 0.5.0 2.213.3 1.0.0 Swagger-Petstore"; retryConfig?: utils.RetryConfig; public constructor(init?: Partial) { Object.assign(this, init);