Skip to content

Commit 744edd8

Browse files
committed
guide: framework flask
1 parent 2530603 commit 744edd8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

openapi/frameworks/flask.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { Callout } from "@/mdx/components";
77

88
# How to generate an OpenAPI document with Flask
99

10-
When building REST APIs with Flask, clear and accurate documentation helps API consumers integrate quickly and confidently. [The OpenAPI Specification](https://swagger.io/specification/) has become the industry standard for documenting RESTful APIs, but writing and maintaining OpenAPI documents by hand is tedious and error-prone.
10+
When building REST APIs with Flask, clear and accurate documentation helps API consumers integrate quickly and confidently. [The OpenAPI Specification](https://spec.openapis.org/oas/latest.html) has become the industry standard for documenting RESTful APIs, but writing and maintaining OpenAPI documents by hand is tedious and error-prone.
1111

12-
`flask-smorest` solves this by generating OpenAPI documentation directly from Flask code, using decorators and marshmallow schemas already in use. This guide covers generating an OpenAPI document from a Flask project and using it to create SDKs with Speakeasy, covering the following:
12+
The `flask-smorest` extension solves this by generating OpenAPI documentation directly from Flask code, using decorators and marshmallow schemas already in use. This guide covers generating an OpenAPI document from a Flask project and using it to create SDKs with Speakeasy, covering the following:
1313

1414
- Setting up a Flask REST API with `flask-smorest`
1515
- Integrating OpenAPI document generation
@@ -30,7 +30,7 @@ The two main decorators are:
3030
- **`@blp.response(status_code, schema)`**: Specifies the response code and marshmallow schema for a method. flask-smorest uses this to document the response and serialize the return value.
3131
- **`@blp.arguments(schema)`**: Validates and deserializes the request body against a marshmallow schema, and documents the expected request body in the OpenAPI spec.
3232

33-
## Example API repository
33+
## Sample API code
3434

3535
<Callout title="Example repository" type="info">
3636
The source code for the completed example is available in the [**Speakeasy examples repository**](https://github.com/speakeasy-api/examples.git) (framework-flask).
@@ -49,7 +49,7 @@ For this guide, we'll use a simple Formula 1 (F1) lap times API with the followi
4949
To follow this guide:
5050

5151
- Python 3.8 or higher
52-
- An existing Flask project or a copy of the provided [example repository](https://github.com/speakeasy-api/flask-openapi-example)
52+
- An existing Flask project or a copy of the provided [example repository](https://github.com/speakeasy-api/examples/tree/main/framework-flask)
5353
- A basic understanding of Flask and REST APIs
5454

5555
## Setting up flask-smorest
@@ -360,7 +360,7 @@ info:
360360
version: v1
361361
openapi: 3.1.0
362362
paths:
363-
/circuits/:
363+
/circuits:
364364
get:
365365
responses:
366366
'200':
@@ -397,7 +397,7 @@ paths:
397397
summary: Create a new circuit
398398
tags:
399399
- Circuits
400-
/circuits/{circuit_id}:
400+
/circuits{circuit_id}:
401401
delete:
402402
responses:
403403
default:
@@ -446,7 +446,7 @@ paths:
446446
summary: Update an existing circuit
447447
tags:
448448
- Circuits
449-
/drivers/:
449+
/drivers:
450450
get:
451451
responses:
452452
'200':
@@ -532,7 +532,7 @@ paths:
532532
summary: Update an existing driver
533533
tags:
534534
- Drivers
535-
/lap-times/:
535+
/lap-times:
536536
get:
537537
responses:
538538
'200':
@@ -709,10 +709,10 @@ Use `@blp.response()` to specify the expected response code and schema for a met
709709
return Circuit.query.all()
710710
```
711711

712-
This generates the following entry for the `/circuits/` `GET` operation in the OpenAPI document:
712+
This generates the following entry for the `GET /circuits` operation in the OpenAPI document:
713713

714714
```yaml filename="openapi.yaml"
715-
/circuits/:
715+
/circuits:
716716
get:
717717
responses:
718718
'200':

0 commit comments

Comments
 (0)