Skip to content

Commit 7c0310e

Browse files
Update README.md
1 parent 19faea6 commit 7c0310e

File tree

1 file changed

+32
-40
lines changed

1 file changed

+32
-40
lines changed

README.md

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,37 @@ async function run() {
103103

104104
run();
105105

106+
```
107+
108+
```typescript
109+
import { SDK } from "@speakeasyapi/code-samples";
110+
import { promises as fs } from "fs"
111+
112+
const sdk = new SDK({
113+
security: {
114+
apiKey: "<YOUR_API_KEY_HERE>",
115+
},
116+
});
117+
118+
async function run() {
119+
const resultPost = await sdk.codesamples.previewAsync({
120+
languages: ["python", "typescript"],
121+
schemaFile: {
122+
fileName: "openapi.json", // ensure file name is included
123+
content: fileContent,
124+
},
125+
});
126+
// Handle the result
127+
console.log(resultPost);
128+
129+
const resultPoll = await sdk.codesamples.getAsync("<job_id>");
130+
131+
// Handle the result
132+
console.log(resultPoll);
133+
}
134+
135+
run();
136+
106137
```
107138
<!-- No SDK Example Usage [usage] -->
108139
<!-- Start Available Resources and Operations [operations] -->
@@ -378,46 +409,7 @@ const sdk = new SDK({ httpClient });
378409
```
379410
<!-- End Custom HTTP Client [http-client] -->
380411

381-
<!-- Start Authentication [security] -->
382-
## Authentication
383-
384-
### Per-Client Security Schemes
385-
386-
This SDK supports the following security schemes globally:
387-
388-
| Name | Type | Scheme |
389-
| --------------------- | ------ | ----------- |
390-
| `apiKey` | apiKey | API key |
391-
| `workspaceIdentifier` | apiKey | API key |
392-
| `bearer` | http | HTTP Bearer |
393-
394-
You can set the security parameters through the `security` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
395-
```typescript
396-
import { SDK } from "@speakeasyapi/code-samples";
397-
import { openAsBlob } from "node:fs";
398-
399-
const sdk = new SDK({
400-
security: {
401-
apiKey: "<YOUR_API_KEY_HERE>",
402-
},
403-
});
404-
405-
async function run() {
406-
const result = await sdk.codesamples.preview({
407-
languages: [
408-
"<value>",
409-
],
410-
schemaFile: await openAsBlob("example.file"),
411-
});
412-
413-
// Handle the result
414-
console.log(result);
415-
}
416-
417-
run();
418-
419-
```
420-
<!-- End Authentication [security] -->
412+
<!-- No Authentication [security] -->
421413

422414
<!-- Start Debugging [debug] -->
423415
## Debugging

0 commit comments

Comments
 (0)