Skip to content

Commit

Permalink
merge(integrated_docs): add base doc generation with utoipa. (#6)
Browse files Browse the repository at this point in the history
- [feat(autogen_docs): add autogen doc & yaml
endpoints.](a107374)

- [feat(docs_permissions): add docs read permission & implemented it for
api.](fbc8dbb)

- [feat(docs_gen): add json docs + api & cleaned
up.](b1dec27)

- [feat(security): add permissions component to
docs.](9103a6a)

- [fix(readme): updated readme to reflect new docs and
tests.](d4d1810)
  • Loading branch information
5-pebbles authored Mar 9, 2024
2 parents 521f2b2 + d4d1810 commit 096c4fa
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 109 deletions.
106 changes: 93 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ sqlvec = { version = "0.0.2", features = ["serde"] }
bcrypt = "0.15.0"
uuid = { version = "1.7.0", features = ["v4"] }

utoipa = { version = "4.2.0", features = ["rocket_extras", "yaml"] }

[dependencies.rocket_sync_db_pools]
version = "0.1.0"
features = ["sqlite_pool"]
101 changes: 5 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,104 +4,13 @@ Tuna is an open source music api, designed to allow client side automation & con

> Warning: this is currently in a work in progress...
<details><summary><h2>Api End Points</h2></summary>

<details><summary><code>POST /init</code></summary>
## Docs

---
> Not all endpoints are documented yet, well actually, most arn't...
**Variables:**
OpenAPI docs are generated with the help of [utoipa](https://github.com/juhaku/utoipa), they can be found in the docs directory.

- username: `String`.
## Tests

- password: `String`

```hurl
# create the first account in the database
POST {{url}}/init
{
"username": {username},
"password": {password}
}
HTTP 200
```

</details>

<details><summary><code>POST /login</code></summary>

---

**Variables:**

- username: `String`.

- password: `String`

```hurl
POST {{url}}/login
{
"username": {{username}},
"password": {{password}}
}
HTTP 200
[Asserts]
cookie "session" exists
```

</details>

<details><summary><code>GET /user?username={{username}}&permissions={{permissions}}&limit={{limit}}</code></summary>

---

**Permissions**: `UserRead`

**Variables:**

- username: `String`.

- permissions: `URL encoded Json<Vec<String>>`.

- limit: `u16`.

```hurl
# partially matches for the given variables, all are optional.
GET {{url}}/user?username={{username}}&permissions={{permissions}}&limit={{limit}}
HTTP 200
[Asserts]
jsonpath "$" count <= {{limit}}
jsonpath "$[0].username" contains {{username}}
jsonpath "$[0].permissions" exists
```

**Response Example:**
```json
[
{
"username": "Owen",
"permissions": ["InviteRead", "InviteDelete"]
}
]
```

</details>

<details><summary><code>DELETE /user/{{username}}</code></summary>

---

**Permissions**: `None` If deleting your own account || `UserDelete` & All permissions of the target user

**Variables:**

- username: `String`.

```hurl
DELETE {{url}}/user/{{username}}
HTTP 200
```

</details>

</details>
Tests can be run with `cargo tests` however its required that you install [hurl](https://github.com/Orange-OpenSource/hurl) first.
Loading

0 comments on commit 096c4fa

Please sign in to comment.