From ff0de409149826b1c5f317c60edf136b7c1fda11 Mon Sep 17 00:00:00 2001 From: Jessica Black Date: Fri, 17 May 2024 13:43:05 -0700 Subject: [PATCH] Document type in schmea --- Cargo.toml | 1 + src/locator.rs | 4 +++- src/locator_package.rs | 4 +++- src/locator_strict.rs | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 26c0b3b..ed1a146 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ thiserror = "1.0.31" typed-builder = "0.10.0" utoipa = "4.2.3" serde_json = "1.0.95" +documented = "0.4.1" [dev-dependencies] assert_matches = "1.5.0" diff --git a/src/locator.rs b/src/locator.rs index 6e88356..c4ec795 100644 --- a/src/locator.rs +++ b/src/locator.rs @@ -1,5 +1,6 @@ use std::{cmp::Ordering, fmt::Display}; +use documented::Documented; use getset::{CopyGetters, Getters}; use lazy_static::lazy_static; use regex::Regex; @@ -47,7 +48,7 @@ use crate::{parse_org_project, Error, Fetcher, PackageLocator, ParseError, Stric /// - `{fetcher}+{org_id}/{project}${revision}` /// /// This parse function is based on the function used in FOSSA Core for maximal compatibility. -#[derive(Clone, Eq, PartialEq, Hash, Debug, TypedBuilder, Getters, CopyGetters)] +#[derive(Clone, Eq, PartialEq, Hash, Debug, TypedBuilder, Getters, CopyGetters, Documented)] pub struct Locator { /// Determines which fetcher is used to download this project. #[getset(get_copy = "pub")] @@ -260,6 +261,7 @@ impl<'a> ToSchema<'a> for Locator { ( "Locator", ObjectBuilder::new() + .description(Some(Self::DOCS)) .example(Some(json!("git+github.com/fossas/example$1234"))) .min_length(Some(3)) .schema_type(SchemaType::String) diff --git a/src/locator_package.rs b/src/locator_package.rs index 3cc33db..5ee0d5b 100644 --- a/src/locator_package.rs +++ b/src/locator_package.rs @@ -1,5 +1,6 @@ use std::{cmp::Ordering, fmt::Display}; +use documented::Documented; use getset::{CopyGetters, Getters}; use serde::{Deserialize, Serialize}; use serde_json::json; @@ -32,7 +33,7 @@ use crate::{Error, Fetcher, Locator, StrictLocator}; /// - `{fetcher}+{org_id}/{project}${revision}` /// /// This implementation ignores the `revision` segment if it exists. If this is not preferred, use [`Locator`] instead. -#[derive(Clone, Eq, PartialEq, Hash, Debug, TypedBuilder, Getters, CopyGetters)] +#[derive(Clone, Eq, PartialEq, Hash, Debug, TypedBuilder, Getters, CopyGetters, Documented)] pub struct PackageLocator { /// Determines which fetcher is used to download this project. #[getset(get_copy = "pub")] @@ -135,6 +136,7 @@ impl<'a> ToSchema<'a> for PackageLocator { ( "PackageLocator", ObjectBuilder::new() + .description(Some(Self::DOCS)) .example(Some(json!("git+github.com/fossas/example"))) .min_length(Some(3)) .schema_type(SchemaType::String) diff --git a/src/locator_strict.rs b/src/locator_strict.rs index 9dbd364..a1a241a 100644 --- a/src/locator_strict.rs +++ b/src/locator_strict.rs @@ -1,5 +1,6 @@ use std::{cmp::Ordering, fmt::Display}; +use documented::Documented; use getset::{CopyGetters, Getters}; use serde::{Deserialize, Serialize}; use serde_json::json; @@ -27,7 +28,7 @@ use crate::{Error, Fetcher, Locator, PackageLocator, ParseError}; /// ```ignore /// {fetcher}+{org_id}/{project}${revision} /// ``` -#[derive(Clone, Eq, PartialEq, Hash, Debug, TypedBuilder, Getters, CopyGetters)] +#[derive(Clone, Eq, PartialEq, Hash, Debug, TypedBuilder, Getters, CopyGetters, Documented)] pub struct StrictLocator { /// Determines which fetcher is used to download this project. #[getset(get_copy = "pub")] @@ -160,6 +161,7 @@ impl<'a> ToSchema<'a> for StrictLocator { ( "StrictLocator", ObjectBuilder::new() + .description(Some(Self::DOCS)) .example(Some(json!("git+github.com/fossas/example$1234"))) .min_length(Some(3)) .schema_type(SchemaType::String)