Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,7 @@ use crate::{models, types::*};

{{#operations}}

{{#basicAuthorization}}
/// {{classnamePascalCase}} APIs - Authorization.
#[async_trait]
#[allow(clippy::ptr_arg)]
pub trait {{classnamePascalCase}}Authorization {
type Claims;

{{#operation}}
{{#vendorExtensions}}
{{#x-has-auth-methods}}
{{#basicAuthorization}}
{{#vendorExtensions}}
/// Authorization{{#summary}} - {{{.}}}{{/summary}}.
/// {{{operationId}}} - {{{httpMethod}}} {{{basePathWithoutHost}}}{{{path}}}
async fn {{{x-operation-id}}}_authorize(
&self,
method: &Method,
host: &Host,
cookies: &CookieJar,
claims: &Self::Claims,
{{#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<super::Authorization, ()> {
Ok(super::Authorization::Authorized)
}
{{/vendorExtensions}}
{{/basicAuthorization}}
{{/x-has-auth-methods}}
{{/vendorExtensions}}
{{^-last}}

{{/-last}}
{{/operation}}
}
{{/basicAuthorization}}
{{>authorization}}

/// {{classnamePascalCase}}
#[async_trait]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{#basicAuthorization}}
/// {{classnamePascalCase}} APIs - Authorization.
#[async_trait]
#[allow(clippy::ptr_arg)]
pub trait {{classnamePascalCase}}Authorization {
type Claims;

{{#operation}}
{{#vendorExtensions}}
{{#x-has-auth-methods}}
{{#basicAuthorization}}
{{#vendorExtensions}}
/// Authorization{{#summary}} - {{{.}}}{{/summary}}.
/// {{{operationId}}} - {{{httpMethod}}} {{{basePathWithoutHost}}}{{{path}}}
async fn {{{x-operation-id}}}_authorize(
&self,
method: &Method,
host: &Host,
cookies: &CookieJar,
claims: &Self::Claims,
{{#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<super::Authorization, ()> {
Ok(super::Authorization::Authorized)
}
{{/vendorExtensions}}
{{/basicAuthorization}}
{{/x-has-auth-methods}}
{{/vendorExtensions}}
{{^-last}}

{{/-last}}
{{/operation}}
}
{{/basicAuthorization}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.15.0-SNAPSHOT
7.16.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ server, you can easily generate a server stub.
To see how to make this your own, look here: [README]((https://openapi-generator.tech))

- API version: 1.0.0
- Generator version: 7.15.0-SNAPSHOT
- Generator version: 7.16.0-SNAPSHOT



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl std::str::FromStr for Amount {
None => {
return std::result::Result::Err(
"Missing value while parsing Amount".to_string(),
)
);
}
};

Expand All @@ -153,7 +153,7 @@ impl std::str::FromStr for Amount {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Amount".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl std::str::FromStr for CheckoutError {
None => {
return std::result::Result::Err(
"Missing value while parsing CheckoutError".to_string(),
)
);
}
};

Expand All @@ -306,7 +306,7 @@ impl std::str::FromStr for CheckoutError {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing CheckoutError".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ impl std::str::FromStr for Payment {
None => {
return std::result::Result::Err(
"Missing value while parsing Payment".to_string(),
)
);
}
};

Expand Down Expand Up @@ -506,7 +506,7 @@ impl std::str::FromStr for Payment {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Payment".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ impl std::str::FromStr for PaymentMethod {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentMethod".to_string(),
)
);
}
};

Expand All @@ -674,7 +674,7 @@ impl std::str::FromStr for PaymentMethod {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentMethod".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -805,7 +805,7 @@ impl std::str::FromStr for PaymentResult {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentResult".to_string(),
)
);
}
};

Expand All @@ -823,7 +823,7 @@ impl std::str::FromStr for PaymentResult {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentResult".to_string(),
)
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use axum::{body::Body, extract::*, response::Response, routing::*};
use axum_extra::extract::{CookieJar, Host, Query as QueryExtra};
use bytes::Bytes;
use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode};
use http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, header::CONTENT_TYPE};
use tracing::error;
use validator::{Validate, ValidationErrors};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{mem, str::FromStr};

use base64::{engine::general_purpose, Engine};
use base64::{Engine, engine::general_purpose};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.15.0-SNAPSHOT
7.16.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ server, you can easily generate a server stub.
To see how to make this your own, look here: [README]((https://openapi-generator.tech))

- API version: 1.0.0
- Generator version: 7.15.0-SNAPSHOT
- Generator version: 7.16.0-SNAPSHOT



Expand Down
20 changes: 10 additions & 10 deletions samples/server/petstore/rust-axum/output/apikey-auths/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl std::str::FromStr for Amount {
None => {
return std::result::Result::Err(
"Missing value while parsing Amount".to_string(),
)
);
}
};

Expand All @@ -153,7 +153,7 @@ impl std::str::FromStr for Amount {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Amount".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ impl std::str::FromStr for CheckoutError {
None => {
return std::result::Result::Err(
"Missing value while parsing CheckoutError".to_string(),
)
);
}
};

Expand All @@ -306,7 +306,7 @@ impl std::str::FromStr for CheckoutError {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing CheckoutError".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ impl std::str::FromStr for Payment {
None => {
return std::result::Result::Err(
"Missing value while parsing Payment".to_string(),
)
);
}
};

Expand Down Expand Up @@ -506,7 +506,7 @@ impl std::str::FromStr for Payment {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing Payment".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ impl std::str::FromStr for PaymentMethod {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentMethod".to_string(),
)
);
}
};

Expand All @@ -674,7 +674,7 @@ impl std::str::FromStr for PaymentMethod {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentMethod".to_string(),
)
);
}
}
}
Expand Down Expand Up @@ -805,7 +805,7 @@ impl std::str::FromStr for PaymentResult {
None => {
return std::result::Result::Err(
"Missing value while parsing PaymentResult".to_string(),
)
);
}
};

Expand All @@ -823,7 +823,7 @@ impl std::str::FromStr for PaymentResult {
_ => {
return std::result::Result::Err(
"Unexpected key while parsing PaymentResult".to_string(),
)
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use axum::{body::Body, extract::*, response::Response, routing::*};
use axum_extra::extract::{CookieJar, Host, Query as QueryExtra};
use bytes::Bytes;
use http::{header::CONTENT_TYPE, HeaderMap, HeaderName, HeaderValue, Method, StatusCode};
use http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, header::CONTENT_TYPE};
use tracing::error;
use validator::{Validate, ValidationErrors};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{mem, str::FromStr};

use base64::{engine::general_purpose, Engine};
use base64::{Engine, engine::general_purpose};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.15.0-SNAPSHOT
7.16.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ server, you can easily generate a server stub.
To see how to make this your own, look here: [README]((https://openapi-generator.tech))

- API version: 1.0.7
- Generator version: 7.15.0-SNAPSHOT
- Generator version: 7.16.0-SNAPSHOT



Expand Down
Loading
Loading