using System.Text.Json.Serialization;
namespace EonaCat.DoxaApi.Models
{
// This file is part of the EonaCat project(s) which is released under the Apache License.
// See the LICENSE file or go to https://EonaCat.com/license for full license details.
///
/// Describes how a single security scheme authenticates requests.
/// Mirrors the relevant parts of the OpenAPI "securityScheme" object so it can be
/// losslessly exported to OpenAPI/Swagger, while also carrying enough information
/// for the DoxaApi UI to render a live "Try it" authorization form.
///
public sealed class SecuritySchemeModel
{
[JsonPropertyName("id")]
public string Id { get; set; } = "";
/// apiKey | http | oauth2 | openIdConnect
[JsonPropertyName("type")]
public string Type { get; set; } = "apiKey";
[JsonPropertyName("description")]
public string? Description { get; set; }
/// For apiKey: header | query | cookie
[JsonPropertyName("in")]
public string? In { get; set; }
/// For apiKey: the header/query/cookie name. For http: ignored.
[JsonPropertyName("name")]
public string? Name { get; set; }
/// For http: bearer | basic | digest
[JsonPropertyName("scheme")]
public string? Scheme { get; set; }
/// For http bearer: an informational hint such as "JWT".
[JsonPropertyName("bearerFormat")]
public string? BearerFormat { get; set; }
/// For oauth2: supported flows (clientCredentials, authorizationCode, password, implicit).
[JsonPropertyName("flows")]
public OAuthFlowsModel? Flows { get; set; }
}
public sealed class OAuthFlowsModel
{
[JsonPropertyName("clientCredentials")]
public OAuthFlowModel? ClientCredentials { get; set; }
[JsonPropertyName("authorizationCode")]
public OAuthFlowModel? AuthorizationCode { get; set; }
[JsonPropertyName("password")]
public OAuthFlowModel? Password { get; set; }
[JsonPropertyName("implicit")]
public OAuthFlowModel? Implicit { get; set; }
}
public sealed class OAuthFlowModel
{
[JsonPropertyName("authorizationUrl")]
public string? AuthorizationUrl { get; set; }
[JsonPropertyName("tokenUrl")]
public string? TokenUrl { get; set; }
[JsonPropertyName("refreshUrl")]
public string? RefreshUrl { get; set; }
[JsonPropertyName("scopes")]
public Dictionary Scopes { get; set; } = new();
}
}