Skip to content

Commit bdc9b2a

Browse files
authored
Merge pull request #19 from speakeasy-api/fix/remove-moonshine-dep
Fix/remove moonshine dep
2 parents f545fb6 + 39cc30f commit bdc9b2a

36 files changed

+1752
-3862
lines changed

.speakeasy/gen.lock

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ id: 521af75f-d011-41f9-a5ff-9f8033773118
33
management:
44
docChecksum: a16089f06495dd5f7de1f5121d72ec45
55
docVersion: 0.4.0
6-
speakeasyVersion: 1.484.1
7-
generationVersion: 2.503.2
8-
releaseVersion: 2.1.6
9-
configChecksum: 21f134167daabccf2f501cd418de0227
6+
speakeasyVersion: 1.495.1
7+
generationVersion: 2.515.4
8+
releaseVersion: 2.2.6
9+
configChecksum: a4ff9835698013bb8c7bb828a7e2be76
1010
repoURL: https://github.com/speakeasy-api/speakeasy-code-samples-ts.git
1111
installationURL: https://github.com/speakeasy-api/speakeasy-code-samples-ts
1212
published: true
1313
features:
1414
typescript:
1515
additionalDependencies: 0.1.0
16-
core: 3.18.22
16+
core: 3.20.0
1717
deepObjectParams: 0.1.0
1818
defaultEnabledRetries: 0.1.0
1919
devContainers: 2.90.0
2020
enumUnions: 0.1.0
2121
envVarSecurityUsage: 0.1.2
22-
globalSecurity: 2.82.12
22+
globalSecurity: 2.82.13
2323
globalSecurityCallbacks: 0.1.0
2424
globalSecurityFlattening: 0.1.0
2525
globalServerURLs: 2.82.4
@@ -95,6 +95,7 @@ generatedFiles:
9595
- src/sdk/codesamples.ts
9696
- src/sdk/index.ts
9797
- src/sdk/sdk.ts
98+
- src/types/async.ts
9899
- src/types/blobs.ts
99100
- src/types/constdatetime.ts
100101
- src/types/enums.ts
@@ -115,7 +116,7 @@ examples:
115116
languages: ["python", "javascript"]
116117
responses:
117118
2XX:
118-
application/json: {"snippets": [{"path": "/sbin", "method": "<value>", "operationId": "<id>", "language": "<value>", "code": "<value>"}, {"path": "/root", "method": "<value>", "operationId": "<id>", "language": "<value>", "code": "<value>"}]}
119+
application/json: {"snippets": [{"path": "/sbin", "method": "<value>", "operationId": "<id>", "language": "php,", "code": "<value>"}, {"path": "/root", "method": "<value>", "operationId": "<id>", "language": "unity,", "code": "<value>"}]}
119120
4XX:
120121
application/json: {"message": "<value>", "status_code": 521235}
121122
default:

.speakeasy/gen.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@ generation:
99
optionalPropertyRendering: withExample
1010
useClassNamesForArrayFields: true
1111
fixes:
12-
nameResolutionDec2023: false
12+
nameResolutionFeb2025: false
1313
parameterOrderingFeb2024: false
1414
requestResponseComponentNamesFeb2024: false
15+
securityFeb2025: false
1516
auth:
1617
oAuth2ClientCredentialsEnabled: false
1718
oAuth2PasswordEnabled: false
1819
typescript:
19-
version: 2.1.6
20+
version: 2.2.6
2021
additionalDependencies:
2122
dependencies:
22-
'@speakeasy-api/moonshine': ^0.69.0
23-
devDependencies: {}
24-
peerDependencies:
25-
highlight.js: ^11.11.1
23+
'@emotion/css': ^11.13.5
24+
codehike: ^1.0.4
25+
motion: ^12.4.7
26+
devDependencies:
27+
'@types/react': ^18.3.18
28+
peerDependencies: {}
2629
additionalPackageJSON: {}
2730
author: Speakeasy
2831
clientServerStatusCodesAsErrors: true
@@ -43,7 +46,7 @@ typescript:
4346
inputModelSuffix: input
4447
maxMethodParams: 1
4548
methodArguments: require-security-and-request
46-
moduleFormat: dual
49+
moduleFormat: esm
4750
outputModelSuffix: output
4851
packageName: '@speakeasyapi/code-samples'
4952
responseFormat: flat

