Skip to content

Commit 17f1a5c

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add OpenAPI spec for code-coverage PR summary and files endpoints (#1765)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 7cbd6aa commit 17f1a5c

8 files changed

Lines changed: 102 additions & 39 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13100,12 +13100,17 @@ components:
1310013100
minLength: 1
1310113101
type: string
1310213102
repository_id:
13103-
description: The repository identifier.
13103+
deprecated: true
13104+
description: "Deprecated: use `repository_url` instead. The repository URL."
1310413105
example: github.com/datadog/shopist
1310513106
minLength: 1
1310613107
type: string
13108+
repository_url:
13109+
description: The repository URL. Accepts a full URL with or without a scheme (for example, `https://github.com/org/repo` or `github.com/org/repo`).
13110+
example: https://github.com/datadog/shopist
13111+
minLength: 1
13112+
type: string
1310713113
required:
13108-
- repository_id
1310913114
- branch
1311013115
type: object
1311113116
BranchCoverageSummaryRequestData:
@@ -19067,12 +19072,17 @@ components:
1906719072
pattern: "^[a-fA-F0-9]{40}$"
1906819073
type: string
1906919074
repository_id:
19070-
description: The repository identifier.
19075+
deprecated: true
19076+
description: "Deprecated: use `repository_url` instead. The repository URL."
1907119077
example: github.com/datadog/shopist
1907219078
minLength: 1
1907319079
type: string
19080+
repository_url:
19081+
description: The repository URL. Accepts a full URL with or without a scheme (for example, `https://github.com/org/repo` or `github.com/org/repo`).
19082+
example: https://github.com/datadog/shopist
19083+
minLength: 1
19084+
type: string
1907419085
required:
19075-
- repository_id
1907619086
- commit_sha
1907719087
type: object
1907819088
CommitCoverageSummaryRequestData:
@@ -122130,7 +122140,7 @@ paths:
122130122140
data:
122131122141
attributes:
122132122142
branch: prod
122133-
repository_id: github.com/datadog/test-service
122143+
repository_url: https://github.com/datadog/test-service
122134122144
type: ci_app_coverage_branch_summary_request
122135122145
schema:
122136122146
$ref: "#/components/schemas/BranchCoverageSummaryRequest"
@@ -122200,7 +122210,7 @@ paths:
122200122210
data:
122201122211
attributes:
122202122212
commit_sha: 66adc9350f2cc9b250b69abddab733dd55e1a588
122203-
repository_id: github.com/datadog/test-service
122213+
repository_url: https://github.com/datadog/test-service
122204122214
type: ci_app_coverage_commit_summary_request
122205122215
schema:
122206122216
$ref: "#/components/schemas/CommitCoverageSummaryRequest"

examples/v2_code-coverage_GetCodeCoverageBranchSummary.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ use datadog_api_client::datadogV2::model::BranchCoverageSummaryRequestType;
99
#[tokio::main]
1010
async fn main() {
1111
let body = BranchCoverageSummaryRequest::new(BranchCoverageSummaryRequestData::new(
12-
BranchCoverageSummaryRequestAttributes::new(
13-
"prod".to_string(),
14-
"github.com/datadog/shopist".to_string(),
15-
),
12+
BranchCoverageSummaryRequestAttributes::new("prod".to_string())
13+
.repository_id("github.com/datadog/shopist".to_string())
14+
.repository_url("https://github.com/datadog/shopist".to_string()),
1615
BranchCoverageSummaryRequestType::CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST,
1716
));
1817
let mut configuration = datadog::Configuration::new();

examples/v2_code-coverage_GetCodeCoverageBranchSummary_2532383345.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ use datadog_api_client::datadogV2::model::BranchCoverageSummaryRequestType;
99
#[tokio::main]
1010
async fn main() {
1111
let body = BranchCoverageSummaryRequest::new(BranchCoverageSummaryRequestData::new(
12-
BranchCoverageSummaryRequestAttributes::new(
13-
"prod".to_string(),
14-
"github.com/datadog/shopist".to_string(),
15-
),
12+
BranchCoverageSummaryRequestAttributes::new("prod".to_string())
13+
.repository_id("github.com/datadog/shopist".to_string()),
1614
BranchCoverageSummaryRequestType::CI_APP_COVERAGE_BRANCH_SUMMARY_REQUEST,
1715
));
1816
let mut configuration = datadog::Configuration::new();

examples/v2_code-coverage_GetCodeCoverageCommitSummary.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ async fn main() {
1111
let body = CommitCoverageSummaryRequest::new(CommitCoverageSummaryRequestData::new(
1212
CommitCoverageSummaryRequestAttributes::new(
1313
"66adc9350f2cc9b250b69abddab733dd55e1a588".to_string(),
14-
"github.com/datadog/shopist".to_string(),
15-
),
14+
)
15+
.repository_id("github.com/datadog/shopist".to_string())
16+
.repository_url("https://github.com/datadog/shopist".to_string()),
1617
CommitCoverageSummaryRequestType::CI_APP_COVERAGE_COMMIT_SUMMARY_REQUEST,
1718
));
1819
let mut configuration = datadog::Configuration::new();

examples/v2_code-coverage_GetCodeCoverageCommitSummary_2575243916.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ async fn main() {
1111
let body = CommitCoverageSummaryRequest::new(CommitCoverageSummaryRequestData::new(
1212
CommitCoverageSummaryRequestAttributes::new(
1313
"c55b0ce584e139bde41a00002ab31bc7d75f791d".to_string(),
14-
"github.com/datadog/shopist".to_string(),
15-
),
14+
)
15+
.repository_id("github.com/datadog/shopist".to_string()),
1616
CommitCoverageSummaryRequestType::CI_APP_COVERAGE_COMMIT_SUMMARY_REQUEST,
1717
));
1818
let mut configuration = datadog::Configuration::new();

src/datadogV2/model/model_branch_coverage_summary_request_attributes.rs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ pub struct BranchCoverageSummaryRequestAttributes {
1414
/// The branch name.
1515
#[serde(rename = "branch")]
1616
pub branch: String,
17-
/// The repository identifier.
17+
/// Deprecated: use `repository_url` instead. The repository URL.
18+
#[deprecated]
1819
#[serde(rename = "repository_id")]
19-
pub repository_id: String,
20+
pub repository_id: Option<String>,
21+
/// The repository URL. Accepts a full URL with or without a scheme (for example, `<https://github.com/org/repo`> or `github.com/org/repo`).
22+
#[serde(rename = "repository_url")]
23+
pub repository_url: Option<String>,
2024
#[serde(flatten)]
2125
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
2226
#[serde(skip)]
@@ -25,15 +29,29 @@ pub struct BranchCoverageSummaryRequestAttributes {
2529
}
2630

2731
impl BranchCoverageSummaryRequestAttributes {
28-
pub fn new(branch: String, repository_id: String) -> BranchCoverageSummaryRequestAttributes {
32+
pub fn new(branch: String) -> BranchCoverageSummaryRequestAttributes {
33+
#[allow(deprecated)]
2934
BranchCoverageSummaryRequestAttributes {
3035
branch,
31-
repository_id,
36+
repository_id: None,
37+
repository_url: None,
3238
additional_properties: std::collections::BTreeMap::new(),
3339
_unparsed: false,
3440
}
3541
}
3642

43+
#[allow(deprecated)]
44+
pub fn repository_id(mut self, value: String) -> Self {
45+
self.repository_id = Some(value);
46+
self
47+
}
48+
49+
#[allow(deprecated)]
50+
pub fn repository_url(mut self, value: String) -> Self {
51+
self.repository_url = Some(value);
52+
self
53+
}
54+
3755
pub fn additional_properties(
3856
mut self,
3957
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -62,6 +80,7 @@ impl<'de> Deserialize<'de> for BranchCoverageSummaryRequestAttributes {
6280
{
6381
let mut branch: Option<String> = None;
6482
let mut repository_id: Option<String> = None;
83+
let mut repository_url: Option<String> = None;
6584
let mut additional_properties: std::collections::BTreeMap<
6685
String,
6786
serde_json::Value,
@@ -74,9 +93,19 @@ impl<'de> Deserialize<'de> for BranchCoverageSummaryRequestAttributes {
7493
branch = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
7594
}
7695
"repository_id" => {
96+
if v.is_null() {
97+
continue;
98+
}
7799
repository_id =
78100
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
79101
}
102+
"repository_url" => {
103+
if v.is_null() {
104+
continue;
105+
}
106+
repository_url =
107+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
108+
}
80109
&_ => {
81110
if let Ok(value) = serde_json::from_value(v.clone()) {
82111
additional_properties.insert(k, value);
@@ -85,12 +114,12 @@ impl<'de> Deserialize<'de> for BranchCoverageSummaryRequestAttributes {
85114
}
86115
}
87116
let branch = branch.ok_or_else(|| M::Error::missing_field("branch"))?;
88-
let repository_id =
89-
repository_id.ok_or_else(|| M::Error::missing_field("repository_id"))?;
90117

118+
#[allow(deprecated)]
91119
let content = BranchCoverageSummaryRequestAttributes {
92120
branch,
93121
repository_id,
122+
repository_url,
94123
additional_properties,
95124
_unparsed,
96125
};

src/datadogV2/model/model_commit_coverage_summary_request_attributes.rs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ pub struct CommitCoverageSummaryRequestAttributes {
1414
/// The commit SHA (40-character hexadecimal string).
1515
#[serde(rename = "commit_sha")]
1616
pub commit_sha: String,
17-
/// The repository identifier.
17+
/// Deprecated: use `repository_url` instead. The repository URL.
18+
#[deprecated]
1819
#[serde(rename = "repository_id")]
19-
pub repository_id: String,
20+
pub repository_id: Option<String>,
21+
/// The repository URL. Accepts a full URL with or without a scheme (for example, `<https://github.com/org/repo`> or `github.com/org/repo`).
22+
#[serde(rename = "repository_url")]
23+
pub repository_url: Option<String>,
2024
#[serde(flatten)]
2125
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
2226
#[serde(skip)]
@@ -25,18 +29,29 @@ pub struct CommitCoverageSummaryRequestAttributes {
2529
}
2630

2731
impl CommitCoverageSummaryRequestAttributes {
28-
pub fn new(
29-
commit_sha: String,
30-
repository_id: String,
31-
) -> CommitCoverageSummaryRequestAttributes {
32+
pub fn new(commit_sha: String) -> CommitCoverageSummaryRequestAttributes {
33+
#[allow(deprecated)]
3234
CommitCoverageSummaryRequestAttributes {
3335
commit_sha,
34-
repository_id,
36+
repository_id: None,
37+
repository_url: None,
3538
additional_properties: std::collections::BTreeMap::new(),
3639
_unparsed: false,
3740
}
3841
}
3942

43+
#[allow(deprecated)]
44+
pub fn repository_id(mut self, value: String) -> Self {
45+
self.repository_id = Some(value);
46+
self
47+
}
48+
49+
#[allow(deprecated)]
50+
pub fn repository_url(mut self, value: String) -> Self {
51+
self.repository_url = Some(value);
52+
self
53+
}
54+
4055
pub fn additional_properties(
4156
mut self,
4257
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -65,6 +80,7 @@ impl<'de> Deserialize<'de> for CommitCoverageSummaryRequestAttributes {
6580
{
6681
let mut commit_sha: Option<String> = None;
6782
let mut repository_id: Option<String> = None;
83+
let mut repository_url: Option<String> = None;
6884
let mut additional_properties: std::collections::BTreeMap<
6985
String,
7086
serde_json::Value,
@@ -77,9 +93,19 @@ impl<'de> Deserialize<'de> for CommitCoverageSummaryRequestAttributes {
7793
commit_sha = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
7894
}
7995
"repository_id" => {
96+
if v.is_null() {
97+
continue;
98+
}
8099
repository_id =
81100
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
82101
}
102+
"repository_url" => {
103+
if v.is_null() {
104+
continue;
105+
}
106+
repository_url =
107+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
108+
}
83109
&_ => {
84110
if let Ok(value) = serde_json::from_value(v.clone()) {
85111
additional_properties.insert(k, value);
@@ -88,12 +114,12 @@ impl<'de> Deserialize<'de> for CommitCoverageSummaryRequestAttributes {
88114
}
89115
}
90116
let commit_sha = commit_sha.ok_or_else(|| M::Error::missing_field("commit_sha"))?;
91-
let repository_id =
92-
repository_id.ok_or_else(|| M::Error::missing_field("repository_id"))?;
93117

118+
#[allow(deprecated)]
94119
let content = CommitCoverageSummaryRequestAttributes {
95120
commit_sha,
96121
repository_id,
122+
repository_url,
97123
additional_properties,
98124
_unparsed,
99125
};

tests/scenarios/features/v2/code_coverage.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ Feature: Code Coverage
1313
Scenario: Get code coverage summary for a branch returns "Bad Request" response
1414
Given operation "GetCodeCoverageBranchSummary" enabled
1515
And new "GetCodeCoverageBranchSummary" request
16-
And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}}
16+
And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist", "repository_url": "https://github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}}
1717
When the request is sent
1818
Then the response status is 400 Bad Request
1919

2020
@generated @skip @team:DataDog/ci-app-backend
2121
Scenario: Get code coverage summary for a branch returns "Not Found" response
2222
Given operation "GetCodeCoverageBranchSummary" enabled
2323
And new "GetCodeCoverageBranchSummary" request
24-
And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}}
24+
And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist", "repository_url": "https://github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}}
2525
When the request is sent
2626
Then the response status is 404 Not Found
2727

2828
@generated @skip @team:DataDog/ci-app-backend
2929
Scenario: Get code coverage summary for a branch returns "OK" response
3030
Given operation "GetCodeCoverageBranchSummary" enabled
3131
And new "GetCodeCoverageBranchSummary" request
32-
And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}}
32+
And body with value {"data": {"attributes": {"branch": "prod", "repository_id": "github.com/datadog/shopist", "repository_url": "https://github.com/datadog/shopist"}, "type": "ci_app_coverage_branch_summary_request"}}
3333
When the request is sent
3434
Then the response status is 200 OK
3535

@@ -61,23 +61,23 @@ Feature: Code Coverage
6161
Scenario: Get code coverage summary for a commit returns "Bad Request" response
6262
Given operation "GetCodeCoverageCommitSummary" enabled
6363
And new "GetCodeCoverageCommitSummary" request
64-
And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}}
64+
And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist", "repository_url": "https://github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}}
6565
When the request is sent
6666
Then the response status is 400 Bad Request
6767

6868
@generated @skip @team:DataDog/ci-app-backend
6969
Scenario: Get code coverage summary for a commit returns "Not Found" response
7070
Given operation "GetCodeCoverageCommitSummary" enabled
7171
And new "GetCodeCoverageCommitSummary" request
72-
And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}}
72+
And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist", "repository_url": "https://github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}}
7373
When the request is sent
7474
Then the response status is 404 Not Found
7575

7676
@generated @skip @team:DataDog/ci-app-backend
7777
Scenario: Get code coverage summary for a commit returns "OK" response
7878
Given operation "GetCodeCoverageCommitSummary" enabled
7979
And new "GetCodeCoverageCommitSummary" request
80-
And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}}
80+
And body with value {"data": {"attributes": {"commit_sha": "66adc9350f2cc9b250b69abddab733dd55e1a588", "repository_id": "github.com/datadog/shopist", "repository_url": "https://github.com/datadog/shopist"}, "type": "ci_app_coverage_commit_summary_request"}}
8181
When the request is sent
8282
Then the response status is 200 OK
8383

0 commit comments

Comments
 (0)