-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rust): add a xtask to generate the OpenAPI spec
- Loading branch information
Showing
14 changed files
with
179 additions
and
126 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
use utoipa::openapi::{ComponentsBuilder, OpenApi, OpenApiBuilder, PathsBuilder}; | ||
use utoipa::openapi::{Components, ComponentsBuilder, Paths, PathsBuilder}; | ||
|
||
use super::ApiDocBuilder; | ||
|
||
pub struct L10nApiDocBuilder; | ||
|
||
impl L10nApiDocBuilder { | ||
pub fn build() -> OpenApi { | ||
let paths = PathsBuilder::new() | ||
impl ApiDocBuilder for L10nApiDocBuilder { | ||
fn title(&self) -> String { | ||
"Localization HTTP API".to_string() | ||
} | ||
|
||
fn paths(&self) -> Paths { | ||
PathsBuilder::new() | ||
.path_from::<crate::l10n::web::__path_get_config>() | ||
.path_from::<crate::l10n::web::__path_keymaps>() | ||
.path_from::<crate::l10n::web::__path_locales>() | ||
.path_from::<crate::l10n::web::__path_set_config>() | ||
.path_from::<crate::l10n::web::__path_timezones>() | ||
.build(); | ||
.build() | ||
} | ||
|
||
let components = ComponentsBuilder::new() | ||
fn components(&self) -> Components { | ||
ComponentsBuilder::new() | ||
.schema_from::<agama_lib::localization::model::LocaleConfig>() | ||
.schema_from::<agama_locale_data::KeymapId>() | ||
.schema_from::<agama_locale_data::LocaleId>() | ||
.schema_from::<crate::l10n::Keymap>() | ||
.schema_from::<crate::l10n::LocaleEntry>() | ||
.schema_from::<crate::l10n::TimezoneEntry>() | ||
.build(); | ||
|
||
OpenApiBuilder::new() | ||
.paths(paths) | ||
.components(Some(components)) | ||
.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
use utoipa::openapi::{ComponentsBuilder, OpenApi, OpenApiBuilder, PathsBuilder}; | ||
use utoipa::openapi::{ComponentsBuilder, PathsBuilder}; | ||
|
||
use super::ApiDocBuilder; | ||
|
||
pub struct ManagerApiDocBuilder; | ||
|
||
impl ManagerApiDocBuilder { | ||
pub fn build() -> OpenApi { | ||
let paths = PathsBuilder::new() | ||
impl ApiDocBuilder for ManagerApiDocBuilder { | ||
fn title(&self) -> String { | ||
"Manager HTTP API".to_string() | ||
} | ||
|
||
fn paths(&self) -> utoipa::openapi::Paths { | ||
PathsBuilder::new() | ||
.path_from::<crate::manager::web::__path_finish_action>() | ||
.path_from::<crate::manager::web::__path_install_action>() | ||
.path_from::<crate::manager::web::__path_installer_status>() | ||
.path_from::<crate::manager::web::__path_probe_action>() | ||
.build(); | ||
.build() | ||
} | ||
|
||
let components = ComponentsBuilder::new() | ||
fn components(&self) -> utoipa::openapi::Components { | ||
ComponentsBuilder::new() | ||
.schema_from::<agama_lib::manager::InstallationPhase>() | ||
.schema_from::<crate::manager::web::InstallerStatus>() | ||
.build(); | ||
|
||
OpenApiBuilder::new() | ||
.paths(paths) | ||
.components(Some(components)) | ||
.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use utoipa::openapi::{Components, ComponentsBuilder, Paths, PathsBuilder}; | ||
|
||
use super::ApiDocBuilder; | ||
|
||
pub struct MiscApiDocBuilder; | ||
|
||
impl ApiDocBuilder for MiscApiDocBuilder { | ||
fn title(&self) -> String { | ||
"Miscelaneous HTTP API".to_string() | ||
} | ||
|
||
fn paths(&self) -> Paths { | ||
PathsBuilder::new() | ||
.path_from::<crate::web::http::__path_ping>() | ||
.build() | ||
} | ||
|
||
fn components(&self) -> Components { | ||
ComponentsBuilder::new() | ||
.schema_from::<crate::web::http::PingResponse>() | ||
.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
use utoipa::openapi::{ComponentsBuilder, OpenApi, OpenApiBuilder, PathsBuilder}; | ||
use utoipa::openapi::{Components, ComponentsBuilder, Paths, PathsBuilder}; | ||
|
||
use super::ApiDocBuilder; | ||
|
||
pub struct QuestionsApiDocBuilder; | ||
|
||
impl QuestionsApiDocBuilder { | ||
pub fn build() -> OpenApi { | ||
let paths = PathsBuilder::new() | ||
impl ApiDocBuilder for QuestionsApiDocBuilder { | ||
fn title(&self) -> String { | ||
"Questions HTTP API".to_string() | ||
} | ||
fn paths(&self) -> Paths { | ||
PathsBuilder::new() | ||
.path_from::<crate::questions::web::__path_answer_question>() | ||
.path_from::<crate::questions::web::__path_create_question>() | ||
.path_from::<crate::questions::web::__path_delete_question>() | ||
.path_from::<crate::questions::web::__path_get_answer>() | ||
.path_from::<crate::questions::web::__path_list_questions>() | ||
.build(); | ||
.build() | ||
} | ||
|
||
let components = ComponentsBuilder::new() | ||
fn components(&self) -> Components { | ||
ComponentsBuilder::new() | ||
.schema_from::<agama_lib::questions::model::Answer>() | ||
.schema_from::<agama_lib::questions::model::GenericAnswer>() | ||
.schema_from::<agama_lib::questions::model::GenericQuestion>() | ||
.schema_from::<agama_lib::questions::model::PasswordAnswer>() | ||
.schema_from::<agama_lib::questions::model::Question>() | ||
.schema_from::<agama_lib::questions::model::QuestionWithPassword>() | ||
.build(); | ||
|
||
OpenApiBuilder::new() | ||
.paths(paths) | ||
.components(Some(components)) | ||
.build() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.