.speakeasy/workflow.lock

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
speakeasyVersion: 1.484.1
1+
speakeasyVersion: 1.495.1
22
sources:
33
speakeasy-OAS:
44
sourceNamespace: speakeasy-oas
5-
sourceRevisionDigest: sha256:67db66bfe8bee7caf24220f613e60760c90e0a7fe721b9f70d46e584d61a8d79
6-
sourceBlobDigest: sha256:63701f5ff26c0ac6e0ea6e314b9dc7bf7063bf75b72a16206b62050baf740623
5+
sourceRevisionDigest: sha256:e536544d55620a79d50578204eb81fba11c6c419701bba423d897f2418d40a2d
6+
sourceBlobDigest: sha256:74092062b98c511fb2035986fe307d2d5de39443dac827b7bdddb853268f768c
77
tags:
88
- latest
99
- 0.4.0
1010
targets:
1111
code_samples_typescript_sdk:
1212
source: speakeasy-OAS
1313
sourceNamespace: speakeasy-oas
14-
sourceRevisionDigest: sha256:67db66bfe8bee7caf24220f613e60760c90e0a7fe721b9f70d46e584d61a8d79
15-
sourceBlobDigest: sha256:63701f5ff26c0ac6e0ea6e314b9dc7bf7063bf75b72a16206b62050baf740623
14+
sourceRevisionDigest: sha256:e536544d55620a79d50578204eb81fba11c6c419701bba423d897f2418d40a2d
15+
sourceBlobDigest: sha256:74092062b98c511fb2035986fe307d2d5de39443dac827b7bdddb853268f768c
16+
codeSamplesNamespace: speakeasy-oas-typescript-code-samples
17+
codeSamplesRevisionDigest: sha256:3a52773bea327c93e288622e24477f9c093cebab089f6e48ca84594db21a43e6
1618
workflow:
1719
workflowVersion: 1.0.0
1820
speakeasyVersion: latest

README.md

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/speakeasy-self/speakeasy-self). Delete this section before > publishing to a package manager.
2020
2121
<div align="center">
22-
<img src="https://github.com/user-attachments/assets/f5ab386f-39bb-4ae2-aa0d-54e2f95b656d" alt="Description" width="750"/>
22+
<picture>
23+
<source media="(prefers-color-scheme: dark)" srcset="./images/code-samples-demo-dark.webm">
24+
<img alt="animation of viewing code, switching programming languages, and copying the displayed text" src="./images/code-samples-demo-light.webm">
25+
</picture>
2326
<p><em>CodeSamples React Component in Action</em></p>
2427
</div>
2528

@@ -28,13 +31,13 @@
2831

2932
Speakeasy Code Samples API: REST APIs for retrieving SDK usage snippets from the Speakeasy Code Samples API.
3033

34+
3135
For more information about the API: [The Speakeasy Platform Documentation](/docs)
3236
<!-- End Summary [summary] -->
3337

