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
5 changes: 4 additions & 1 deletion .github/workflows/samples-rust-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ jobs:

- name: Build
working-directory: ${{ matrix.sample }}
run: cargo build --all-targets --all-features
run: |
set -e
cargo build --all-targets --all-features
cargo build --all-targets --no-default-features
- name: Tests
working-directory: ${{ matrix.sample }}
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,10 @@ public CodegenModel fromModel(String name, Schema model) {
additionalProperties.put("apiUsesUuid", true);
}

if (prop.isByteArray) {
additionalProperties.put("apiUsesByteArray", true);
}

String xmlName = modelXmlNames.get(prop.dataType);
if (xmlName != null) {
prop.vendorExtensions.put("x-item-xml-name", xmlName);
Expand Down Expand Up @@ -1535,6 +1539,11 @@ private void processParam(CodegenParameter param, CodegenOperation op) {
additionalProperties.put("apiUsesUuid", true);
}

// If a parameter uses byte arrays, we need to set a flag.
if (param.isByteArray) {
additionalProperties.put("apiUsesByteArray", true);
}

if (Boolean.TRUE.equals(param.isFreeFormObject)) {
param.vendorExtensions.put("x-format-string", "{:?}");
example = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,10 @@ public CodegenModel fromModel(String name, Schema model) {
additionalProperties.put("apiUsesUuid", true);
}

if (prop.isByteArray) {
additionalProperties.put("apiUsesByteArray", true);
}

String xmlName = modelXmlNames.get(prop.dataType);
if (xmlName != null) {
prop.vendorExtensions.put("x-item-xml-name", xmlName);
Expand Down Expand Up @@ -1515,6 +1519,11 @@ private void processParam(CodegenParameter param, CodegenOperation op) {
additionalProperties.put("apiUsesUuid", true);
}

// If a parameter uses byte arrays, we need to set a flag.
if (param.isByteArray) {
additionalProperties.put("apiUsesByteArray", true);
}

if (Boolean.TRUE.equals(param.isFreeFormObject)) {
param.vendorExtensions.put("x-format-string", "{:?}");
example = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ client = [
"serde_urlencoded",
{{/usesUrlEncodedForm}}
{{#hasCallbacks}}
"serde_ignored", "regex", "percent-encoding", "lazy_static",
"serde_ignored", "percent-encoding", {{^apiUsesByteArray}}"lazy_static", "regex",{{/apiUsesByteArray}}
{{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list below }}
"hyper", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
Expand All @@ -66,7 +66,7 @@ server = [
"native-tls", "hyper-openssl", "hyper-tls", "openssl",
{{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list above }}
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
"serde_ignored", "hyper", "percent-encoding", "url" {{^apiUsesByteArray}},"lazy_static", "regex"{{/apiUsesByteArray}}
]
cli = [
{{#apiHasDeleteMethods}}
Expand Down Expand Up @@ -96,6 +96,10 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
{{#apiUsesByteArray}}
lazy_static = "1.5"
regex = "1.12"
{{/apiUsesByteArray}}

# Crates included if required by the API definition
{{#usesXml}}
Expand Down Expand Up @@ -126,9 +130,11 @@ serde_urlencoded = {version = "0.6.1", optional = true}
{{/usesUrlEncodedForm}}

# Server, and client callback-specific
{{^apiUsesByteArray}}
lazy_static = { version = "1.4", optional = true }
percent-encoding = {version = "2.1.0", optional = true}
regex = {version = "1.3", optional = true}
{{/apiUsesByteArray}}
percent-encoding = {version = "2.1.0", optional = true}

# CLI-specific
anyhow = { version = "1", optional = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::BTreeSet;
use crate::server::Authorization;
use serde::{Deserialize, Serialize};
use swagger::{ApiError, auth::{Basic, Bearer}};
use swagger::{ApiError, auth::{Basic, Bearer, Authorization}};

#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
Expand All @@ -24,7 +23,7 @@ pub trait AuthenticationApi {

/// Method should be implemented (see example-code) to map Basic (Username:password) to an Authorization
fn basic_authorization(&self, basic: &Basic) -> Result<Authorization, ApiError>;
}
}

// Implement it for AllowAllAuthenticator (dummy is needed, but should not used as we have Bearer authorization)
use swagger::auth::{AllowAllAuthenticator, RcBound, Scopes};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use futures::Stream;
use std::error::Error;
use std::collections::BTreeSet;
use std::task::{Poll, Context};
use swagger::{ApiError, ContextWrapper};
use swagger::{ApiError, ContextWrapper, auth::Authorization};
use serde::{Serialize, Deserialize};
use crate::server::Authorization;


type ServiceError = Box<dyn Error + Send + Sync + 'static>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ client = [
"serde_urlencoded",
{{/usesUrlEncodedForm}}
{{#hasCallbacks}}
"serde_ignored", "regex", "percent-encoding", "lazy_static",
"serde_ignored", "percent-encoding", {{^apiUsesByteArray}}"lazy_static", "regex"{{/apiUsesByteArray}}
{{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list below }}
"hyper", "hyper-util/http1", "hyper-util/http2", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
Expand All @@ -60,7 +60,8 @@ server = [
"native-tls", "hyper-openssl", "hyper-tls", "openssl",
{{/hasCallbacks}}
{{! Anything added to the list below, should probably be added to the callbacks list above }}
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
"serde_ignored", "hyper", "percent-encoding", "url",
{{^apiUsesByteArray}}"lazy_static", "regex"{{/apiUsesByteArray}}
]
cli = [
{{#apiHasDeleteMethods}}
Expand Down Expand Up @@ -88,8 +89,14 @@ futures = "0.3"
swagger = { version = "7.0.0", features = ["serdejson", "server", "client", "tls"] }
headers = "0.4.0"
log = "0.4.27"

mime = "0.3"
mockall = { version = "0.13.1", optional = true }
{{#apiUsesByteArray}}
lazy_static = "1.5"
regex = "1.12"
{{/apiUsesByteArray}}


serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down Expand Up @@ -124,9 +131,11 @@ serde_urlencoded = { version = "0.7.1", optional = true }
tower-service = "0.3.3"

# Server, and client callback-specific
{{^apiUsesByteArray}}
lazy_static = { version = "1.5", optional = true }
percent-encoding = { version = "2.3.1", optional = true }
regex = { version = "1.12", optional = true }
{{/apiUsesByteArray}}
percent-encoding = { version = "2.3.1", optional = true }

# CLI-specific
anyhow = { version = "1", optional = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::BTreeSet;
use crate::server::Authorization;
use serde::{Deserialize, Serialize};
use swagger::ApiError;
use swagger::{ApiError, auth::Authorization};
use headers::authorization::{Basic, Bearer};
#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ use mockall::automock;
use std::error::Error;
use std::collections::BTreeSet;
use std::task::{Poll, Context};
use swagger::{ApiError, ContextWrapper};
use swagger::{ApiError, ContextWrapper, auth::Authorization};
use serde::{Serialize, Deserialize};
use crate::server::Authorization;


#[cfg(any(feature = "client", feature = "server"))]
type ServiceError = Box<dyn Error + Send + Sync + 'static>;

pub const BASE_PATH: &str = "{{{basePathWithoutHost}}}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ server = [
"mime_0_2",
"multipart", "multipart/server", "swagger/multipart_form",
"hyper_0_10", "mime_multipart", "swagger/multipart_related",
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
"serde_ignored", "hyper", "percent-encoding", "url"
]
cli = [
"anyhow", "clap-verbosity-flag", "simple_logger", "structopt", "tokio"
Expand All @@ -46,6 +46,8 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
lazy_static = "1.5"
regex = "1.12"

# Crates included if required by the API definition
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
Expand All @@ -61,9 +63,7 @@ url = {version = "2.1", optional = true}
# Client-specific

# Server, and client callback-specific
lazy_static = { version = "1.4", optional = true }
percent-encoding = {version = "2.1.0", optional = true}
regex = {version = "1.3", optional = true}

# CLI-specific
anyhow = { version = "1", optional = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::BTreeSet;
use crate::server::Authorization;
use serde::{Deserialize, Serialize};
use swagger::{ApiError, auth::{Basic, Bearer}};
use swagger::{ApiError, auth::{Basic, Bearer, Authorization}};

#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
Expand All @@ -24,7 +23,7 @@ pub trait AuthenticationApi {

/// Method should be implemented (see example-code) to map Basic (Username:password) to an Authorization
fn basic_authorization(&self, basic: &Basic) -> Result<Authorization, ApiError>;
}
}

// Implement it for AllowAllAuthenticator (dummy is needed, but should not used as we have Bearer authorization)
use swagger::auth::{AllowAllAuthenticator, RcBound, Scopes};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use futures::Stream;
use std::error::Error;
use std::collections::BTreeSet;
use std::task::{Poll, Context};
use swagger::{ApiError, ContextWrapper};
use swagger::{ApiError, ContextWrapper, auth::Authorization};
use serde::{Serialize, Deserialize};
use crate::server::Authorization;


type ServiceError = Box<dyn Error + Send + Sync + 'static>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ client = [
"hyper", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
]
server = [
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
"serde_ignored", "hyper", "percent-encoding", "url" ,"lazy_static", "regex"
]
cli = [
"anyhow", "clap-verbosity-flag", "simple_logger", "structopt", "tokio"
Expand Down Expand Up @@ -52,8 +52,8 @@ url = {version = "2.1", optional = true}

# Server, and client callback-specific
lazy_static = { version = "1.4", optional = true }
percent-encoding = {version = "2.1.0", optional = true}
regex = {version = "1.3", optional = true}
percent-encoding = {version = "2.1.0", optional = true}

# CLI-specific
anyhow = { version = "1", optional = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::BTreeSet;
use crate::server::Authorization;
use serde::{Deserialize, Serialize};
use swagger::{ApiError, auth::{Basic, Bearer}};
use swagger::{ApiError, auth::{Basic, Bearer, Authorization}};

#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
Expand All @@ -24,7 +23,7 @@ pub trait AuthenticationApi {

/// Method should be implemented (see example-code) to map Basic (Username:password) to an Authorization
fn basic_authorization(&self, basic: &Basic) -> Result<Authorization, ApiError>;
}
}

// Implement it for AllowAllAuthenticator (dummy is needed, but should not used as we have Bearer authorization)
use swagger::auth::{AllowAllAuthenticator, RcBound, Scopes};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use futures::Stream;
use std::error::Error;
use std::collections::BTreeSet;
use std::task::{Poll, Context};
use swagger::{ApiError, ContextWrapper};
use swagger::{ApiError, ContextWrapper, auth::Authorization};
use serde::{Serialize, Deserialize};
use crate::server::Authorization;


type ServiceError = Box<dyn Error + Send + Sync + 'static>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ edition = "2018"
default = ["client", "server"]
client = [
"serde_urlencoded",
"serde_ignored", "regex", "percent-encoding", "lazy_static",
"serde_ignored", "percent-encoding",
"hyper", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
]
server = [
"native-tls", "hyper-openssl", "hyper-tls", "openssl",
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
"serde_ignored", "hyper", "percent-encoding", "url"
]
cli = [
"anyhow", "clap-verbosity-flag", "simple_logger", "structopt", "tokio"
Expand All @@ -43,6 +43,8 @@ mime = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }
lazy_static = "1.5"
regex = "1.12"

# Crates included if required by the API definition
serde-xml-rs = "0.8"
Expand All @@ -57,9 +59,7 @@ url = {version = "2.1", optional = true}
serde_urlencoded = {version = "0.6.1", optional = true}

# Server, and client callback-specific
lazy_static = { version = "1.4", optional = true }
percent-encoding = {version = "2.1.0", optional = true}
regex = {version = "1.3", optional = true}

# CLI-specific
anyhow = { version = "1", optional = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::BTreeSet;
use crate::server::Authorization;
use serde::{Deserialize, Serialize};
use swagger::{ApiError, auth::{Basic, Bearer}};
use swagger::{ApiError, auth::{Basic, Bearer, Authorization}};

#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
Expand All @@ -24,7 +23,7 @@ pub trait AuthenticationApi {

/// Method should be implemented (see example-code) to map Basic (Username:password) to an Authorization
fn basic_authorization(&self, basic: &Basic) -> Result<Authorization, ApiError>;
}
}

// Implement it for AllowAllAuthenticator (dummy is needed, but should not used as we have Bearer authorization)
use swagger::auth::{AllowAllAuthenticator, RcBound, Scopes};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use futures::Stream;
use std::error::Error;
use std::collections::BTreeSet;
use std::task::{Poll, Context};
use swagger::{ApiError, ContextWrapper};
use swagger::{ApiError, ContextWrapper, auth::Authorization};
use serde::{Serialize, Deserialize};
use crate::server::Authorization;


type ServiceError = Box<dyn Error + Send + Sync + 'static>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ client = [
"hyper", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
]
server = [
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
"serde_ignored", "hyper", "percent-encoding", "url" ,"lazy_static", "regex"
]
cli = [
"anyhow", "clap-verbosity-flag", "simple_logger", "structopt", "tokio"
Expand Down Expand Up @@ -52,8 +52,8 @@ url = {version = "2.1", optional = true}

# Server, and client callback-specific
lazy_static = { version = "1.4", optional = true }
percent-encoding = {version = "2.1.0", optional = true}
regex = {version = "1.3", optional = true}
percent-encoding = {version = "2.1.0", optional = true}

# CLI-specific
anyhow = { version = "1", optional = true }
Expand Down
Loading
Loading