Skip to content

Commit 88a0577

Browse files
authored
rust: Replace OpenAPI generator with openapi-codegen for model generation (#1644)
2 parents 328490d + ecfe6d8 commit 88a0577

File tree

200 files changed

+1178
-7272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+1178
-7272
lines changed

ChangeLog.md

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
* Libs/Rust **(Breaking)**: Add optional `EventTypeDeleteOptions` parameter to `EventType::delete`
2020
* Libs/Rust **(Breaking)**: Add optional `PostOptions` parameter to `Endpoint::recover`,
2121
`Endpoint::rotate_secret`, `Integration::rotate_key` and `MessageAttempt::resend`
22+
* Libs/Rust **(Breaking)**: Remove model files that were not referenced by any operations available
23+
through the `Svix` object
24+
* Libs/Rust **(Breaking)**: Switch `Patch` struct fields from `Option<Option<T>>` to
25+
`js_option::JsOption<T>`
26+
* Libs/Rust **(Breaking)**: Change `rate_limit` from `i32` to `u16` in several places
27+
* Libs/Rust **(Breaking)**: Remove `settings` parameter from `EnvironmentIn::new`
2228
* Libs/Go **(Breaking)**: Rename `Statistics.AggregateAppStats` to `AggregateAppStatsWithOptions`;
2329
the old name is used for a version of the method without the `PostOptions`, like elsewhere
2430
* Libs/Go: Add `Authentication.ExpireAll` (and `ExpireAllWithOptions`)

regen_openapi.sh

-5
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,5 @@ yarn openapi-generator-cli generate -i .codegen-tmp/openapi.json -g ruby -o ruby
5353

5454
yarn openapi-generator-cli generate -i .codegen-tmp/openapi.json -g csharp -o csharp/ -c csharp/openapi-generator-config.json --global-property apis,models,supportingFiles,apiTests=false,apiDocs=false,modelTests=false,modelDocs=false
5555

56-
# Cleanup previous codegen, allowing us to spot removals.
57-
# If the removals are expected, stage them eg. `git add -u`, then commit them.
58-
rm -rf rust/src/models
59-
yarn openapi-generator-cli generate -i .codegen-tmp/openapi-less-null.json -g rust -o rust/ -c rust/openapi-generator-config.json -t rust/templates
60-
6156
rm -rf .codegen-tmp
6257
echo Note: Python generation is not executed automatically.

rust/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ thiserror = "1.0.30"
4040
time = "0.3"
4141
url = "2.2"
4242
tokio = { version = "1.41.0", features = ["time"] }
43-
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
4443
itertools = "0.14.0"
44+
js_option = "0.1.1"
4545

4646
[dev-dependencies]
4747
tokio = { version = "1.41.0", features = ["macros"] }

rust/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use hyper_util::client::legacy::{connect::HttpConnector, Client as HyperClient};
1616
pub mod api;
1717
pub mod error;
1818
mod model_ext;
19-
#[allow(clippy::all)]
2019
mod models;
2120
mod request;
2221
pub mod webhooks;
+12-25
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
1-
/*
2-
* Svix API
3-
*
4-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5-
*
6-
* The version of the OpenAPI document: 1.1.1
7-
*
8-
* Generated by: https://openapi-generator.tech
9-
*/
10-
11-
#[allow(unused_imports)]
12-
use crate::models;
13-
#[allow(unused_imports)]
1+
// this file is @generated
142
use serde::{Deserialize, Serialize};
153

16-
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
use super::{
5+
background_task_status::BackgroundTaskStatus, background_task_type::BackgroundTaskType,
6+
};
7+
8+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
179
pub struct AggregateEventTypesOut {
18-
#[serde(rename = "id")]
1910
pub id: String,
20-
#[serde(rename = "status")]
21-
pub status: models::BackgroundTaskStatus,
22-
#[serde(rename = "task")]
23-
pub task: models::BackgroundTaskType,
11+
12+
pub status: BackgroundTaskStatus,
13+
14+
pub task: BackgroundTaskType,
2415
}
2516

2617
impl AggregateEventTypesOut {
27-
pub fn new(
28-
id: String,
29-
status: models::BackgroundTaskStatus,
30-
task: models::BackgroundTaskType,
31-
) -> AggregateEventTypesOut {
32-
AggregateEventTypesOut { id, status, task }
18+
pub fn new(id: String, status: BackgroundTaskStatus, task: BackgroundTaskType) -> Self {
19+
Self { id, status, task }
3320
}
3421
}

rust/src/models/app_portal_access_in.rs

+22-23
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
/*
2-
* Svix API
3-
*
4-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5-
*
6-
* The version of the OpenAPI document: 1.1.1
7-
*
8-
* Generated by: https://openapi-generator.tech
9-
*/
10-
11-
#[allow(unused_imports)]
12-
use crate::models;
13-
#[allow(unused_imports)]
1+
// this file is @generated
142
use serde::{Deserialize, Serialize};
153

16-
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
use super::application_in::ApplicationIn;
5+
6+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
177
pub struct AppPortalAccessIn {
18-
#[serde(rename = "application", skip_serializing_if = "Option::is_none")]
19-
pub application: Option<Box<models::ApplicationIn>>,
20-
/// How long the token will be valid for, in seconds. Valid values are
21-
/// between 1 hour and 7 days. The default is 7 days.
22-
#[serde(rename = "expiry", skip_serializing_if = "Option::is_none")]
8+
/// Optionally creates a new application while generating the access link.
9+
/// If the application id or uid that is used in the path already exists,
10+
/// this argument is ignored.
11+
#[serde(skip_serializing_if = "Option::is_none")]
12+
pub application: Option<ApplicationIn>,
13+
14+
/// How long the token will be valid for, in seconds.
15+
///
16+
/// Valid values are between 1 hour and 7 days. The default is 7 days.
17+
#[serde(skip_serializing_if = "Option::is_none")]
2318
pub expiry: Option<i32>,
19+
2420
/// The set of feature flags the created token will have access to.
25-
#[serde(rename = "featureFlags", skip_serializing_if = "Option::is_none")]
21+
#[serde(rename = "featureFlags")]
22+
#[serde(skip_serializing_if = "Option::is_none")]
2623
pub feature_flags: Option<Vec<String>>,
24+
2725
/// Whether the app portal should be in read-only mode.
28-
#[serde(rename = "readOnly", skip_serializing_if = "Option::is_none")]
26+
#[serde(rename = "readOnly")]
27+
#[serde(skip_serializing_if = "Option::is_none")]
2928
pub read_only: Option<bool>,
3029
}
3130

3231
impl AppPortalAccessIn {
33-
pub fn new() -> AppPortalAccessIn {
34-
AppPortalAccessIn {
32+
pub fn new() -> Self {
33+
Self {
3534
application: None,
3635
expiry: None,
3736
feature_flags: None,
+5-18
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
/*
2-
* Svix API
3-
*
4-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5-
*
6-
* The version of the OpenAPI document: 1.1.1
7-
*
8-
* Generated by: https://openapi-generator.tech
9-
*/
10-
11-
#[allow(unused_imports)]
12-
use crate::models;
13-
#[allow(unused_imports)]
1+
// this file is @generated
142
use serde::{Deserialize, Serialize};
153

16-
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
175
pub struct AppPortalAccessOut {
18-
#[serde(rename = "token")]
196
pub token: String,
20-
#[serde(rename = "url")]
7+
218
pub url: String,
229
}
2310

2411
impl AppPortalAccessOut {
25-
pub fn new(token: String, url: String) -> AppPortalAccessOut {
26-
AppPortalAccessOut { token, url }
12+
pub fn new(token: String, url: String) -> Self {
13+
Self { token, url }
2714
}
2815
}

rust/src/models/app_usage_stats_in.rs

+12-21
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1-
/*
2-
* Svix API
3-
*
4-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5-
*
6-
* The version of the OpenAPI document: 1.1.1
7-
*
8-
* Generated by: https://openapi-generator.tech
9-
*/
10-
11-
#[allow(unused_imports)]
12-
use crate::models;
13-
#[allow(unused_imports)]
1+
// this file is @generated
142
use serde::{Deserialize, Serialize};
153

16-
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
175
pub struct AppUsageStatsIn {
18-
/// Specific app IDs or UIDs to aggregate stats for. Note that if none of
19-
/// the given IDs or UIDs are resolved, a 422 response will be given.
20-
#[serde(rename = "appIds", skip_serializing_if = "Option::is_none")]
6+
/// Specific app IDs or UIDs to aggregate stats for.
7+
///
8+
/// Note that if none of the given IDs or UIDs are resolved, a 422 response
9+
/// will be given.
10+
#[serde(rename = "appIds")]
11+
#[serde(skip_serializing_if = "Option::is_none")]
2112
pub app_ids: Option<Vec<String>>,
22-
#[serde(rename = "since")]
13+
2314
pub since: String,
24-
#[serde(rename = "until")]
15+
2516
pub until: String,
2617
}
2718

2819
impl AppUsageStatsIn {
29-
pub fn new(since: String, until: String) -> AppUsageStatsIn {
30-
AppUsageStatsIn {
20+
pub fn new(since: String, until: String) -> Self {
21+
Self {
3122
app_ids: None,
3223
since,
3324
until,

rust/src/models/app_usage_stats_out.rs

+18-25
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,33 @@
1-
/*
2-
* Svix API
3-
*
4-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5-
*
6-
* The version of the OpenAPI document: 1.1.1
7-
*
8-
* Generated by: https://openapi-generator.tech
9-
*/
10-
11-
#[allow(unused_imports)]
12-
use crate::models;
13-
#[allow(unused_imports)]
1+
// this file is @generated
142
use serde::{Deserialize, Serialize};
153

16-
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
use super::{
5+
background_task_status::BackgroundTaskStatus, background_task_type::BackgroundTaskType,
6+
};
7+
8+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
179
pub struct AppUsageStatsOut {
18-
#[serde(rename = "id")]
1910
pub id: String,
20-
#[serde(rename = "status")]
21-
pub status: models::BackgroundTaskStatus,
22-
#[serde(rename = "task")]
23-
pub task: models::BackgroundTaskType,
24-
/// Any app IDs or UIDs received in the request that weren't found. Stats
25-
/// will be produced for all the others.
11+
12+
pub status: BackgroundTaskStatus,
13+
14+
pub task: BackgroundTaskType,
15+
16+
/// Any app IDs or UIDs received in the request that weren't found.
17+
///
18+
/// Stats will be produced for all the others.
2619
#[serde(rename = "unresolvedAppIds")]
2720
pub unresolved_app_ids: Vec<String>,
2821
}
2922

3023
impl AppUsageStatsOut {
3124
pub fn new(
3225
id: String,
33-
status: models::BackgroundTaskStatus,
34-
task: models::BackgroundTaskType,
26+
status: BackgroundTaskStatus,
27+
task: BackgroundTaskType,
3528
unresolved_app_ids: Vec<String>,
36-
) -> AppUsageStatsOut {
37-
AppUsageStatsOut {
29+
) -> Self {
30+
Self {
3831
id,
3932
status,
4033
task,

rust/src/models/application_in.rs

+12-21
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
1-
/*
2-
* Svix API
3-
*
4-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5-
*
6-
* The version of the OpenAPI document: 1.1.1
7-
*
8-
* Generated by: https://openapi-generator.tech
9-
*/
10-
11-
#[allow(unused_imports)]
12-
use crate::models;
13-
#[allow(unused_imports)]
1+
// this file is @generated
142
use serde::{Deserialize, Serialize};
153

16-
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
175
pub struct ApplicationIn {
18-
#[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
6+
#[serde(skip_serializing_if = "Option::is_none")]
197
pub metadata: Option<std::collections::HashMap<String, String>>,
20-
#[serde(rename = "name")]
8+
219
pub name: String,
22-
#[serde(rename = "rateLimit", skip_serializing_if = "Option::is_none")]
23-
pub rate_limit: Option<i32>,
10+
11+
#[serde(rename = "rateLimit")]
12+
#[serde(skip_serializing_if = "Option::is_none")]
13+
pub rate_limit: Option<u16>,
14+
2415
/// Optional unique identifier for the application.
25-
#[serde(rename = "uid", skip_serializing_if = "Option::is_none")]
16+
#[serde(skip_serializing_if = "Option::is_none")]
2617
pub uid: Option<String>,
2718
}
2819

2920
impl ApplicationIn {
30-
pub fn new(name: String) -> ApplicationIn {
31-
ApplicationIn {
21+
pub fn new(name: String) -> Self {
22+
Self {
3223
metadata: None,
3324
name,
3425
rate_limit: None,

rust/src/models/application_out.rs

+14-22
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
1-
/*
2-
* Svix API
3-
*
4-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5-
*
6-
* The version of the OpenAPI document: 1.1.1
7-
*
8-
* Generated by: https://openapi-generator.tech
9-
*/
10-
11-
#[allow(unused_imports)]
12-
use crate::models;
13-
#[allow(unused_imports)]
1+
// this file is @generated
142
use serde::{Deserialize, Serialize};
153

16-
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
4+
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
175
pub struct ApplicationOut {
186
#[serde(rename = "createdAt")]
197
pub created_at: String,
8+
209
/// The app's ID
21-
#[serde(rename = "id")]
2210
pub id: String,
23-
#[serde(rename = "metadata")]
11+
2412
pub metadata: std::collections::HashMap<String, String>,
25-
#[serde(rename = "name")]
13+
2614
pub name: String,
27-
#[serde(rename = "rateLimit", skip_serializing_if = "Option::is_none")]
28-
pub rate_limit: Option<i32>,
15+
16+
#[serde(rename = "rateLimit")]
17+
#[serde(skip_serializing_if = "Option::is_none")]
18+
pub rate_limit: Option<u16>,
19+
2920
/// The app's UID
30-
#[serde(rename = "uid", skip_serializing_if = "Option::is_none")]
21+
#[serde(skip_serializing_if = "Option::is_none")]
3122
pub uid: Option<String>,
23+
3224
#[serde(rename = "updatedAt")]
3325
pub updated_at: String,
3426
}
@@ -40,8 +32,8 @@ impl ApplicationOut {
4032
metadata: std::collections::HashMap<String, String>,
4133
name: String,
4234
updated_at: String,
43-
) -> ApplicationOut {
44-
ApplicationOut {
35+
) -> Self {
36+
Self {
4537
created_at,
4638
id,
4739
metadata,

0 commit comments

Comments
 (0)