3438
<!-- Start Table of Contents [toc] -->
3539
## Table of Contents
3640
<!-- $toc-max-depth=2 -->
37-
* [@speakeasyapi/code-samples](#speakeasyapicode-samples)
3841
* [SDK Installation](#sdk-installation)
3942
* [Requirements](#requirements)
4043
* [SDK Example Usage](#sdk-example-usage)
@@ -95,7 +98,8 @@ yarn add @tanstack/react-query react react-dom
9598
```
9699

97100
> [!NOTE]
98-
> This package is published with CommonJS and ES Modules (ESM) support.
101+
> This package is published as an ES Module (ESM) only. For applications using
102+
> CommonJS, use `await import("@speakeasyapi/code-samples")` to import and use this package.
99103
<!-- End SDK Installation [installation] -->
100104
101105
<!-- Start Requirements [requirements] -->
@@ -147,46 +151,39 @@ run();
147151
### React Component
148152

149153
This library includes a React component that fetches and highlights code
150-
snippets using `highlight.js`. Along with displaying the snippet, it shows a
154+
snippets using `codehike`. Along with displaying the snippet, it shows a
151155
loading state during fetching and provides a fallback view if an error occurs.
152156

153157
```tsx
154158
import { SpeakeasyCodeSamplesCore } from "@speakeasyapi/code-samples/core";
155159
import {
156-
CodeSample,
160+
CodeSampleFilenameTitle,
161+
CodeSamplesViewer,
157162
SpeakeasyCodeSamplesProvider,
158163
} from "@speakeasyapi/code-samples/react";
159-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
160-
161-
const queryClient = new QueryClient();
162164

163165
const speakeasyCodeSamples = new SpeakeasyCodeSamplesCore({
164166
apiKey: "<YOUR_API_KEY_HERE>",
165167
registryUrl: "https://spec.speakeasy.com/org/ws/my-source",
166168
});
167169

168-
// Retries are handled by the underlying SDK.
169-
queryClient.setQueryDefaults(["@speakeasyapi/code-samples"], { retry: false });
170-
171-
queryClient.setMutationDefaults(["@speakeasyapi/code-samples"], {
172-
retry: false,
173-
});
174-
175170
function App() {
176171
return (
177-
<QueryClientProvider client={queryClient}>
178-
<SpeakeasyCodeSamplesProvider client={speakeasyCodeSamples}>
179-
<CodeSample operationId="getPetById" language="typescript" />
180-
</SpeakeasyCodeSamplesProvider>
181-
</QueryClientProvider>
172+
<SpeakeasyCodeSamplesProvider client={speakeasyCodeSamples}>
173+
<CodeSamplesViewer
174+
copyable
175+
defaultLang={"typescript"}
176+
title={CodeSampleFilenameTitle}
177+
operation={"getPassageText"}
178+
// client={speakeasyCodeSamples}
179+
// 👆optional, if you want to pass the client directly
180+
// instead of using the provider
181+
/>
182+
</SpeakeasyCodeSamplesProvider>
182183
);
183184
}
184185
```
185186

186-
> [!NOTE]
187-
> To apply styles to the highlighted code, import a `highlight.js` theme CSS
188-
> file into your project using methods like a `<link>` tag.
189-
190187
<!-- Start Authentication [security] -->
191188
## Authentication
192189

@@ -538,9 +535,9 @@ In some rare cases, the SDK can fail to get a response from the server or even m
538535

539536
You can override the default server globally by passing a server name to the `server: keyof typeof ServerList` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
540537

541-
| Name | Server |
542-
| ------ | ----------------------------------- |
543-
| `prod` | `https://api.prod.speakeasyapi.dev` |
538+
| Name | Server | Description |
539+
| ------ | ----------------------------------- | ----------- |
540+
| `prod` | `https://api.prod.speakeasyapi.dev` | |
544541

545542
#### Example
546543

example/package-lock.json

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
}
66

77
h1 {
8-
font-size: 3rem;
8+
font-size: 2rem;
99
margin-bottom: 18px;
1010
font-weight: 600;
1111
text-align: center;

example/src/App.tsx

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,31 @@
1+
import { SpeakeasyCodeSamplesCore } from "@speakeasyapi/code-samples/core";
12
import {
2-
CodeSample,
3+
CodeSampleFilenameTitle,
4+
CodeSamplesViewer,
35
SpeakeasyCodeSamplesProvider,
4-
SupportedLanguage,
56
} from "@speakeasyapi/code-samples/react";
6-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
77
import "./App.css";
8-
import { SpeakeasyCodeSamplesCore } from "@speakeasyapi/code-samples/core";
9-
10-
const CodeSampleHeader = ({ lang }: { lang: SupportedLanguage }) => {
11-
let filename = "example";
12-
13-
switch (lang) {
14-
case "python":
15-
filename += ".py";
16-
break;
17-
case "ruby":
18-
filename += ".rb";
19-
break;
20-
case "terraform":
21-
filename += ".tf";
22-
break;
23-
case "typescript":
24-
filename += ".ts";
25-
break;
26-
case "csharp":
27-
case "unity":
28-
filename += ".cs";
29-
break;
30-
case "java":
31-
case "swift":
32-
case "php":
33-
case "go":
34-
filename += `.${lang}`;
35-
break;
36-
case "postman":
37-
filename += ".json";
38-
break;
39-
default:
40-
throw new Error("unsupported language: " + lang);
41-
}
42-
43-
return (
44-
<span style={{ color: "var(--ch-1)", marginLeft: 4 }}>{filename}</span>
45-
);
46-
};
478

489
function App() {
49-
const queryClient = new QueryClient();
5010
const coreSdk = new SpeakeasyCodeSamplesCore({
5111
apiKey: import.meta.env.VITE_SPEAKEASY_API_KEY,
5212
registryUrl: import.meta.env.VITE_SPEAKEASY_REGISTRY_URL,
5313
});
5414

15+
// You can use the context provider to pass the core SDK instance to the code
16+
// samples viewer
5517
return (
56-
<QueryClientProvider client={queryClient}>
57-
<SpeakeasyCodeSamplesProvider client={coreSdk}>
58-
<h1 className="bg-background">Speakeasy Code Samples</h1>
59-
<div style={{ width: "660px" }}>
60-
<CodeSample
61-
operation={{ operationId: "getPassageText" }}
62-
heading={({ selectedLang }) => (
63-
<CodeSampleHeader lang={selectedLang} />
64-
)}
65-
mode="system"
66-
/>
67-
</div>
68-
</SpeakeasyCodeSamplesProvider>
69-
</QueryClientProvider>
18+
<SpeakeasyCodeSamplesProvider client={coreSdk}>
19+
<div style={{ width: "700px", marginInline: "auto" }}>
20+
<CodeSamplesViewer
21+
copyable
22+
defaultLang={"typescript"}
23+
title={CodeSampleFilenameTitle}
24+
operation={"getPassageText"}
25+
// client={coreSdk} 👈 optional, if you want to pass the client directly
26+
/>
27+
</div>
28+
</SpeakeasyCodeSamplesProvider>
7029
);
7130
}
7231

example/src/index.css

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,6 @@
1313
-moz-osx-font-smoothing: grayscale;
1414
}
1515

16-
body {
17-
margin: 0;
18-
display: flex;
19-
place-items: center;
20-
min-width: 320px;
21-
min-height: 100vh;
22-
}
23-
24-
h1 {
25-
font-size: 3.2em;
26-
line-height: 1.1;
27-
}
28-
2916
@media (prefers-color-scheme: light) {
3017
:root {
3118
color: #213547;

images/code-samples-demo-dark.webm

285 KB
Binary file not shown.
226 KB
Binary file not shown.

0 commit comments

Comments
 (0)