Skip to content

Commit

Permalink
Replace OpenAPI generator with openapi-codegen for model generation
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte committed Jan 16, 2025
1 parent e22b79e commit ecfe6d8
Show file tree
Hide file tree
Showing 192 changed files with 1,133 additions and 7,112 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
* Libs/Rust **(Breaking)**: Add optional `EventTypeDeleteOptions` parameter to `EventType::delete`
* Libs/Rust **(Breaking)**: Add optional `PostOptions` parameter to `Endpoint::recover`,
`Endpoint::rotate_secret`, `Integration::rotate_key` and `MessageAttempt::resend`
* Libs/Rust **(Breaking)**: Remove model files that were not referenced by any operations available
through the `Svix` object
* Libs/Rust **(Breaking)**: Switch `Patch` struct fields from `Option<Option<T>>` to
`js_option::JsOption<T>`
* Libs/Rust **(Breaking)**: Change `rate_limit` from `i32` to `u16` in several places
* Libs/Rust **(Breaking)**: Remove `settings` parameter from `EnvironmentIn::new`
* Libs/Go **(Breaking)**: Rename `Statistics.AggregateAppStats` to `AggregateAppStatsWithOptions`;
the old name is used for a version of the method without the `PostOptions`, like elsewhere
* Libs/Go: Add `Authentication.ExpireAll` (and `ExpireAllWithOptions`)
Expand Down
5 changes: 0 additions & 5 deletions regen_openapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,5 @@ yarn openapi-generator-cli generate -i .codegen-tmp/openapi.json -g ruby -o ruby

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

# Cleanup previous codegen, allowing us to spot removals.
# If the removals are expected, stage them eg. `git add -u`, then commit them.
rm -rf rust/src/models
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

rm -rf .codegen-tmp
echo Note: Python generation is not executed automatically.
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ thiserror = "1.0.30"
time = "0.3"
url = "2.2"
tokio = { version = "1.41.0", features = ["time"] }
serde_with = { version = "^3.8", default-features = false, features = ["base64", "std", "macros"] }
itertools = "0.14.0"
js_option = "0.1.1"

[dev-dependencies]
tokio = { version = "1.41.0", features = ["macros"] }
Expand Down
1 change: 0 additions & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use hyper_util::client::legacy::{connect::HttpConnector, Client as HyperClient};
pub mod api;
pub mod error;
mod model_ext;
#[allow(clippy::all)]
mod models;
mod request;
pub mod webhooks;
Expand Down
37 changes: 12 additions & 25 deletions rust/src/models/aggregate_event_types_out.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
/*
* Svix API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
*
* Generated by: https://openapi-generator.tech
*/

#[allow(unused_imports)]
use crate::models;
#[allow(unused_imports)]
// this file is @generated
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
use super::{
background_task_status::BackgroundTaskStatus, background_task_type::BackgroundTaskType,
};

#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct AggregateEventTypesOut {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "status")]
pub status: models::BackgroundTaskStatus,
#[serde(rename = "task")]
pub task: models::BackgroundTaskType,

pub status: BackgroundTaskStatus,

pub task: BackgroundTaskType,
}

impl AggregateEventTypesOut {
pub fn new(
id: String,
status: models::BackgroundTaskStatus,
task: models::BackgroundTaskType,
) -> AggregateEventTypesOut {
AggregateEventTypesOut { id, status, task }
pub fn new(id: String, status: BackgroundTaskStatus, task: BackgroundTaskType) -> Self {
Self { id, status, task }
}
}
45 changes: 22 additions & 23 deletions rust/src/models/app_portal_access_in.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
/*
* Svix API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
*
* Generated by: https://openapi-generator.tech
*/

#[allow(unused_imports)]
use crate::models;
#[allow(unused_imports)]
// this file is @generated
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
use super::application_in::ApplicationIn;

#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct AppPortalAccessIn {
#[serde(rename = "application", skip_serializing_if = "Option::is_none")]
pub application: Option<Box<models::ApplicationIn>>,
/// How long the token will be valid for, in seconds. Valid values are
/// between 1 hour and 7 days. The default is 7 days.
#[serde(rename = "expiry", skip_serializing_if = "Option::is_none")]
/// Optionally creates a new application while generating the access link.
/// If the application id or uid that is used in the path already exists,
/// this argument is ignored.
#[serde(skip_serializing_if = "Option::is_none")]
pub application: Option<ApplicationIn>,

/// How long the token will be valid for, in seconds.
///
/// Valid values are between 1 hour and 7 days. The default is 7 days.
#[serde(skip_serializing_if = "Option::is_none")]
pub expiry: Option<i32>,

/// The set of feature flags the created token will have access to.
#[serde(rename = "featureFlags", skip_serializing_if = "Option::is_none")]
#[serde(rename = "featureFlags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub feature_flags: Option<Vec<String>>,

/// Whether the app portal should be in read-only mode.
#[serde(rename = "readOnly", skip_serializing_if = "Option::is_none")]
#[serde(rename = "readOnly")]
#[serde(skip_serializing_if = "Option::is_none")]
pub read_only: Option<bool>,
}

