Skip to main content
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 display them in your OpenAPI pages. Add this property to any request method. It has the following schema.
string
required
The language of the code sample.
string
The label for the sample. This is useful when providing multiple examples for a single endpoint.
string
required
The source code of the sample.
Here is an example of code samples for a plant tracking app, which has both a Bash CLI tool and a JavaScript SDK.