-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rust-axum] Split up api trait per tag (#18621)
* [rust-axum] Feat: split up api trait per tag * [rust-axum] Fix: missing types in api files * [rust-axum] Fix: add samples output * [rust-axum] Feat: handle mutli tagged operations * [rust-axum] Fix: spacing between generated operations * [rust-axum] Fix: coding standards
- Loading branch information
1 parent
57dceae
commit e9f961e
Showing
62 changed files
with
3,285 additions
and
3,131 deletions.
There are no files selected for viewing
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
6 changes: 6 additions & 0 deletions
6
modules/openapi-generator/src/main/resources/rust-axum/apis-mod.mustache
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,6 @@ | ||
{{#apiInfo}} | ||
{{#apis}} | ||
pub mod {{classFilename}}; | ||
{{/apis}} | ||
{{/apiInfo}} | ||
|
74 changes: 74 additions & 0 deletions
74
modules/openapi-generator/src/main/resources/rust-axum/apis.mustache
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,74 @@ | ||
use async_trait::async_trait; | ||
use axum::extract::*; | ||
use axum_extra::extract::{CookieJar, Multipart}; | ||
use bytes::Bytes; | ||
use http::Method; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::{models, types::*}; | ||
|
||
{{#operations}} | ||
{{#operation}} | ||
{{>response}} | ||
{{/operation}} | ||
{{/operations}} | ||
|
||
{{#operations}} | ||
/// {{classnamePascalCase}} | ||
#[async_trait] | ||
#[allow(clippy::ptr_arg)] | ||
pub trait {{classnamePascalCase}} { | ||
{{#operation}} | ||
{{#summary}} | ||
/// {{{.}}}. | ||
/// | ||
{{/summary}} | ||
{{#vendorExtensions}} | ||
/// {{{operationId}}} - {{{httpMethod}}} {{{basePathWithoutHost}}}{{{path}}} | ||
async fn {{{x-operation-id}}}( | ||
&self, | ||
method: Method, | ||
host: Host, | ||
cookies: CookieJar, | ||
{{#headerParams.size}} | ||
header_params: models::{{{operationIdCamelCase}}}HeaderParams, | ||
{{/headerParams.size}} | ||
{{#pathParams.size}} | ||
path_params: models::{{{operationIdCamelCase}}}PathParams, | ||
{{/pathParams.size}} | ||
{{#queryParams.size}} | ||
query_params: models::{{{operationIdCamelCase}}}QueryParams, | ||
{{/queryParams.size}} | ||
{{^x-consumes-multipart-related}} | ||
{{^x-consumes-multipart}} | ||
{{#bodyParam}} | ||
{{#vendorExtensions}} | ||
{{^x-consumes-plain-text}} | ||
body: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}}, | ||
{{/x-consumes-plain-text}} | ||
{{#x-consumes-plain-text}} | ||
{{#isString}} | ||
body: String, | ||
{{/isString}} | ||
{{^isString}} | ||
body: Bytes, | ||
{{/isString}} | ||
{{/x-consumes-plain-text}} | ||
{{/vendorExtensions}} | ||
{{/bodyParam}} | ||
{{/x-consumes-multipart}} | ||
{{/x-consumes-multipart-related}} | ||
{{#x-consumes-multipart}} | ||
body: Multipart, | ||
{{/x-consumes-multipart}} | ||
{{#x-consumes-multipart-related}} | ||
body: axum::body::Body, | ||
{{/x-consumes-multipart-related}} | ||
) -> Result<{{{operationId}}}Response, String>; | ||
{{/vendorExtensions}} | ||
{{^-last}} | ||
|
||
{{/-last}} | ||
{{/operation}} | ||
} | ||
{{/operations}} |
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
3 changes: 0 additions & 3 deletions
3
modules/openapi-generator/src/main/resources/rust-axum/server-mod.mustache
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
2 changes: 2 additions & 0 deletions
2
samples/server/petstore/rust-axum/output/multipart-v3/.openapi-generator/FILES
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,6 +1,8 @@ | ||
.gitignore | ||
Cargo.toml | ||
README.md | ||
src/apis/default.rs | ||
src/apis/mod.rs | ||
src/header.rs | ||
src/lib.rs | ||
src/models.rs | ||
|
64 changes: 64 additions & 0 deletions
64
samples/server/petstore/rust-axum/output/multipart-v3/src/apis/default.rs
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,64 @@ | ||
use async_trait::async_trait; | ||
use axum::extract::*; | ||
use axum_extra::extract::{CookieJar, Multipart}; | ||
use bytes::Bytes; | ||
use http::Method; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::{models, types::*}; | ||
|
||
#[derive(Debug, PartialEq, Serialize, Deserialize)] | ||
#[must_use] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum MultipartRelatedRequestPostResponse { | ||
/// OK | ||
Status201_OK, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Serialize, Deserialize)] | ||
#[must_use] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum MultipartRequestPostResponse { | ||
/// OK | ||
Status201_OK, | ||
} | ||
|
||
#[derive(Debug, PartialEq, Serialize, Deserialize)] | ||
#[must_use] | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum MultipleIdenticalMimeTypesPostResponse { | ||
/// OK | ||
Status200_OK, | ||
} | ||
|
||
/// Default | ||
#[async_trait] | ||
#[allow(clippy::ptr_arg)] | ||
pub trait Default { | ||
/// MultipartRelatedRequestPost - POST /multipart_related_request | ||
async fn multipart_related_request_post( | ||
&self, | ||
method: Method, | ||
host: Host, | ||
cookies: CookieJar, | ||
body: axum::body::Body, | ||
) -> Result<MultipartRelatedRequestPostResponse, String>; | ||
|
||
/// MultipartRequestPost - POST /multipart_request | ||
async fn multipart_request_post( | ||
&self, | ||
method: Method, | ||
host: Host, | ||
cookies: CookieJar, | ||
body: Multipart, | ||
) -> Result<MultipartRequestPostResponse, String>; | ||
|
||
/// MultipleIdenticalMimeTypesPost - POST /multiple-identical-mime-types | ||
async fn multiple_identical_mime_types_post( | ||
&self, | ||
method: Method, | ||
host: Host, | ||
cookies: CookieJar, | ||
body: axum::body::Body, | ||
) -> Result<MultipleIdenticalMimeTypesPostResponse, String>; | ||
} |
1 change: 1 addition & 0 deletions
1
samples/server/petstore/rust-axum/output/multipart-v3/src/apis/mod.rs
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 @@ | ||
pub mod default; |
Oops, something went wrong.