impl AppPortalAccessIn {
pub fn new() -> AppPortalAccessIn {
AppPortalAccessIn {
pub fn new() -> Self {
Self {
application: None,
expiry: None,
feature_flags: None,
Expand Down
23 changes: 5 additions & 18 deletions rust/src/models/app_portal_access_out.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
/*
* Svix API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
*
* Generated by: https://openapi-generator.tech
*/

#[allow(unused_imports)]
use crate::models;
#[allow(unused_imports)]
// this file is @generated
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct AppPortalAccessOut {
#[serde(rename = "token")]
pub token: String,
#[serde(rename = "url")]

pub url: String,
}

impl AppPortalAccessOut {
pub fn new(token: String, url: String) -> AppPortalAccessOut {
AppPortalAccessOut { token, url }
pub fn new(token: String, url: String) -> Self {
Self { token, url }
}
}
33 changes: 12 additions & 21 deletions rust/src/models/app_usage_stats_in.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
/*
* Svix API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
*
* Generated by: https://openapi-generator.tech
*/

#[allow(unused_imports)]
use crate::models;
#[allow(unused_imports)]
// this file is @generated
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct AppUsageStatsIn {
/// Specific app IDs or UIDs to aggregate stats for. Note that if none of
/// the given IDs or UIDs are resolved, a 422 response will be given.
#[serde(rename = "appIds", skip_serializing_if = "Option::is_none")]
/// Specific app IDs or UIDs to aggregate stats for.
///
/// Note that if none of the given IDs or UIDs are resolved, a 422 response
/// will be given.
#[serde(rename = "appIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_ids: Option<Vec<String>>,
#[serde(rename = "since")]

pub since: String,
#[serde(rename = "until")]

pub until: String,
}

impl AppUsageStatsIn {
pub fn new(since: String, until: String) -> AppUsageStatsIn {
AppUsageStatsIn {
pub fn new(since: String, until: String) -> Self {
Self {
app_ids: None,
since,
until,
Expand Down
43 changes: 18 additions & 25 deletions rust/src/models/app_usage_stats_out.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
/*
* Svix API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
*
* Generated by: https://openapi-generator.tech
*/

#[allow(unused_imports)]
use crate::models;
#[allow(unused_imports)]
// this file is @generated
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
use super::{
background_task_status::BackgroundTaskStatus, background_task_type::BackgroundTaskType,
};

#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct AppUsageStatsOut {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "status")]
pub status: models::BackgroundTaskStatus,
#[serde(rename = "task")]
pub task: models::BackgroundTaskType,
/// Any app IDs or UIDs received in the request that weren't found. Stats
/// will be produced for all the others.

pub status: BackgroundTaskStatus,

pub task: BackgroundTaskType,

/// Any app IDs or UIDs received in the request that weren't found.
///
/// Stats will be produced for all the others.
#[serde(rename = "unresolvedAppIds")]
pub unresolved_app_ids: Vec<String>,
}

impl AppUsageStatsOut {
pub fn new(
id: String,
status: models::BackgroundTaskStatus,
task: models::BackgroundTaskType,
status: BackgroundTaskStatus,
task: BackgroundTaskType,
unresolved_app_ids: Vec<String>,
) -> AppUsageStatsOut {
AppUsageStatsOut {
) -> Self {
Self {
id,
status,
task,
Expand Down
33 changes: 12 additions & 21 deletions rust/src/models/application_in.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
/*
* Svix API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
*
* Generated by: https://openapi-generator.tech
*/

#[allow(unused_imports)]
use crate::models;
#[allow(unused_imports)]
// this file is @generated
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct ApplicationIn {
#[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<std::collections::HashMap<String, String>>,
#[serde(rename = "name")]

pub name: String,
#[serde(rename = "rateLimit", skip_serializing_if = "Option::is_none")]
pub rate_limit: Option<i32>,

#[serde(rename = "rateLimit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rate_limit: Option<u16>,

/// Optional unique identifier for the application.
#[serde(rename = "uid", skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uid: Option<String>,
}

impl ApplicationIn {
pub fn new(name: String) -> ApplicationIn {
ApplicationIn {
pub fn new(name: String) -> Self {
Self {
metadata: None,
name,
rate_limit: None,
Expand Down
36 changes: 14 additions & 22 deletions rust/src/models/application_out.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
/*
* Svix API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
*
* Generated by: https://openapi-generator.tech
*/

#[allow(unused_imports)]
use crate::models;
#[allow(unused_imports)]
// this file is @generated
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct ApplicationOut {
#[serde(rename = "createdAt")]
pub created_at: String,

/// The app's ID
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "metadata")]

pub metadata: std::collections::HashMap<String, String>,
#[serde(rename = "name")]

pub name: String,
#[serde(rename = "rateLimit", skip_serializing_if = "Option::is_none")]
pub rate_limit: Option<i32>,

#[serde(rename = "rateLimit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rate_limit: Option<u16>,

/// The app's UID
#[serde(rename = "uid", skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uid: Option<String>,

#[serde(rename = "updatedAt")]
pub updated_at: String,
}
Expand All @@ -40,8 +32,8 @@ impl ApplicationOut {
metadata: std::collections::HashMap<String, String>,
name: String,
updated_at: String,
) -> ApplicationOut {
ApplicationOut {
) -> Self {
Self {
created_at,
id,
metadata,
Expand Down
Loading

0 comments on commit ecfe6d8

Please sign in to comment.