Skip to content

Commit 14fd2ee

Browse files
committed
openapi generated doc image
1 parent 6949919 commit 14fd2ee

File tree

6 files changed

+51
-19
lines changed

6 files changed

+51
-19
lines changed

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,21 @@ async def create_user(new_hero: HeroBase, session: Session):
186186

187187
### Database
188188

189-
💡 This example uses an `SQLite` database for simplicity.
189+
💡 This example uses an `SQLite` database for simplicity: `FastSQLA` is compatible with
190+
all asynchronous db drivers that `SQLAlchemy` is compatible with.
190191

191-
`FastSQLA` is compatible with all asynchronous db drivers that `SQLAlchemy` is
192-
compatible with.
192+
Let's create an `SQLite` database using `sqlite3` and insert 12 rows in the `hero` table:
193193

194-
Let's create an `SQLite` database using `sqlite3`:
195194
```bash
196195
sqlite3 db.sqlite <<EOF
196+
-- Create Table hero
197197
CREATE TABLE hero (
198198
id INTEGER PRIMARY KEY AUTOINCREMENT,
199-
name TEXT NOT NULL UNIQUE, -- Hero name (e.g., Superman)
199+
name TEXT NOT NULL UNIQUE, -- Unique hero name (e.g., Superman)
200200
secret_identity TEXT NOT NULL -- Secret identity (e.g., Clark Kent)
201201
);
202202
203-
-- Insert heroes with hero name and secret identity
203+
-- Insert heroes with their name and secret identity
204204
INSERT INTO hero (name, secret_identity) VALUES ('Superman', 'Clark Kent');
205205
INSERT INTO hero (name, secret_identity) VALUES ('Batman', 'Bruce Wayne');
206206
INSERT INTO hero (name, secret_identity) VALUES ('Wonder Woman', 'Diana Prince');
@@ -218,10 +218,14 @@ EOF
218218

219219
### Run the app
220220

221-
Let's install required dependencies & run the app:
221+
Let's install required dependencies:
222222
```bash
223223
pip install uvicorn aiosqlite fastsqla
224-
sqlalchemy_url=sqlite+aiosqlite:///db.sqlite?check_same_thread=false uvicorn example:app
224+
```
225+
Let's run the app:
226+
```
227+
sqlalchemy_url=sqlite+aiosqlite:///db.sqlite?check_same_thread=false \
228+
uvicorn example:app
225229
```
226230

227231
### Check the result
@@ -254,6 +258,13 @@ Returns:
254258
}
255259
```
256260

261+
You can also check the generated openapi doc by opening your browser to
262+
[http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs).
263+
264+
![OpenAPI generated documentation of the example API](images/example-openapi-generated-doc.png)
265+
266+
267+
257268
## License
258269

259270
This project is licensed under the terms of the [MIT license](https://github.com/hadrien/FastSQLA/blob/main/LICENSE).

docs/configuration.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,23 @@ variables, with each parameter name prefixed by **`SQLALCHEMY_`**.
1111

1212
!!! note
1313

14-
FastSQLA is case-insensitive when reading environment variables, so parameter names
15-
prefixed with **`SQLALCHEMY_`** can be provided in any letter case.
14+
FastSQLA is **case-insensitive** when reading environment variables, so parameter
15+
names prefixed with **`SQLALCHEMY_`** can be provided in any letter case.
1616

1717
## Examples
1818

19-
1. :simple-postgresql: PostgreSQL url using [`asyncpg`][sqlalchemy.dialects.postgresql.asyncpg]
20-
driver with a [`pool_recycle`][sqlalchemy.create_engine.params.pool_recycle] of 30
21-
minutes:
19+
1. :simple-postgresql: PostgreSQL url using
20+
[`asyncpg`][sqlalchemy.dialects.postgresql.asyncpg] driver with a
21+
[`pool_recycle`][sqlalchemy.create_engine.params.pool_recycle] of 30 minutes:
2222

2323
```bash
2424
export SQLALCHEMY_URL=postgresql+asyncpg://postgres@localhost
2525
export SQLALCHEMY_POOL_RECYCLE=1800
2626
```
2727

28-
2. :simple-sqlite: SQLite db file using [`aiosqlite`][sqlalchemy.dialects.sqlite.aiosqlite]
29-
driver with a [`pool_size`][sqlalchemy.create_engine.params.pool_size] of 50:
28+
2. :simple-sqlite: SQLite db file using
29+
[`aiosqlite`][sqlalchemy.dialects.sqlite.aiosqlite] driver with a
30+
[`pool_size`][sqlalchemy.create_engine.params.pool_size] of 50:
3031

3132
```bash
3233
export sqlalchemy_url=sqlite+aiosqlite:////tmp/test.db?check_same_thread=false
448 KB
Loading

mkdocs.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ theme:
1616
logo: material/database
1717
name: material
1818
features:
19+
- admonition
1920
- announce.dismiss
2021
- content.code.annotate
2122
- content.code.copy
@@ -49,8 +50,8 @@ theme:
4950
name: Switch to system preference
5051

5152
plugins:
52-
- search
5353
- autorefs
54+
- glightbox
5455
- mkdocstrings:
5556
enable_inventory: true
5657
handlers:
@@ -59,14 +60,18 @@ plugins:
5960
- https://docs.python.org/3/objects.inv
6061
- https://docs.sqlalchemy.org/en/20/objects.inv
6162
- https://fastapi.tiangolo.com/objects.inv
63+
- search
6264

6365
markdown_extensions:
6466
- admonition
65-
- pymdownx.details
66-
- pymdownx.superfences
6767
- attr_list
68+
- md_in_html
69+
- pymdownx.blocks.caption
70+
- pymdownx.details
6871
- pymdownx.emoji:
6972
emoji_index: !!python/name:material.extensions.emoji.twemoji
7073
emoji_generator: !!python/name:material.extensions.emoji.to_svg
74+
- pymdownx.superfences
7175
- toc:
7276
permalink: true
77+

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ Issues = "https://github.com/hadrien/fastsqla/issues"
4343
Changelog = "https://github.com/hadrien/fastsqla/releases"
4444

4545
[project.optional-dependencies]
46-
docs = ["mkdocs-material>=9.5.50", "mkdocstrings[python]>=0.27.0"]
46+
docs = [
47+
"mkdocs-glightbox>=0.4.0",
48+
"mkdocs-material>=9.5.50",
49+
"mkdocstrings[python]>=0.27.0",
50+
]
4751

4852
[tool.uv]
4953
package = true

uv.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)