Skip to content

Commit

Permalink
Add OpenAPI schemas for the sbom details.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob McWhirter committed Jul 19, 2024
1 parent 23f4fae commit 54e4744
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion modules/fundamental/src/sbom/endpoints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ pub fn configure(config: &mut web::ServiceConfig, db: Database) {
crate::sbom::model::SbomPackage,
crate::sbom::model::SbomPackageRelation,
crate::sbom::model::SbomSummary,
crate::sbom::model::details::SbomDetails,
crate::sbom::model::details::SbomAdvisory,
crate::sbom::model::details::SbomStatus,
crate::sbom::model::SbomHead,
crate::sbom::model::Which,
crate::purl::model::details::purl::StatusContext,
trustify_common::advisory::AdvisoryVulnerabilityAssertions,
trustify_common::advisory::Assertion,
trustify_common::purl::Purl,
Expand Down Expand Up @@ -165,7 +170,7 @@ pub async fn all_related(
("id" = string, Path, description = "Digest/hash of the document, prefixed by hash type, such as 'sha256:<hash>' or 'urn:uuid:<uuid>'"),
),
responses(
(status = 200, description = "Matching SBOM", body = SbomSummary),
(status = 200, description = "Matching SBOM", body = SbomDetails),
(status = 404, description = "Matching SBOM not found"),
),
)]
Expand Down
7 changes: 4 additions & 3 deletions modules/fundamental/src/sbom/model/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use std::collections::HashMap;
use time::OffsetDateTime;
use trustify_common::cpe::CpeCompare;
use trustify_common::db::ConnectionOrTransaction;
use utoipa::ToSchema;

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct SbomDetails {
#[serde(flatten)]
pub head: SbomHead,
Expand All @@ -27,7 +28,7 @@ pub struct SbomDetails {
pub advisories: Vec<SbomAdvisory>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct SbomAdvisory {
#[serde(flatten)]
pub head: AdvisoryHead,
Expand Down Expand Up @@ -146,7 +147,7 @@ impl SbomAdvisory {
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct SbomStatus {
pub vulnerability_id: String,
pub status: String,
Expand Down

0 comments on commit 54e4744

Please sign in to comment.