Skip to content

Commit

Permalink
Document type in schmea
Browse files Browse the repository at this point in the history
  • Loading branch information
jssblck committed May 17, 2024
1 parent 2d2ba6c commit ff0de40
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion src/locator.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/locator_package.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/locator_strict.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ff0de40

Please sign in to comment.