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: openapi/frameworks/flask.mdx
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,9 @@ import { Callout } from "@/mdx/components";
7
7
8
8
# How to generate an OpenAPI document with Flask
9
9
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.
11
11
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:
13
13
14
14
- Setting up a Flask REST API with `flask-smorest`
15
15
- Integrating OpenAPI document generation
@@ -30,7 +30,7 @@ The two main decorators are:
30
30
-**`@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.
31
31
-**`@blp.arguments(schema)`**: Validates and deserializes the request body against a marshmallow schema, and documents the expected request body in the OpenAPI spec.
32
32
33
-
## Example API repository
33
+
## Sample API code
34
34
35
35
<Callouttitle="Example repository"type="info">
36
36
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
49
49
To follow this guide:
50
50
51
51
- 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)
53
53
- A basic understanding of Flask and REST APIs
54
54
55
55
## Setting up flask-smorest
@@ -360,7 +360,7 @@ info:
360
360
version: v1
361
361
openapi: 3.1.0
362
362
paths:
363
-
/circuits/:
363
+
/circuits:
364
364
get:
365
365
responses:
366
366
'200':
@@ -397,7 +397,7 @@ paths:
397
397
summary: Create a new circuit
398
398
tags:
399
399
- Circuits
400
-
/circuits/{circuit_id}:
400
+
/circuits{circuit_id}:
401
401
delete:
402
402
responses:
403
403
default:
@@ -446,7 +446,7 @@ paths:
446
446
summary: Update an existing circuit
447
447
tags:
448
448
- Circuits
449
-
/drivers/:
449
+
/drivers:
450
450
get:
451
451
responses:
452
452
'200':
@@ -532,7 +532,7 @@ paths:
532
532
summary: Update an existing driver
533
533
tags:
534
534
- Drivers
535
-
/lap-times/:
535
+
/lap-times:
536
536
get:
537
537
responses:
538
538
'200':
@@ -709,10 +709,10 @@ Use `@blp.response()` to specify the expected response code and schema for a met
709
709
return Circuit.query.all()
710
710
```
711
711
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:
0 commit comments