You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api-design/picking-architectures.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ Beyond authentication, REST's resource-oriented design provides an intuitive and
42
42
43
43
For example, you can use the Flask framework in Python to build a RESTful API. Here is how you can define a simple endpoint to fetch a list of products:
44
44
45
-
```python app.py
45
+
```pythonfilename="app.py"
46
46
from flask import Flask, jsonify, request
47
47
48
48
app = Flask(__name__)
@@ -262,7 +262,7 @@ This is what a typical WebSocket architecture looks like.
262
262
263
263
WebSockets is a great choice for our high-frequency trading application. Let's see how this could be implemented in a Node.js application, using channels to allow users to send orders and receive price changes in real time.
Copy file name to clipboardExpand all lines: api-design/testing.mdx
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@ title: "Testing Best Practices in REST API Design"
3
3
description: "Implement comprehensive API testing strategies to ensure reliability, performance, and backward compatibility throughout development cycles."
4
4
---
5
5
6
+
importImagefrom"next/image";
7
+
6
8
# Testing your API
7
9
8
10
We write tests to build trust. Trust that our software is reliable, safe, and extendable. When it comes to testing public APIs, robust testing gives users confidence that the API *behaves* as expected. This guide not only covers the *how* of API testing, but also how to project externally the confidence brought by testing.
@@ -17,7 +19,7 @@ But for *public* or third-party-consumed APIs, the *why* extends further. Your t
17
19
18
20
API testing clashes with the traditional test pyramid - you know, the one that says, "Many unit tests at the bottom, fewer integration tests in the middle, and a few end-to-end tests at the top."
19
21
20
-

22
+
<Imagesrc="/assets/api-design/api-testing/pyramid.svg?.url"alt="The test pyramid"width={1000}height={1000} />
21
23
22
24
This pyramid is a good model for verifying the implementation details of small units of work, but it's a terrible model for verifying an API's behavior. Unit tests, useful on the server when testing complex logic, don't tell us much about how the API behaves as a whole.
23
25
@@ -27,7 +29,7 @@ We need a new model for API tests.
27
29
28
30
The traditional test pyramid (many unit tests, fewer integration tests, fewest E2E tests) is okay for internal implementation details. But for verifying API *behavior* from a consumer's viewpoint, the emphasis shifts.
29
31
30
-

