Skip to content

Commit c7c2a13

Browse files
committed
Sync open source content 🐝 (from 3ffc8387f74bd2c7c97b1e7c35b854f318217d1c)
1 parent 31b8aaf commit c7c2a13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+6647
-6147
lines changed

api-design/request-body.mdx

Lines changed: 71 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Key components:
2828

2929
Requests can also have a "request body", which is a payload of data being sent
3030
the API for processing. It is very frowned upon to use a request body for the
31-
HTTP method `GET`, but expected for `POST`, `PUT`, `PATCH`, and `QUERY.
31+
HTTP method `GET`, but expected for `POST`, `PUT`, `PATCH`, and `QUERY`.
3232

3333
The request body can be in a variety of formats, but the most common are JSON,
3434
XML, and form data.
@@ -59,68 +59,76 @@ when receiving it.
5959
Most of you will interact with APIs using a programming language, and the code
6060
to send a request will look something like this:
6161

62-
<CodeWithTabs>
63-
```typescript !!tabs main.js
64-
import axios from 'axios';
65-
66-
const response = await axios.post('https://api.example.org/places', {
62+
<CodeWithTabs
63+
tabs={[
64+
{
65+
label: "main.js",
66+
language: "typescript",
67+
code: ` import axios from 'axios';
68+
69+
const response = await axios.post('https://api.example.org/places', {
70+
name: 'High Wood',
71+
lat: 50.464569783,
72+
lon: -4.486597585,
73+
});`,
74+
},
75+
{
76+
label: "main.py",
77+
language: "python",
78+
code: ` import json
79+
import requests
80+
81+
headers = {
82+
'Content-Type': 'application/json',
83+
}
84+
payload = {
85+
'name': 'High Wood',
86+
'lat': 50.464569783,
87+
'lon': -4.486597585,
88+
}
89+
req = requests.post(
90+
'https://api.example.org/places',
91+
data=json.dumps(payload),
92+
headers=headers
93+
)`,
94+
},
95+
{
96+
label: "main.php",
97+
language: "php",
98+
code: `$client = new Guzzle\\Http\\Client('https://api.example.org');
99+
100+
$headers = [
101+
'Content-Type' => 'application/json',
102+
];
103+
$payload = [
104+
'name' => 'High Wood',
105+
'lat' => 50.464569783,
106+
'lon' => -4.486597585,
107+
];
108+
$req = $client->post('/places', [
109+
'headers' => $headers,
110+
'json' => $payload,
111+
]);`,
112+
},
113+
{
114+
label: "main.rb",
115+
language: "ruby",
116+
code: `conn = Faraday.new(
117+
url: 'https://api.example.org',
118+
headers: { 'Content-Type' => 'application/json' }
119+
)
120+
121+
response = conn.post('/places') do |req|
122+
req.body = {
67123
name: 'High Wood',
68124
lat: 50.464569783,
69125
lon: -4.486597585,
70-
});
71-
```
72-
73-
```python !!tabs main.py
74-
import json
75-
import requests
76-
77-
headers = {
78-
'Content-Type': 'application/json',
79-
}
80-
payload = {
81-
'name': 'High Wood',
82-
'lat': 50.464569783,
83-
'lon': -4.486597585,
84-
}
85-
req = requests.post(
86-
'https://api.example.org/places',
87-
data=json.dumps(payload),
88-
headers=headers
89-
)
90-
```
91-
92-
```php !!tabs main.php
93-
$client = new Guzzle\Http\Client('https://api.example.org');
94-
95-
$headers = [
96-
'Content-Type' => 'application/json',
97-
];
98-
$payload = [
99-
'name' => 'High Wood',
100-
'lat' => 50.464569783,
101-
'lon' => -4.486597585,
102-
];
103-
$req = $client->post('/places', [
104-
'headers' => $headers,
105-
'json' => $payload,
106-
]);
107-
```
108-
109-
```ruby !!tabs main.rb
110-
conn = Faraday.new(
111-
url: 'https://api.example.org',
112-
headers: { 'Content-Type' => 'application/json' }
113-
)
114-
115-
response = conn.post('/places') do |req|
116-
req.body = {
117-
name: 'High Wood',
118-
lat: 50.464569783,
119-
lon: -4.486597585,
120-
}.to_json
121-
end
122-
```
123-
</CodeWithTabs>
126+
}.to_json
127+
end`,
128+
}
129+
130+
]}
131+
/>
124132

125133
HTTP tooling is essentially the same thing no matter the language. It's all
126134
about URLs, methods, body, and headers. This makes REST API design a lot easier,
@@ -206,13 +214,12 @@ More on this in the [API Responses](/api-design/responses) guide.
206214
### 2. Do not use request bodies for DELETE requests
207215

208216
Some API designers use a request body for a DELETE request to capture more
209-
information about the deletion of a resource.
217+
information about the deletion of a resource.
210218

211219
Doing so is recommended against in both [RFC9110: HTTP
212220
Semantics](https://www.rfc-editor.org/rfc/rfc9110.html#name-delete) which states
213221
the semantics are undefined, and is warned against further in the OpenAPI
214-
specification. Some tooling will support it some wont.
215-
222+
specification. Some tooling will support it some wont.
216223

217224
```http
218225
DELETE /drinks/1 HTTP/1.1
@@ -267,4 +274,4 @@ This way, the user always knows what to expect in the request body, and you can
267274
validate the request body more easily. If the user doesn't send a renewal date,
268275
you can just use the current date as the default value. This is a lot easier to
269276
understand and work with than having to check if the request body is present or
270-
not, and then check if the renewal date is present or not.
277+
not, and then check if the renewal date is present or not.

docs/create-client-sdks.mdx

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,35 @@ For a more UI-based experience, use the Speakeasy app:
3030

3131
After signing up, install the Speakeasy CLI using one of the following methods:
3232

33-
<CodeWithTabs>
34-
35-
```bash !!tabs Homebrew
36-
# Homebrew (macOS)
37-
brew install speakeasy-api/tap/speakeasy
38-
```
39-
40-
```bash !!tabs Script
41-
# Script Installation (macOS and Linux)
42-
curl -fsSL https://go.speakeasy.com/cli-install.sh | sh
43-
```
44-
45-
```bash !!tabs Winget
46-
# Windows Installation
33+
<CodeWithTabs
34+
tabs={[
35+
{
36+
label: "Homebrew",
37+
language: "bash",
38+
code: `# Homebrew (macOS)
39+
brew install speakeasy-api/tap/speakeasy`,
40+
},
41+
{
42+
label: "Script",
43+
language: "bash",
44+
code: `# Script Installation (macOS and Linux)
45+
curl -fsSL https://go.speakeasy.com/cli-install.sh | sh`,
46+
},
47+
{
48+
label: "Winget",
49+
language: "bash",
50+
code: `# Windows Installation
4751
# Using winget:
48-
winget install speakeasy
49-
```
50-
51-
```bash !!tabs Chocolatey
52-
# Using Chocolatey:
53-
choco install speakeasy
54-
```
55-
56-
</CodeWithTabs>
52+
winget install speakeasy`,
53+
},
54+
{
55+
label: "Chocolatey",
56+
language: "bash",
57+
code: `# Using Chocolatey:
58+
choco install speakeasy`,
59+
},
60+
]}
61+
/>
5762

5863
For manual installation, download the latest release from the [releases page](https://github.com/speakeasy-api/speakeasy/releases), extract the binary, and add it to the system path.
5964

@@ -75,7 +80,7 @@ If you've not previously signed up for an account, you will be prompted to creat
7580

7681
New accounts start with a 14 day free trial of Speakeasy's business tier, to enable users to try out every SDK generation feature. At the end of the trial, accounts will revert to the free tier. No credit card is required.
7782

78-
Free accounts can continue to generate one SDK with up to 50 API methods free of charge. Please refer to the pricing page for update information on each [pricing tier](https://www.speakeasy.com/pricing).
83+
Free accounts can continue to generate one SDK with up to 50 API methods free of charge. Please refer to the pricing page for update information on each [pricing tier](https://www.speakeasy.com/pricing).
7984

8085
### Upload an OpenAPI document
8186

@@ -114,7 +119,8 @@ Provide either a link to a remote hosted OpenAPI document, or a relative path to
114119
### Select artifact type
115120

116121
After configuring the OpenAPI document, the next step prompt is to choose the type of artifact being generated: SDK or MCP. Select SDK, and a prompt will appear to choose the target language:
117-
Choosing Terraform will default you back to the CLI native onboarding. [Editor support for Terraform previews](https://roadmap.speakeasy.com/roadmap?id=a8164ebf-55e1-4376-b42e-4e040c085586) coming soon.
122+
Choosing Terraform will default you back to the CLI native onboarding. [Editor support for Terraform previews](https://roadmap.speakeasy.com/roadmap?id=a8164ebf-55e1-4376-b42e-4e040c085586) coming soon.
123+
118124
<Screenshot
119125
variant="cli"
120126
image={{

0 commit comments

Comments
 (0)