Skip to content

update: links and new features #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 30 additions & 6 deletions openapi/frameworks/pydantic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Before we get started, make sure you have [Python](https://www.python.org/downlo
python --version
```

We use Python 3.12.4 in this guide, but any version of Python 3.8 or higher should work.
We use Python 3.13.3 in this guide, but any version of Python 3.8 or higher should work.

## Create a New Python Project

Expand Down Expand Up @@ -1480,7 +1480,7 @@ Now that we have a complete OpenAPI schema with paths and operations, we can use

### Prerequisites for SDK Generation

Install Speakeasy by following the [Speakeasy installation instructions](/docs/speakeasy-cli/getting-started#install).
Install Speakeasy by following the [Speakeasy installation instructions](../../docs/speakeasy-reference/cli/getting-started#install)

On macOS, you can install Speakeasy using Homebrew:

Expand All @@ -1504,15 +1504,27 @@ speakeasy quickstart

Follow the onscreen prompts to provide the necessary configuration details for your new SDK such as the name, schema location and output path. Enter `openapi.yaml` when prompted for the OpenAPI document location and select TypeScript when prompted for which language you would like to generate.

Speakeasy [validates](../../docs/core-concepts#validation) the OpenAPI document to check that it's ready for code generation. Validation issues will be printed in the terminal. The generated SDK will be saved as a folder in your project.

![Speakeasy quickstart command output](./assets/pydantic/speakeasy-quickstart-output.png)

Speakeasy also suggests improvements for your SDK, using [Speakeasy Suggest](../../docs/prep-openapi/maintenance.md), which is an AI-powered tool in Speakeasy Studio. You can view the suggestions in Speakeasy Studio:

![Speakeasy Studio suggestions](./assets/pydantic/speakeasy-studio-suggestions.png)

### Adding Speakeasy Extensions to the OpenAPI Schema

Speakeasy uses [OpenAPI extensions](../../openapi/extensions.md) to provide additional information for generating SDKs.
Speakeasy uses [OpenAPI extensions](../../openapi/extensions.mdx) to provide additional information for generating SDKs.

We can add extensions using [OpenAPI Overlays](../../openapi/overlays.mdx), which are YAML files that [Speakeasy overlays on top of the OpenAPI schema](/docs/prep-openapi/overlays/create-overlays.mdx).

We can add extensions using [OpenAPI Overlays](../../openapi/overlays.mdx), which are YAML files that [Speakeasy overlays on top of the OpenAPI schema](/docs/prep-openapi/overlays/create-overlays).
Overlays can be used along side [OpenAPI Transformations](../../docs/prep-openapi/transformations.mdx) to improve the OpenAPI document for SDK generation.

Alternatively, you can add extensions directly to the OpenAPI schema using the `x-` prefix.
Transformations are predefined functions that allow you remove unused components, filter operations, and format your OpenAPI document. Unlike overlays, transformations directly modify the OpenAPI document itself.

For example, you can add the [`x-speakeasy-retries` extension](../../docs/customize-sdks/retries.mdx) to have Speakeasy generate retry logic in the SDK.
Note that for Speakeasy OpenAPI extensions, you can also add extensions directly to the OpenAPI schema using the `x-` prefix.

For example, you can add the [`x-speakeasy-retries`](../../docs/customize/runtime/retries.mdx) extension to have Speakeasy generate retry logic in the SDK.

Import the `Dict` and `Any` types from the `typing` module in `api.py`, and `ConfigDict` from `pydantic`.

Expand Down Expand Up @@ -1628,8 +1640,20 @@ Speakeasy will detect the changes to your OpenAPI schema, generate the SDK with

Take a look at the generated SDK to see how Speakeasy groups operations by tags.

In the SDK `README.md` file, you'll find documentation about your Speakeasy SDK. TypeScript SDKs generated with Speakeasy include an installable [Model Context Protocol (MCP) server](../../docs/model-context-protocol.mdx) where the various SDK methods are exposed as tools that can be invoked by AI applications. Your SDK documentation includes instructions for installing the MCP server.

Note that the SDK is not ready for production use. To get it production-ready, follow the steps outlined in your Speakeasy Studio workspace.

## We Can Help Get Your Pydantic Models Ready for SDK Generation

In this tutorial, we learned how to generate an OpenAPI schema from Pydantic models and use it to generate an SDK client using Speakeasy.

If you would like to discuss how to get your Pydantic models ready for SDK generation, give us feedback, or shoot the breeze about all things OpenAPI and SDKs, [join our Slack](https://join.slack.com/t/speakeasy-dev/shared_invite/zt-1cwb3flxz-lS5SyZxAsF_3NOq5xc8Cjw).

If you haven't already, take a look at our [blog](https://www.speakeasy.com/blog) to learn more about API design, SDK generation, and our latest features including:

- [Native JSONL support in your SDKs](https://www.speakeasy.com/blog/release-jsonl-support)
- [Introducing comprehensive SDK Testing](https://www.speakeasy.com/blog/release-sdk-testing)
- [Model Context Protocol: TypeScript SDKs for the Agentic AI ecosystem](https://www.speakeasy.com/blog/release-model-context-protocol)
- [Python Generation with Async & Pydantic Support](https://www.speakeasy.com/blog/release-python)
- [Choosing your Python REST API framework](https://www.speakeasy.com/blog/choosing-your-framework-python)