Skip to content

Commit b671d0b

Browse files
committed
Set response metadata appropriately
1 parent 9d475c0 commit b671d0b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

modules/fundamental/src/sbom/endpoints/mod.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ use crate::{
2525
service::SbomService,
2626
},
2727
};
28-
use actix_web::{HttpResponse, Responder, delete, get, http::header, post, web, web::BytesMut};
28+
use actix_web::{
29+
HttpResponse, Responder, delete, get,
30+
http::header::{self, ContentType},
31+
post,
32+
web::{self, BytesMut},
33+
};
2934
use config::Config;
3035
use futures_util::TryStreamExt;
3136
use sea_orm::{TransactionTrait, prelude::Uuid};
@@ -556,7 +561,7 @@ pub async fn create_exploitiq_report(
556561
let buf = s.try_collect::<BytesMut>().await?;
557562
let sbom: serde_json::Value = serde_json::from_slice(buf.as_ref())?;
558563
let req = ExploitIqRequest::new(sbom, vulnerabilities);
559-
HttpResponse::Ok().json(create_report(req).await?)
564+
HttpResponse::Created().json(create_report(req).await?)
560565
}
561566
None => HttpResponse::NotFound().finish(),
562567
}),
@@ -572,11 +577,14 @@ pub async fn create_exploitiq_report(
572577
("id" = String, description = "ExploitIQ report id"),
573578
),
574579
responses(
575-
(status = 200, description = "The proxied ExploitIQ report", body = inline(BinaryData)),
580+
(status = 200, description = "The proxied ExploitIQ report", body = serde_json::Value),
576581
)
577582
)]
578583
#[get("/v2/sbom/exploitiq/{id}")]
579584
pub async fn fetch_exploitiq_report(id: web::Path<String>) -> Result<impl Responder, Error> {
580585
let id = id.into_inner();
581-
Ok(HttpResponse::Ok().streaming(fetch_report(id).await?))
586+
let stream = fetch_report(id).await?;
587+
Ok(HttpResponse::Ok()
588+
.content_type(ContentType::json())
589+
.streaming(stream))
582590
}

openapi.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,9 +2394,7 @@ paths:
23942394
description: The proxied ExploitIQ report
23952395
content:
23962396
application/json:
2397-
schema:
2398-
type: string
2399-
format: binary
2397+
schema: {}
24002398
/api/v2/sbom/{id}:
24012399
get:
24022400
tags:

0 commit comments

Comments
 (0)