Skip to content

Commit be1399d

Browse files
committed
Add SDK examples content
1 parent ed12618 commit be1399d

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: "Adding SDK examples"
3+
description: ""
4+
---
5+
6+
If your users interact with your API using an SDK rather than directly through a network request, you can use the `x-codeSamples` extension to add code samples to your OpenAPI document and Mintlify will display them in your OpenAPI pages.
7+
8+
This property can be added within any request method and has the following schema.
9+
10+
<ParamField body="lang" type="string" required>
11+
The language of the code sample.
12+
</ParamField>
13+
14+
<ParamField body="label" type="string">
15+
The label for the sample. This is useful when providing multiple examples for a single endpoint.
16+
</ParamField>
17+
18+
<ParamField body="source" type="string" required>
19+
The source code of the sample.
20+
</ParamField>
21+
22+
Here is an example of some code samples for a plant tracking app, which has both a Bash CLI tool and a JavaScript SDK.
23+
24+
```yaml
25+
paths:
26+
/plants:
27+
get:
28+
...
29+
x-codeSamples:
30+
- lang: bash
31+
label: List all unwatered plants
32+
source: |
33+
planter list -u
34+
- lang: javascript
35+
label: List all unwatered plants
36+
source: |
37+
const planter = require('planter');
38+
planter.list({ unwatered: true });
39+
- lang: bash
40+
label: List all potted plants
41+
source: |
42+
planter list -p
43+
- lang: javascript
44+
label: List all potted plants
45+
source: |
46+
const planter = require('planter');
47+
planter.list({ potted: true });
48+
```
49+

api-playground/customization/managing-page-visibility.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ description: "Control which endpoints from your OpenAPI specification appear in
66

77
You can control exactly which parts of your OpenAPI specification get published and how they're organized. Hiding pages can be useful when you're documenting internal APIs, beta features, or other endpoints that shouldn't appear in navigation.
88

9-
If your pages are autogenerated from an OpenAPI document, you can control which endpoints get published and how they appear in your documentation with the `x-hidden` and `x-excluded` properties.
9+
If your pages are autogenerated from an OpenAPI document, you can control which endpoints get published and how they appear in your documentation with the `x-hidden` and `x-excluded` extensions.
1010

1111
## `x-hidden`
1212

13-
The `x-hidden` property creates a page for an endpoint, but hides it from navigation. The page is only accessible by navigating directly its URL.
13+
The `x-hidden` extension creates a page for an endpoint, but hides it from navigation. The page is only accessible by navigating directly its URL.
1414

1515
Common use cases for `x-hidden` are:
1616

@@ -21,7 +21,7 @@ Common use cases for `x-hidden` are:
2121
## `x-excluded`
2222

2323

24-
The `x-excluded` property completely excludes an endpoint from your documentation.
24+
The `x-excluded` extension completely excludes an endpoint from your documentation.
2525

2626
Common use cases for `x-excluded` are:
2727

@@ -31,7 +31,7 @@ Common use cases for `x-excluded` are:
3131

3232
## Implementation
3333

34-
Add the `x-hidden` or `x-excluded` property under the HTTP method in your OpenAPI specification.
34+
Add the `x-hidden` or `x-excluded` extension under the HTTP method in your OpenAPI specification.
3535

3636
Here are examples of how to use each property in an OpenAPI schema document for an endpoint and a webhook path:
3737

0 commit comments

Comments
 (0)