Tweak the schema to use summary instead of description and add tags

This commit is contained in:
Quentin Gliech
2024-07-26 17:19:15 +02:00
parent 3f947025e2
commit cdecac735e
5 changed files with 30 additions and 7 deletions
+6 -1
View File
@@ -14,7 +14,7 @@
use aide::{
axum::ApiRouter,
openapi::{OAuth2Flow, OAuth2Flows, OpenApi, SecurityScheme, Server},
openapi::{OAuth2Flow, OAuth2Flows, OpenApi, SecurityScheme, Server, Tag},
};
use axum::{
extract::{FromRef, FromRequestParts, State},
@@ -53,6 +53,11 @@ where
.nest("/api/admin/v1", self::v1::router())
.finish_api_with(&mut api, |t| {
t.title("Matrix Authentication Service admin API")
.tag(Tag {
name: "user".to_owned(),
description: Some("Manage users".to_owned()),
..Tag::default()
})
.security_scheme(
"oauth2",
SecurityScheme::OAuth2 {
@@ -58,7 +58,8 @@ pub struct UsernamePathParam {
pub fn doc(operation: TransformOperation) -> TransformOperation {
operation
.description("Get a user by its username (localpart)")
.summary("Get a user by its username (localpart)")
.tag("user")
.response_with::<200, Json<SingleResponse<User>>, _>(|t| {
let [sample, ..] = User::samples();
let response =
+2 -1
View File
@@ -52,7 +52,8 @@ impl IntoResponse for RouteError {
pub fn doc(operation: TransformOperation) -> TransformOperation {
operation
.description("Get a user")
.summary("Get a user")
.tag("user")
.response_with::<200, Json<SingleResponse<User>>, _>(|t| {
let [sample, ..] = User::samples();
let response = SingleResponse::new_canonical(sample);
+2 -1
View File
@@ -100,7 +100,8 @@ impl IntoResponse for RouteError {
pub fn doc(operation: TransformOperation) -> TransformOperation {
operation
.description("List users")
.summary("List users")
.tag("user")
.response_with::<200, Json<PaginatedResponse<User>>, _>(|t| {
let users = User::samples();
let pagination = mas_storage::Pagination::first(users.len());
+18 -3
View File
@@ -18,7 +18,10 @@
"paths": {
"/api/admin/v1/users": {
"get": {
"description": "List users",
"tags": [
"user"
],
"summary": "List users",
"parameters": [
{
"in": "query",
@@ -171,7 +174,10 @@
},
"/api/admin/v1/users/{id}": {
"get": {
"description": "Get a user",
"tags": [
"user"
],
"summary": "Get a user",
"parameters": [
{
"in": "path",
@@ -238,7 +244,10 @@
},
"/api/admin/v1/users/by-username/{username}": {
"get": {
"description": "Get a user by its username (localpart)",
"tags": [
"user"
],
"summary": "Get a user by its username (localpart)",
"parameters": [
{
"in": "path",
@@ -631,5 +640,11 @@
"urn:mas:admin"
]
}
],
"tags": [
{
"name": "user",
"description": "Manage users"
}
]
}