Add utoipa info for v2 routes (#5775)

* wip: add v2 docs, routes to config, paths

* fix up path prefixes

* fix leading slashes

* fix slash route

* fix more slashes

* wip: full utopification of v2

* convert last few v2 routes to utoipa
This commit is contained in:
aecsocket
2026-04-15 13:25:35 +00:00
committed by GitHub
parent baee34b0b6
commit f12bd7b4b8
28 changed files with 1979 additions and 211 deletions
+9 -5
View File
@@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize};
use validator::Validate;
/// A project returned from the API
#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, utoipa::ToSchema)]
pub struct LegacyProject {
/// Relevant V2 fields- these were removed or modified in V3,
/// and are now part of the dynamic fields system
@@ -253,7 +253,9 @@ impl LegacyProject {
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Copy)]
#[derive(
Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Copy, utoipa::ToSchema,
)]
#[serde(rename_all = "kebab-case")]
pub enum LegacySideType {
Required,
@@ -290,7 +292,7 @@ impl LegacySideType {
}
/// A specific version of a project
#[derive(Serialize, Deserialize, Clone)]
#[derive(Serialize, Deserialize, Clone, utoipa::ToSchema)]
pub struct LegacyVersion {
/// Relevant V2 fields- these were removed or modified in V3,
/// and are now part of the dynamic fields system
@@ -368,7 +370,7 @@ impl From<Version> for LegacyVersion {
}
}
#[derive(Serialize, Deserialize, Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug, utoipa::ToSchema)]
pub struct LegacyGalleryItem {
pub url: String,
pub raw_url: String,
@@ -393,7 +395,9 @@ impl LegacyGalleryItem {
}
}
#[derive(Serialize, Deserialize, Validate, Clone, Eq, PartialEq)]
#[derive(
Serialize, Deserialize, Validate, Clone, Eq, PartialEq, utoipa::ToSchema,
)]
pub struct DonationLink {
pub id: String,
pub platform: String,
+13
View File
@@ -124,6 +124,19 @@ bitflags::bitflags! {
bitflags_serde_impl!(Scopes, u64);
impl utoipa::PartialSchema for Scopes {
fn schema() -> utoipa::openapi::RefOr<utoipa::openapi::schema::Schema> {
utoipa::openapi::ObjectBuilder::new()
.schema_type(utoipa::openapi::schema::Type::Integer)
.format(Some(utoipa::openapi::SchemaFormat::KnownFormat(
utoipa::openapi::KnownFormat::Int64,
)))
.into()
}
}
impl utoipa::ToSchema for Scopes {}
impl Scopes {
// these scopes cannot be specified in a personal access token
pub fn restricted() -> Scopes {
+34
View File
@@ -33,6 +33,23 @@ bitflags::bitflags! {
bitflags_serde_impl!(ProjectPermissions, u64);
impl utoipa::PartialSchema for ProjectPermissions {
fn schema() -> utoipa::openapi::RefOr<utoipa::openapi::schema::Schema> {
u64::schema()
}
}
impl utoipa::ToSchema for ProjectPermissions {
fn schemas(
schemas: &mut Vec<(
String,
utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>,
)>,
) {
u64::schemas(schemas);
}
}
impl Default for ProjectPermissions {
fn default() -> ProjectPermissions {
ProjectPermissions::empty()
@@ -92,6 +109,23 @@ bitflags::bitflags! {
bitflags_serde_impl!(OrganizationPermissions, u64);
impl utoipa::PartialSchema for OrganizationPermissions {
fn schema() -> utoipa::openapi::RefOr<utoipa::openapi::schema::Schema> {
u64::schema()
}
}
impl utoipa::ToSchema for OrganizationPermissions {
fn schemas(
schemas: &mut Vec<(
String,
utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>,
)>,
) {
u64::schemas(schemas);
}
}
impl Default for OrganizationPermissions {
fn default() -> OrganizationPermissions {
OrganizationPermissions::NONE