mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Improves OpenApi documentation
This commit is contained in:
1 parent
f2703b86c5
commit
77f95708b9
101 files changed
+2336
-294
No files matched your search
+4
-1
@@ -20,6 +20,9 @@ public class CheckInitializationEndpointSummary : Summary<CheckInitializationEnd
|
||||
Summary = "Checks the initialization status of the application.";
|
||||
Description = "Checks the initialization status of the application (if the Admin account exists).";
|
||||
|
||||
Response<InitializationResponse>(200, "The application initialization status is returned.");
|
||||
Response(200, "The application initialization status is returned.",
|
||||
example: new InitializationResponse(
|
||||
IsInitialized: true
|
||||
));
|
||||
}
|
||||
}
|
||||
+63
-6
@@ -1,6 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -20,12 +23,66 @@ public class SetupApplicationEndpointSummary : Summary<SetupApplicationEndpoint,
|
||||
Summary = "Performs the initial application setup.";
|
||||
Description = "Performs the initial application setup, including creating the Admin account.";
|
||||
|
||||
RequestParam(r => r.Username, "The desired username for the new account.");
|
||||
RequestParam(r => r.Password, "The password for the new account.");
|
||||
RequestParam(r => r.PasswordConfirm, "The confirmation of the entered password, used to ensure consistency.");
|
||||
RequestParam(r => r.Use2fa, "Indicates whether two-factor authentication (2FA) should be enabled for the new account.");
|
||||
ExampleRequest = new RegistrationRequest(
|
||||
Username: "JohnDoe",
|
||||
Password: "Abcd123$",
|
||||
PasswordConfirm: "Abcd123$",
|
||||
Use2fa: true
|
||||
);
|
||||
RequestExamples.Add(new RequestExample(new RegistrationRequest(
|
||||
Username: "JohnDoe",
|
||||
Password: "Abcd123$",
|
||||
PasswordConfirm: "Abcd123$",
|
||||
Use2fa: false
|
||||
)));
|
||||
|
||||
Response(200, "The Admin account of the application is returned.");
|
||||
Response<ProblemDetails>(422, "The request did not pass validation checks.", "application/problem+json");
|
||||
RequestParam(r => r.Username, "The desired username for the new account. Required.");
|
||||
RequestParam(r => r.Password, "The password for the new account. Required.");
|
||||
RequestParam(r => r.PasswordConfirm, "The confirmation of the entered password, used to ensure consistency. Required.");
|
||||
RequestParam(r => r.Use2fa, "Indicates whether two-factor authentication (2FA) should be enabled for the new account. Optional.");
|
||||
|
||||
Response(201, "The Admin account of the application is returned.", example:
|
||||
new RegistrationResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
Username: "JohnDoe",
|
||||
TotpSecret: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABCQAAAQkAQAAAACN7fKkAAAFW0lEQVR4nO3bQW4cOQwF0L6B73/L3MABjCp/ilR1BphkFAl..."
|
||||
));
|
||||
|
||||
Response(403, "The request failed because the application is already initialized (Admin account exists).", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "AdminAccountAlreadyCreated",
|
||||
instance = "/api/v1/initialization",
|
||||
traceId = "00-4d94289ee3cddd8d1a3da9ef35bd37a8-585fbdf2b5ad5e03-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/initialization",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"UsernameCannotBeEmpty",
|
||||
"PassordCannotBeEmpty",
|
||||
"InvalidPassword",
|
||||
"PasswordConfirmCannotBeEmpty",
|
||||
"PasswordsNotMatch"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user