Skip to content

Commit 1bfeb9b

Browse files
authored
Fix OpenAPI for api-v2 (#2864)
## Problem The OpenAPI specification is missing some types that implement the `ToSchema` trait due to name conflicts. ## Solution Qualify the names so they do not conflict anymore and all of them are included in the output. ## Testing - Tested manually
2 parents d50d1ca + 94e8cd7 commit 1bfeb9b

File tree

25 files changed

+67
-4
lines changed

25 files changed

+67
-4
lines changed

rust/agama-server/src/web/docs/config.rs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,33 @@ impl ApiDocBuilder for ConfigApiDocBuilder {
9191
.schema_from::<agama_network::types::SSID>()
9292
.schema_from::<agama_network::types::Status>()
9393
.schema_from::<agama_network::types::LinkLocal>()
94+
.schema_from::<agama_utils::api::software::Config>()
9495
.schema_from::<agama_utils::api::software::AddonConfig>()
9596
.schema_from::<agama_utils::api::software::ProductConfig>()
97+
.schema_from::<agama_utils::api::software::SoftwareProposal>()
98+
.schema_from::<agama_utils::api::software::SelectedBy>()
99+
.schema_from::<agama_utils::api::software::Pattern>()
100+
.schema_from::<agama_utils::api::software::Repository>()
101+
.schema_from::<agama_utils::api::software::RegistrationInfo>()
102+
.schema_from::<agama_utils::api::software::AddonInfo>()
103+
.schema_from::<agama_utils::api::software::AddonRegistration>()
96104
.schema_from::<agama_utils::api::files::BaseScript>()
97105
.schema_from::<agama_utils::api::files::InitScript>()
98106
.schema_from::<agama_utils::api::files::PostPartitioningScript>()
99107
.schema_from::<agama_utils::api::files::PostScript>()
100108
.schema_from::<agama_utils::api::files::PreScript>()
101109
.schema_from::<agama_utils::api::files::Script>()
102110
.schema_from::<agama_utils::api::files::ScriptsConfig>()
111+
.schema_from::<agama_utils::api::files::Config>()
103112
.schema_from::<agama_utils::api::software::PatternsMap>()
104113
.schema_from::<agama_utils::api::software::PatternsConfig>()
105114
.schema_from::<agama_utils::api::software::SoftwareConfig>()
106115
.schema_from::<agama_utils::api::manager::LanguageTag>()
107116
.schema_from::<agama_utils::api::manager::License>()
108117
.schema_from::<agama_utils::api::manager::LicenseContent>()
118+
.schema_from::<agama_utils::api::manager::Product>()
119+
.schema_from::<agama_utils::api::manager::ProductMode>()
120+
.schema_from::<agama_utils::api::manager::HardwareInfo>()
109121
.schema_from::<agama_locale_data::KeymapId>()
110122
.schema_from::<agama_locale_data::LocaleId>()
111123
.schema_from::<agama_locale_data::TimezoneId>()
@@ -117,16 +129,39 @@ impl ApiDocBuilder for ConfigApiDocBuilder {
117129
.schema_from::<agama_utils::api::Patch>()
118130
.schema_from::<agama_utils::api::Progress>()
119131
.schema_from::<agama_utils::api::Proposal>()
132+
.schema_from::<agama_utils::api::hostname::Proposal>()
133+
.schema_from::<agama_utils::api::network::Proposal>()
134+
.schema_from::<agama_utils::api::software::Proposal>()
135+
.schema_from::<agama_utils::api::l10n::Proposal>()
120136
.schema_from::<agama_utils::api::Scope>()
121137
.schema_from::<agama_utils::api::Status>()
122138
.schema_from::<agama_utils::api::SystemInfo>()
139+
.schema_from::<agama_utils::api::manager::SystemInfo>()
140+
.schema_from::<agama_utils::api::hostname::SystemInfo>()
141+
.schema_from::<agama_utils::api::l10n::SystemInfo>()
142+
.schema_from::<agama_utils::api::software::SystemInfo>()
143+
.schema_from::<agama_utils::api::network::SystemInfo>()
144+
.schema_from::<agama_utils::api::s390::SystemInfo>()
145+
.schema_from::<agama_utils::api::bootloader::Config>()
146+
.schema_from::<agama_utils::api::hostname::Config>()
147+
.schema_from::<agama_utils::api::proxy::Config>()
148+
.schema_from::<agama_utils::api::security::Config>()
149+
.schema_from::<agama_utils::api::security::SSLFingerprint>()
150+
.schema_from::<agama_utils::api::security::SSLFingerprintAlgorithm>()
151+
.schema_from::<agama_utils::api::network::Config>()
152+
.schema_from::<agama_utils::api::iscsi::Config>()
153+
.schema_from::<agama_utils::api::users::Config>()
154+
.schema_from::<agama_utils::api::users::config::FirstUserConfig>()
155+
.schema_from::<agama_utils::api::users::config::RootUserConfig>()
156+
.schema_from::<agama_utils::api::users::config::UserPassword>()
157+
.schema_from::<agama_utils::api::s390::Config>()
158+
.schema_from::<agama_utils::api::RawConfig>()
123159
.schema_from::<agama_utils::api::l10n::Config>()
124160
.schema_from::<agama_utils::api::l10n::Keymap>()
125161
.schema_from::<agama_utils::api::l10n::LocaleEntry>()
126-
.schema_from::<agama_utils::api::l10n::Proposal>()
127162
.schema_from::<agama_utils::api::l10n::SystemConfig>()
128-
.schema_from::<agama_utils::api::l10n::SystemInfo>()
129163
.schema_from::<agama_utils::api::l10n::TimezoneEntry>()
164+
.schema_from::<agama_utils::api::l10n::Translations>()
130165
.schema_from::<agama_utils::api::network::AccessPoint>()
131166
.schema_from::<agama_utils::api::network::Device>()
132167
.schema_from::<agama_utils::api::network::Dhcp4Settings>()
@@ -146,8 +181,6 @@ impl ApiDocBuilder for ConfigApiDocBuilder {
146181
.schema_from::<agama_utils::api::network::NetworkConnection>()
147182
.schema_from::<agama_utils::api::network::NetworkConnectionWithState>()
148183
.schema_from::<agama_utils::api::network::NetworkConnectionsCollection>()
149-
.schema_from::<agama_utils::api::network::NetworkSettings>()
150-
.schema_from::<agama_utils::api::network::NetworkSettings>()
151184
.schema_from::<agama_utils::api::network::StateSettings>()
152185
.schema_from::<agama_utils::api::network::VlanSettings>()
153186
.schema_from::<agama_utils::api::network::WirelessSettings>()
@@ -160,6 +193,7 @@ impl ApiDocBuilder for ConfigApiDocBuilder {
160193
.schema_from::<agama_utils::api::question::QuestionSpec>()
161194
.schema_from::<agama_utils::api::question::SelectionOption>()
162195
.schema_from::<agama_utils::api::question::UpdateQuestion>()
196+
.schema_from::<agama_utils::api::storage::Config>()
163197
.schema_from::<agama_utils::api::software::RepositoryConfig>()
164198
.schema_from::<agama_utils::api::status::Stage>()
165199
.schema_from::<agama_utils::api::query::SolveStorageModel>()

rust/agama-utils/src/api/bootloader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use serde::{Deserialize, Serialize};
2626
#[derive(Clone, Debug, Serialize, Deserialize, Default, Merge, utoipa::ToSchema)]
2727
#[serde(rename_all = "camelCase")]
2828
#[merge(strategy = merge::option::overwrite_none)]
29+
#[schema(as = bootloader::Config)]
2930
pub struct Config {
3031
/// Whether bootloader should stop on boot menu.
3132
#[serde(skip_serializing_if = "Option::is_none")]

rust/agama-utils/src/api/files/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::api::files::{
2929
};
3030

3131
#[derive(Clone, Debug, Default, Serialize, Deserialize, Merge, utoipa::ToSchema)]
32+
#[schema(as = files::Config)]
3233
pub struct Config {
3334
#[serde(skip_serializing_if = "Option::is_none")]
3435
#[merge(strategy = merge::option::overwrite_none)]

rust/agama-utils/src/api/hostname/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use serde::{Deserialize, Serialize};
2424
/// Hostname config.
2525
#[derive(Clone, Debug, Default, Merge, Serialize, Deserialize, PartialEq, utoipa::ToSchema)]
2626
#[serde(rename_all = "camelCase")]
27+
#[schema(as = hostname::Config)]
2728
pub struct Config {
2829
#[serde(skip_serializing_if = "Option::is_none")]
2930
#[merge(strategy = merge::option::overwrite_none)]

rust/agama-utils/src/api/hostname/proposal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use serde::{Deserialize, Serialize};
2222

2323
/// Describes what Agama proposes for the target system.
2424
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
25+
#[schema(as = hostname::Proposal)]
2526
pub struct Proposal {
2627
#[serde(skip_serializing_if = "Option::is_none")]
2728
pub r#static: Option<String>,

rust/agama-utils/src/api/hostname/system_info.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use serde::{Deserialize, Serialize};
2222

2323
/// Describes the current system hostname information
2424
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, utoipa::ToSchema)]
25+
#[schema(as = hostname::SystemInfo)]
2526
pub struct SystemInfo {
2627
#[serde(skip_serializing_if = "Option::is_none")]
2728
pub r#static: Option<String>,

rust/agama-utils/src/api/iscsi/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use serde_json::Value;
2424

2525
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, utoipa::ToSchema)]
2626
#[serde(transparent)]
27+
#[schema(as = iscsi::Config)]
2728
pub struct Config(pub Value);
2829

2930
impl Merge for Config {

rust/agama-utils/src/api/l10n/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use serde::{Deserialize, Serialize};
2424
/// Localization config.
2525
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Merge, utoipa::ToSchema)]
2626
#[serde(rename_all = "camelCase")]
27+
#[schema(as = l10n::Config)]
2728
pub struct Config {
2829
/// Locale (e.g., "en_US.UTF-8").
2930
#[serde(skip_serializing_if = "Option::is_none")]

rust/agama-utils/src/api/l10n/proposal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use serde_with::{serde_as, DisplayFromStr};
2525
/// Describes what Agama proposes for the target system.
2626
#[serde_as]
2727
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
28+
#[schema(as = l10n::Proposal)]
2829
pub struct Proposal {
2930
/// Keymap (e.g., "us", "cz(qwerty)", etc.).
3031
#[serde_as(as = "DisplayFromStr")]

rust/agama-utils/src/api/l10n/system_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use serde::{Deserialize, Serialize};
2222

2323
#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
24+
#[schema(as = l10n::SystemConfig)]
2425
pub struct SystemConfig {
2526
pub locale: Option<String>,
2627
pub keymap: Option<String>,

0 commit comments

Comments
 (0)