32
+
<Imagesrc="/assets/api-design/api-testing/api-pyramid.svg?.url"alt="The API test pyramid"width={1000}height={1000} />
31
33
32
34
It's not exactly a pyramid, but you get the idea.
33
35
@@ -298,7 +300,7 @@ Here's what belongs in the public domain:
298
300
299
301
✅ **Authentication flow verification:** Tests that demonstrate how authentication works, covering token acquisition, refresh flows, and error handling.
✅ **Error condition handling:** Tests that demonstrate how your API responds to different error states, such as invalid inputs, missing resources, and service errors.
Copy file name to clipboardExpand all lines: docs/create-terraform.mdx
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,8 @@ Speakeasy helps you autogenerate documentation using the HashiCorp `terraform-pl
89
89
90
90
The Swagger Petstore generates a usage snippet for the pet resource similar to the following:
91
91
92
-
```go "petstore_pet" "my_pet" {
92
+
```go
93
+
"petstore_pet""my_pet" {
93
94
id = 10
94
95
name = "doggie"
95
96
photo_urls = [
@@ -158,7 +159,7 @@ Speakeasy natively supports the direct import of resources with multiple ID fiel
158
159
159
160
An import block allows you to import a resource into the Terraform state by generating the corresponding Terraform configuration. Using a composite key, the import block will look like this:
Copy file name to clipboardExpand all lines: docs/customize/code/code-regions/java.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ description: "Learn how to use custom code regions in Java SDKs."
8
8
To enable custom code regions for Java SDKs, update the project's
9
9
`.speakeasy/gen.yaml` file as follows:
10
10
11
-
```diff .speakeasy/gen.yaml
11
+
```difffilename=".speakeasy/gen.yaml"
12
12
configVersion: 2.0.0
13
13
generation:
14
14
# ...
@@ -51,7 +51,7 @@ Java model classes can also have custom code regions:
51
51
52
52
When adding custom code that requires external packages, configure these dependencies in the `.speakeasy/gen.yaml` file to prevent them from being removed during SDK regeneration. Use the `additionalDependencies` configuration to specify package dependencies:
53
53
54
-
```yaml .speakeasy/gen.yaml
54
+
```yamlfilename=".speakeasy/gen.yaml"
55
55
java:
56
56
additionalDependencies:
57
57
- implementation:org.commonmark:commonmark:0.21.0
@@ -62,7 +62,7 @@ java:
62
62
63
63
This ensures that dependencies persist across SDK regenerations and are properly included in the generated `build.gradle`.
Copy file name to clipboardExpand all lines: docs/customize/code/code-regions/python.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ description: "Learn how to use custom code regions in Python SDKs."
8
8
To enable custom code regions for Python SDKs, update the project's
9
9
`.speakeasy/gen.yaml` file as follows:
10
10
11
-
```diff .speakeasy/gen.yaml
11
+
```difffilename=".speakeasy/gen.yaml"
12
12
configVersion: 2.0.0
13
13
generation:
14
14
# ...
@@ -40,7 +40,7 @@ Python SDK classes can have two code regions:
40
40
41
41
When adding custom code that requires external packages, configure these dependencies in the `.speakeasy/gen.yaml` file to prevent them from being removed during SDK regeneration. Use the `additionalDependencies` configuration to specify package dependencies:
42
42
43
-
```yaml .speakeasy/gen.yaml
43
+
```yamlfilename=".speakeasy/gen.yaml"
44
44
python:
45
45
additionalDependencies:
46
46
main:
@@ -53,7 +53,7 @@ python:
53
53
54
54
This ensures that dependencies persist across SDK regenerations and are properly included in the generated `pyproject.toml`.
55
55
56
-
```python src/todos_sdk/todos.py
56
+
```python filename="src/todos_sdk/todos.py"
57
57
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
Copy file name to clipboardExpand all lines: docs/customize/code/code-regions/typescript.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ description: "Learn how to use custom code regions in TypeScript SDKs."
8
8
To enable custom code regions for TypeScript SDKs, update the project's
9
9
`.speakeasy/gen.yaml` file as follows:
10
10
11
-
```diff .speakeasy/gen.yaml
11
+
```difffilename=".speakeasy/gen.yaml"
12
12
configVersion: 2.0.0
13
13
generation:
14
14
# ...
@@ -40,7 +40,7 @@ TypeScript SDK classes can have two code regions:
40
40
41
41
When adding custom code that requires external packages, configure these dependencies in the `.speakeasy/gen.yaml` file to prevent them from being removed during SDK regeneration. Use the `additionalDependencies` configuration to specify package dependencies:
42
42
43
-
```yaml .speakeasy/gen.yaml
43
+
```yamlfilename=".speakeasy/gen.yaml"
44
44
typescript:
45
45
additionalDependencies:
46
46
dependencies:
@@ -54,7 +54,7 @@ typescript:
54
54
55
55
This ensures that dependencies persist across SDK regenerations and are properly included in the generated `package.json`.
56
56
57
-
```typescript src/sdk/todos.ts
57
+
```typescript filename="src/sdk/todos.ts"
58
58
/*
59
59
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
Copy file name to clipboardExpand all lines: docs/customize/data-model/additionalproperties.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Speakeasy sets `additionalProperties` to `false` by default unless explicitly de
19
19
20
20
Set `additionalProperties: true` to accept arbitrary fields beyond the defined properties. This is useful for accepting unpredictable fields or allowing future extensions without schema updates.
21
21
22
-
```yaml openapi.yaml
22
+
```yamlfilename="openapi.yaml"
23
23
components:
24
24
schemas:
25
25
FlexibleObject:
@@ -58,7 +58,7 @@ await sdk.items.create({
58
58
59
59
Constrain additional properties to a specific type:
Copy file name to clipboardExpand all lines: docs/customize/structure/namespaces.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Each method will then be added to namespaces corresponding with its `tags`. If a
18
18
19
19
The following example illustrates the method `sdk.Drinks.ListDrinks()` assigned to the `Drinks` namespace and another method `sdk.ListLocations()` kept in the default class:
20
20
21
-
```yaml Tags
21
+
```yamlfilename="Tags"
22
22
paths:
23
23
/bar_locations:
24
24
get:
@@ -70,7 +70,7 @@ Sometimes the `tags` in an OpenAPI spec may already be used for an unrelated pur
70
70
71
71
The `x-speakeasy-group` field allows defining custom namespaces. Add this field to any operation in the OpenAPI spec to override any `tags` associated with that method. For example:
0 commit comments