diff --git a/config/client/dart.yml b/config/client/dart.yml index 300443f3c38..b53e897fbc8 100644 --- a/config/client/dart.yml +++ b/config/client/dart.yml @@ -2,7 +2,7 @@ pubAuthor: ORY GmbH pubAuthorEmail: opensource@ory.sh pubHomepage: https://www.ory.sh pubName: ${DART_PUB_NAME} -pubDescription: ${DART_PUB_DESCRIPTION} +pubDescription: ${PACKAGE_DESCRIPTION} pubRepository: ${DART_PUB_REPOSITORY} pubVersion: $RAW_VERSION diff --git a/openapi/templates/.gitkeep b/openapi/templates/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/openapi/templates/rust/Cargo.mustache b/openapi/templates/rust/Cargo.mustache deleted file mode 100644 index 23d7ea08470..00000000000 --- a/openapi/templates/rust/Cargo.mustache +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "{{{packageName}}}" -version = "{{{packageVersion}}}" -authors = ["OpenAPI Generator team and contributors"] -edition = "2018" - -[dependencies] -num-traits = { version = "^0.2", default-features = false } -serde = "^1.0" -serde_derive = "^1.0" -serde_json = "^1.0" -url = "^2.2" -{{#hyper}} -hyper = "~0.11" -serde_yaml = "0.7" -base64 = "~0.7.0" -futures = "0.1.23" -{{/hyper}} -{{#reqwest}} -{{^supportAsync}} -reqwest = "~0.9" -{{/supportAsync}} -{{#supportAsync}} -[dependencies.reqwest] -version = "^0.11" -default-features = false -features = ["json", "multipart"] -{{/supportAsync}} -{{/reqwest}} - -[dev-dependencies] -{{#hyper}} -tokio-core = "*" -{{/hyper}} diff --git a/openapi/templates/rust/README.md b/openapi/templates/rust/README.md deleted file mode 100644 index 43494e43e41..00000000000 --- a/openapi/templates/rust/README.md +++ /dev/null @@ -1 +0,0 @@ -# openapi-generator-rust diff --git a/openapi/templates/rust/gitignore.mustache b/openapi/templates/rust/gitignore.mustache deleted file mode 100644 index 43735cf136f..00000000000 --- a/openapi/templates/rust/gitignore.mustache +++ /dev/null @@ -1,3 +0,0 @@ -/target/ - - diff --git a/openapi/templates/rust/hyper/api.mustache b/openapi/templates/rust/hyper/api.mustache deleted file mode 100644 index 56a2c68ce5f..00000000000 --- a/openapi/templates/rust/hyper/api.mustache +++ /dev/null @@ -1,167 +0,0 @@ -{{>partial_header}} -use std::rc::Rc; -use std::borrow::Borrow; -#[allow(unused_imports)] -use std::option::Option; - -use hyper; -use serde_json; -use futures::Future; - -use super::{Error, configuration}; -use super::request as __internal_request; - -pub struct {{{classname}}}Client { - configuration: Rc>, -} - -impl {{{classname}}}Client { - pub fn new(configuration: Rc>) -> {{{classname}}}Client { - {{{classname}}}Client { - configuration, - } - } -} - -pub trait {{{classname}}} { -{{#operations}} -{{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Box>>; -{{/operation}} -{{/operations}} -} - -impl{{{classname}}} for {{{classname}}}Client { -{{#operations}} -{{#operation}} - fn {{{operationId}}}(&self, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}crate::models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Box>> { - let mut req = __internal_request::Request::new(hyper::Method::{{{httpMethod}}}, "{{{path}}}".to_string()) - {{#hasAuthMethods}} - {{#authMethods}} - {{#isApiKey}} - .with_auth(__internal_request::Auth::ApiKey(__internal_request::ApiKey{ - in_header: {{#isKeyInHeader}}true{{/isKeyInHeader}}{{^isKeyInHeader}}false{{/isKeyInHeader}}, - in_query: {{#isKeyInQuery}}true{{/isKeyInQuery}}{{^isKeyInQuery}}false{{/isKeyInQuery}}, - param_name: "{{{keyParamName}}}".to_owned(), - })) - {{/isApiKey}} - {{#isBasic}} - .with_auth(__internal_request::Auth::Basic) - {{/isBasic}} - {{#isOAuth}} - .with_auth(__internal_request::Auth::Oauth) - {{/isOAuth}} - {{/authMethods}} - {{/hasAuthMethods}} - ; - {{#queryParams}} - {{#required}} - {{^isNullable}} - req = req.with_query_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_query_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_query_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(ref s) = {{{paramName}}} { - req = req.with_query_param("{{{baseName}}}".to_string(), s{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/queryParams}} - {{#pathParams}} - {{#required}} - {{^isNullable}} - req = req.with_path_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_path_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_path_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/pathParams}} - {{#hasHeaderParams}} - {{#headerParams}} - {{#required}} - {{^isNullable}} - req = req.with_header_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_header_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_header_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/headerParams}} - {{/hasHeaderParams}} - {{#hasFormParams}} - {{#formParams}} - {{#isFile}} - {{#required}} - {{^isNullable}} - req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, - None => { req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_form_param("{{{baseName}}}".to_string(), unimplemented!()); - } - {{/required}} - {{/isFile}} - {{^isFile}} - {{#required}} - {{^isNullable}} - req = req.with_form_param("{{{baseName}}}".to_string(), {{{paramName}}}{{#isArray}}.join(","){{/isArray}}.to_string()); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(param_value) => { req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); }, - None => { req = req.with_form_param("{{{baseName}}}".to_string(), "".to_string()); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(param_value) = {{{paramName}}} { - req = req.with_form_param("{{{baseName}}}".to_string(), param_value{{#isArray}}.join(","){{/isArray}}.to_string()); - } - {{/required}} - {{/isFile}} - {{/formParams}} - {{/hasFormParams}} - {{#hasBodyParam}} - {{#bodyParams}} - req = req.with_body_param({{{paramName}}}); - {{/bodyParams}} - {{/hasBodyParam}} - {{^returnType}} - req = req.returns_nothing(); - {{/returnType}} - - req.execute(self.configuration.borrow()) - } - -{{/operation}} -{{/operations}} -} diff --git a/openapi/templates/rust/hyper/api_mod.mustache b/openapi/templates/rust/hyper/api_mod.mustache deleted file mode 100644 index d2b43120854..00000000000 --- a/openapi/templates/rust/hyper/api_mod.mustache +++ /dev/null @@ -1,68 +0,0 @@ -use hyper; -use serde; -use serde_json; - -#[derive(Debug)] -pub enum Error { - UriError(hyper::error::UriError), - Hyper(hyper::Error), - Serde(serde_json::Error), - ApiError(ApiError), -} - -#[derive(Debug)] -pub struct ApiError { - pub code: hyper::StatusCode, - pub content: Option, -} - -impl<'de, T> From<(hyper::StatusCode, &'de [u8])> for Error - where T: serde::Deserialize<'de> { - fn from(e: (hyper::StatusCode, &'de [u8])) -> Self { - if e.1.len() == 0 { - return Error::ApiError(ApiError{ - code: e.0, - content: None, - }); - } - match serde_json::from_slice::(e.1) { - Ok(t) => Error::ApiError(ApiError{ - code: e.0, - content: Some(t), - }), - Err(e) => { - Error::from(e) - } - } - } -} - -impl From for Error { - fn from(e: hyper::Error) -> Self { - return Error::Hyper(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - return Error::Serde(e) - } -} - -mod request; - -{{#apiInfo}} -{{#apis}} -mod {{{classFilename}}}; -{{#operations}} -{{#operation}} -{{#-last}} -pub use self::{{{classFilename}}}::{ {{{classname}}}, {{{classname}}}Client }; -{{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - -pub mod configuration; -pub mod client; diff --git a/openapi/templates/rust/hyper/client.mustache b/openapi/templates/rust/hyper/client.mustache deleted file mode 100644 index 5b3bcf85c75..00000000000 --- a/openapi/templates/rust/hyper/client.mustache +++ /dev/null @@ -1,53 +0,0 @@ -use std::rc::Rc; - -use hyper; -use super::configuration::Configuration; - -pub struct APIClient { -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} - {{#-last}} - {{{classFilename}}}: Box, - {{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} -} - -impl APIClient { - pub fn new(configuration: Configuration) -> APIClient { - let rc = Rc::new(configuration); - - APIClient { -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} - {{#-last}} - {{{classFilename}}}: Box::new(crate::apis::{{{classname}}}Client::new(rc.clone())), - {{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} - } - } - -{{#apiInfo}} -{{#apis}} -{{#operations}} -{{#operation}} -{{#-last}} - pub fn {{{classFilename}}}(&self) -> &dyn crate::apis::{{{classname}}}{ - self.{{{classFilename}}}.as_ref() - } - -{{/-last}} -{{/operation}} -{{/operations}} -{{/apis}} -{{/apiInfo}} -} diff --git a/openapi/templates/rust/hyper/configuration.mustache b/openapi/templates/rust/hyper/configuration.mustache deleted file mode 100644 index adb51d6e92c..00000000000 --- a/openapi/templates/rust/hyper/configuration.mustache +++ /dev/null @@ -1,32 +0,0 @@ -{{>partial_header}} -use hyper; - -pub struct Configuration { - pub base_path: String, - pub user_agent: Option, - pub client: hyper::client::Client, - pub basic_auth: Option, - pub oauth_access_token: Option, - pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one -} - -pub type BasicAuth = (String, Option); - -pub struct ApiKey { - pub prefix: Option, - pub key: String, -} - -impl Configuration { - pub fn new(client: hyper::client::Client) -> Configuration { - Configuration { - base_path: "{{{basePath}}}".to_owned(), - user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, - client: client, - basic_auth: None, - oauth_access_token: None, - api_key: None, - } - } -} diff --git a/openapi/templates/rust/lib.mustache b/openapi/templates/rust/lib.mustache deleted file mode 100644 index cdc5287aae7..00000000000 --- a/openapi/templates/rust/lib.mustache +++ /dev/null @@ -1,16 +0,0 @@ -#[macro_use] -extern crate serde_derive; - -extern crate serde; -extern crate serde_json; -extern crate url; -{{#hyper}} -extern crate hyper; -extern crate futures; -{{/hyper}} -{{#reqwest}} -extern crate reqwest; -{{/reqwest}} - -pub mod apis; -pub mod models; diff --git a/openapi/templates/rust/model.mustache b/openapi/templates/rust/model.mustache deleted file mode 100644 index 2aeb50e1813..00000000000 --- a/openapi/templates/rust/model.mustache +++ /dev/null @@ -1,134 +0,0 @@ -{{>partial_header}} -{{#models}} -{{#model}} -{{#description}} -/// {{{classname}}} : {{{description}}} -{{/description}} - -{{!-- for enum schemas --}} -{{#isEnum}} -/// {{{description}}} -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum {{{classname}}} { -{{#allowableValues}} -{{#enumVars}} - #[serde(rename = "{{{value}}}")] - {{{name}}}, -{{/enumVars}}{{/allowableValues}} -} - -impl ToString for {{{classname}}} { - fn to_string(&self) -> String { - match self { - {{#allowableValues}} - {{#enumVars}} - Self::{{{name}}} => String::from("{{{value}}}"), - {{/enumVars}} - {{/allowableValues}} - } - } -} -{{/isEnum}} - -{{!-- for schemas that have a discriminator --}} -{{#discriminator}} -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -#[serde(tag = "{{{vendorExtensions.x-tag-name}}}")] -{{#vendorExtensions}} -pub enum {{{classname}}} { - {{#x-mapped-models}} - #[serde(rename="{{mappingName}}")] - {{{modelName}}} { - {{#vars}} - {{#description}} - /// {{{description}}} - {{/description}} - #[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})] - // {{required}}, {{isNullable}}, {{enumName}}, {{dataType}}, {{isModel}} - {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{classname}}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{#isModel}}Box<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}}, - {{/vars}} - }, - {{/x-mapped-models}} -} - -{{!-- for properties within the enums above that are of enum type --}} -{{#x-mapped-models}} -{{#vars}} -{{#isEnum}} -/// {{{description}}} -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum {{{classname}}}{{{enumName}}} { -{{#allowableValues}} - {{#enumVars}} - #[serde(rename = "{{{value}}}")] - {{{name}}}, - {{/enumVars}} -{{/allowableValues}} -} -{{/isEnum}} -{{/vars}} -{{/x-mapped-models}} -{{/vendorExtensions}} - -{{/discriminator}} - -{{!-- for non-enum schemas --}} -{{^isEnum}} -{{^discriminator}} -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct {{{classname}}} { -{{#vars}} - {{#description}} - /// {{{description}}} - {{/description}} - #[serde(rename = "{{{baseName}}}"{{^required}}, skip_serializing_if = "Option::is_none"{{/required}})] - pub {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{#isArray}}{{#uniqueItems}}std::collections::HashSet<{{/uniqueItems}}{{^uniqueItems}}Vec<{{/uniqueItems}}{{/isArray}}{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{#isModel}}Box<{{{dataType}}}>{{/isModel}}{{^isModel}}{{{dataType}}}{{/isModel}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}}, -{{/vars}} -} - -{{!-- if there are no required vars, implement Default (TODO: check if we can do the same if all vars are nullable --}} -{{#requiredVars}} -{{/requiredVars}} -{{^requiredVars}} -impl Default for {{{classname}}} { - fn default() -> Self { - Self::new() - } -} -{{/requiredVars}} - -impl {{{classname}}} { - {{#description}} - /// {{{description}}} - {{/description}} - pub fn new({{#requiredVars}}{{{name}}}: {{#isNullable}}Option<{{/isNullable}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}>{{/isNullable}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} { - {{{classname}}} { - {{#vars}} - {{{name}}}{{^required}}{{#isArray}}: None{{/isArray}}{{#isMap}}: None{{/isMap}}{{^isContainer}}: None{{/isContainer}}{{/required}}{{#required}}{{#isModel}}: {{#isNullable}}{{{name}}}.map(Box::new){{/isNullable}}{{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{/isModel}}{{/required}}, - {{/vars}} - } - } -} -{{/discriminator}} -{{/isEnum}} - -{{!-- for properties that are of enum type --}} -{{^discriminator}} -{{#vars}} -{{#isEnum}} -/// {{{description}}} -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum {{{enumName}}} { -{{#allowableValues}} -{{#enumVars}} - #[serde(rename = "{{{value}}}")] - {{{name}}}, -{{/enumVars}} -{{/allowableValues}} -} -{{/isEnum}} -{{/vars}} -{{/discriminator}} - -{{/model}} -{{/models}} diff --git a/openapi/templates/rust/model_mod.mustache b/openapi/templates/rust/model_mod.mustache deleted file mode 100644 index 06bf92f019a..00000000000 --- a/openapi/templates/rust/model_mod.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#models}} -{{#model}} -pub mod {{{classFilename}}}; -pub use self::{{{classFilename}}}::{{{classname}}}; -{{/model}} -{{/models}} diff --git a/openapi/templates/rust/partial_header.mustache b/openapi/templates/rust/partial_header.mustache deleted file mode 100644 index 9eb233d1197..00000000000 --- a/openapi/templates/rust/partial_header.mustache +++ /dev/null @@ -1,13 +0,0 @@ -/* - {{#appName}} - * {{{appName}}} - * - {{/appName}} - {{#appDescription}} - * {{{appDescription}}} - * - {{/appDescription}} - * {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}} - * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} - * Generated by: https://openapi-generator.tech - */ diff --git a/openapi/templates/rust/request.rs b/openapi/templates/rust/request.rs deleted file mode 100644 index f97b5277196..00000000000 --- a/openapi/templates/rust/request.rs +++ /dev/null @@ -1,239 +0,0 @@ -use std::borrow::Cow; -use std::collections::HashMap; - -use super::{configuration, Error}; -use futures; -use futures::{Future, Stream}; -use hyper; -use hyper::header::UserAgent; -use serde; -use serde_json; - -pub(crate) struct ApiKey { - pub in_header: bool, - pub in_query: bool, - pub param_name: String, -} - -impl ApiKey { - fn key(&self, prefix: &Option, key: &str) -> String { - match prefix { - None => key.to_owned(), - Some(ref prefix) => format!("{} {}", prefix, key), - } - } -} - -#[allow(dead_code)] -pub(crate) enum Auth { - None, - ApiKey(ApiKey), - Basic, - Oauth, -} - -pub(crate) struct Request { - auth: Auth, - method: hyper::Method, - path: String, - query_params: HashMap, - no_return_type: bool, - path_params: HashMap, - form_params: HashMap, - header_params: HashMap, - // TODO: multiple body params are possible technically, but not supported here. - serialized_body: Option, -} - -impl Request { - pub fn new(method: hyper::Method, path: String) -> Self { - Request { - auth: Auth::None, - method: method, - path: path, - query_params: HashMap::new(), - path_params: HashMap::new(), - form_params: HashMap::new(), - header_params: HashMap::new(), - serialized_body: None, - no_return_type: false, - } - } - - pub fn with_body_param(mut self, param: T) -> Self { - self.serialized_body = Some(serde_json::to_string(¶m).unwrap()); - self - } - - pub fn with_header_param(mut self, basename: String, param: String) -> Self { - self.header_params.insert(basename, param); - self - } - - pub fn with_query_param(mut self, basename: String, param: String) -> Self { - self.query_params.insert(basename, param); - self - } - - pub fn with_path_param(mut self, basename: String, param: String) -> Self { - self.path_params.insert(basename, param); - self - } - - pub fn with_form_param(mut self, basename: String, param: String) -> Self { - self.form_params.insert(basename, param); - self - } - - pub fn returns_nothing(mut self) -> Self { - self.no_return_type = true; - self - } - - pub fn with_auth(mut self, auth: Auth) -> Self { - self.auth = auth; - self - } - - pub fn execute<'a, C, U>( - self, - conf: &configuration::Configuration, - ) -> Box> + 'a> - where - C: hyper::client::Connect, - U: Sized + 'a, - for<'de> U: serde::Deserialize<'de>, - { - let mut query_string = ::url::form_urlencoded::Serializer::new("".to_owned()); - // raw_headers is for headers we don't know the proper type of (e.g. custom api key - // headers); headers is for ones we do know the type of. - let mut raw_headers = HashMap::new(); - let mut headers: hyper::header::Headers = hyper::header::Headers::new(); - - let mut path = self.path; - for (k, v) in self.path_params { - // replace {id} with the value of the id path param - path = path.replace(&format!("{{{}}}", k), &v); - } - - for (k, v) in self.header_params { - raw_headers.insert(k, v); - } - - for (key, val) in self.query_params { - query_string.append_pair(&key, &val); - } - - match self.auth { - Auth::ApiKey(apikey) => { - if let Some(ref key) = conf.api_key { - let val = apikey.key(&key.prefix, &key.key); - if apikey.in_query { - query_string.append_pair(&apikey.param_name, &val); - } - if apikey.in_header { - raw_headers.insert(apikey.param_name, val); - } - } - } - Auth::Basic => { - if let Some(ref auth_conf) = conf.basic_auth { - let auth = hyper::header::Authorization(hyper::header::Basic { - username: auth_conf.0.to_owned(), - password: auth_conf.1.to_owned(), - }); - headers.set(auth); - } - } - Auth::Oauth => { - if let Some(ref token) = conf.oauth_access_token { - let auth = hyper::header::Authorization(hyper::header::Bearer { - token: token.to_owned(), - }); - headers.set(auth); - } - } - Auth::None => {} - } - - let mut uri_str = format!("{}{}", conf.base_path, path); - - let query_string_str = query_string.finish(); - if query_string_str != "" { - uri_str += "?"; - uri_str += &query_string_str; - } - let uri: hyper::Uri = match uri_str.parse() { - Err(e) => { - return Box::new(futures::future::err(Error::UriError(e))); - } - Ok(u) => u, - }; - - let mut req = hyper::Request::new(self.method, uri); - { - let req_headers = req.headers_mut(); - if let Some(ref user_agent) = conf.user_agent { - req_headers.set(UserAgent::new(Cow::Owned(user_agent.clone()))); - } - - req_headers.extend(headers.iter()); - - for (key, val) in raw_headers { - req_headers.set_raw(key, val); - } - } - - if self.form_params.len() > 0 { - req.headers_mut().set(hyper::header::ContentType::form_url_encoded()); - let mut enc = ::url::form_urlencoded::Serializer::new("".to_owned()); - for (k, v) in self.form_params { - enc.append_pair(&k, &v); - } - req.set_body(enc.finish()); - } - - if let Some(body) = self.serialized_body { - req.headers_mut().set(hyper::header::ContentType::json()); - req.headers_mut() - .set(hyper::header::ContentLength(body.len() as u64)); - req.set_body(body); - } - - let no_ret_type = self.no_return_type; - let res = conf.client - .request(req) - .map_err(|e| Error::from(e)) - .and_then(|resp| { - let status = resp.status(); - resp.body() - .concat2() - .and_then(move |body| Ok((status, body))) - .map_err(|e| Error::from(e)) - }) - .and_then(|(status, body)| { - if status.is_success() { - Ok(body) - } else { - Err(Error::from((status, &*body))) - } - }); - Box::new( - res - .and_then(move |body| { - let parsed: Result = if no_ret_type { - // This is a hack; if there's no_ret_type, U is (), but serde_json gives an - // error when deserializing "" into (), so deserialize 'null' into it - // instead. - // An alternate option would be to require U: Default, and then return - // U::default() here instead since () implements that, but then we'd - // need to impl default for all models. - serde_json::from_str("null") - } else { - serde_json::from_slice(&body) - }; - parsed.map_err(|e| Error::from(e)) - }) - ) - } -} diff --git a/openapi/templates/rust/reqwest/api.mustache b/openapi/templates/rust/reqwest/api.mustache deleted file mode 100644 index ab6d97410c2..00000000000 --- a/openapi/templates/rust/reqwest/api.mustache +++ /dev/null @@ -1,324 +0,0 @@ -{{>partial_header}} - -use std::fmt::Display; - -use num_traits; -use reqwest; - -use crate::apis::ResponseContent; -use super::{Error, configuration}; - -trait NumVecJoin { - fn join(&self, sep: &str) -> String; -} - -impl NumVecJoin for Vec { - fn join(&self, sep: &str) -> String { - self.iter() - .map(ToString::to_string) - .collect::>() - .join(sep) - } -} - -{{#operations}} -{{#operation}} -{{#vendorExtensions.x-group-parameters}} -{{#allParams}} -{{#-first}} -/// struct for passing parameters to the method `{{operationId}}` -#[derive(Clone, Debug)] -pub struct {{{operationIdCamelCase}}}Params { -{{/-first}} - {{#description}} - /// {{{.}}} - {{/description}} - pub {{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}String{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}crate::models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}},{{/-last}} -{{#-last}} -} - -{{/-last}} -{{/allParams}} -{{/vendorExtensions.x-group-parameters}} -{{/operation}} -{{/operations}} - -{{#supportMultipleResponses}} -{{#operations}} -{{#operation}} -/// struct for typed successes of method `{{operationId}}` -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Success { - {{#responses}} - {{#is2xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is2xx}} - {{#is3xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is3xx}} - {{/responses}} - UnknownValue(serde_json::Value), -} - -{{/operation}} -{{/operations}} -{{/supportMultipleResponses}} -{{#operations}} -{{#operation}} -/// struct for typed errors of method `{{operationId}}` -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum {{{operationIdCamelCase}}}Error { - {{#responses}} - {{#is4xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is4xx}} - {{#is5xx}} - Status{{code}}({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/is5xx}} - {{#isDefault}} - DefaultResponse({{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}), - {{/isDefault}} - {{/responses}} - UnknownValue(serde_json::Value), -} - -{{/operation}} -{{/operations}} - -{{#operations}} -{{#operation}} -{{#description}} -/// {{{.}}} -{{/description}} -{{#notes}} -/// {{{.}}} -{{/notes}} -{{#vendorExtensions.x-group-parameters}} -pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration{{#allParams}}{{#-first}}, params: {{{operationIdCamelCase}}}Params{{/-first}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> { - // unbox the parameters - {{#allParams}} - let {{paramName}} = params.{{paramName}}; - {{/allParams}} - -{{/vendorExtensions.x-group-parameters}} -{{^vendorExtensions.x-group-parameters}} -pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isString}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isString}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{^isString}}{{^isUuid}}{{#schema.dataType}}{{{schema.dataType}}}{{/schema.dataType}}{{^schema.dataType}}{{^isPrimitiveType}}{{^isContainer}}{{#isBodyParam}}&crate::models::{{/isBodyParam}}{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/schema.dataType}}{{/isUuid}}{{/isString}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) -> Result<{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{#returnType}}{{{returnType}}}{{/returnType}}{{/supportMultipleResponses}}, Error<{{{operationIdCamelCase}}}Error>> { -{{/vendorExtensions.x-group-parameters}} - - let local_var_client = &configuration.client; - - let local_var_uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode({{/isString}}{{{paramName}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{#isString}}){{/isString}}{{/pathParams}}); - let mut local_var_req_builder = local_var_client.request(reqwest::Method::{{{httpMethod}}}, local_var_uri_str.as_str()); - - {{#queryParams}} - {{#required}} - local_var_req_builder = local_var_req_builder.query(&[("{{{baseName}}}", {{{paramName}}}{{#isArray}}.iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}})]); - {{/required}} - {{^required}} - if let Some(ref local_var_str) = {{{paramName}}} { - local_var_req_builder = local_var_req_builder.query(&[("{{{baseName}}}", local_var_str{{#isArray}}.iter().map(|p| p.to_string()).collect::>().join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}})]); - } - {{/required}} - {{/queryParams}} - {{#hasAuthMethods}} - {{#authMethods}} - {{#isApiKey}} - {{#isKeyInQuery}} - if let Some(ref local_var_apikey) = configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, - }; - local_var_req_builder = local_var_req_builder.query(&[("{{{keyParamName}}}", local_var_value)]); - } - {{/isKeyInQuery}} - {{/isApiKey}} - {{/authMethods}} - {{/hasAuthMethods}} - if let Some(ref local_var_user_agent) = configuration.user_agent { - local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - {{#hasHeaderParams}} - {{#headerParams}} - {{#required}} - {{^isNullable}} - local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", {{{paramName}}}{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(local_var_param_value) => { local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); }, - None => { local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", ""); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(local_var_param_value) = {{{paramName}}} { - local_var_req_builder = local_var_req_builder.header("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); - } - {{/required}} - {{/headerParams}} - {{/hasHeaderParams}} - {{#hasAuthMethods}} - {{#authMethods}} - {{#isApiKey}} - {{#isKeyInHeader}} - if let Some(ref local_var_apikey) = configuration.api_key { - let local_var_key = local_var_apikey.key.clone(); - let local_var_value = match local_var_apikey.prefix { - Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key), - None => local_var_key, - }; - local_var_req_builder = local_var_req_builder.header("{{{keyParamName}}}", local_var_value); - }; - {{/isKeyInHeader}} - {{/isApiKey}} - {{#isBasic}} - {{#isBasicBasic}} - if let Some(ref local_var_auth_conf) = configuration.basic_auth { - local_var_req_builder = local_var_req_builder.basic_auth(local_var_auth_conf.0.to_owned(), local_var_auth_conf.1.to_owned()); - }; - {{/isBasicBasic}} - {{#isBasicBearer}} - if let Some(ref local_var_token) = configuration.bearer_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - {{/isBasicBearer}} - {{/isBasic}} - {{#isOAuth}} - if let Some(ref local_var_token) = configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - {{/isOAuth}} - {{/authMethods}} - {{/hasAuthMethods}} - {{#isMultipart}} - {{#hasFormParams}} - let mut local_var_form = reqwest::multipart::Form::new(); - {{#formParams}} - {{#isFile}} - {{^supportAsync}} - {{#required}} - {{^isNullable}} - local_var_form = local_var_form.file("{{{baseName}}}", {{{paramName}}})?; - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(local_var_param_value) => { local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value)?; }, - None => { unimplemented!("Required nullable form file param not supported"); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(local_var_param_value) = {{{paramName}}} { - local_var_form = local_var_form.file("{{{baseName}}}", local_var_param_value)?; - } - {{/required}} - {{/supportAsync}} - {{#supportAsync}} - // TODO: support file upload for '{{{baseName}}}' parameter - {{/supportAsync}} - {{/isFile}} - {{^isFile}} - {{#required}} - {{^isNullable}} - local_var_form = local_var_form.text("{{{baseName}}}", {{{paramName}}}{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(local_var_param_value) => { local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); }, - None => { local_var_form = local_var_form.text("{{{baseName}}}", ""); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(local_var_param_value) = {{{paramName}}} { - local_var_form = local_var_form.text("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); - } - {{/required}} - {{/isFile}} - {{/formParams}} - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - {{/hasFormParams}} - {{/isMultipart}} - {{^isMultipart}} - {{#hasFormParams}} - let mut local_var_form_params = std::collections::HashMap::new(); - {{#formParams}} - {{#isFile}} - {{#required}} - {{^isNullable}} - local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); }, - None => { unimplemented!("Required nullable file form param not supported with x-www-form-urlencoded content"); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(local_var_param_value) = {{{paramName}}} { - local_var_form_params.insert("{{{baseName}}}", unimplemented!("File form param not supported with x-www-form-urlencoded content")); - } - {{/required}} - {{/isFile}} - {{^isFile}} - {{#required}} - {{^isNullable}} - local_var_form_params.insert("{{{baseName}}}", {{{paramName}}}{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); - {{/isNullable}} - {{#isNullable}} - match {{{paramName}}} { - Some(local_var_param_value) => { local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); }, - None => { local_var_form_params.insert("{{{baseName}}}", ""); }, - } - {{/isNullable}} - {{/required}} - {{^required}} - if let Some(local_var_param_value) = {{{paramName}}} { - local_var_form_params.insert("{{{baseName}}}", local_var_param_value{{#isArray}}.join(","){{/isArray}}{{^isArray}}.to_string(){{/isArray}}); - } - {{/required}} - {{/isFile}} - {{/formParams}} - local_var_req_builder = local_var_req_builder.form(&local_var_form_params); - {{/hasFormParams}} - {{/isMultipart}} - {{#hasBodyParam}} - {{#bodyParams}} - local_var_req_builder = local_var_req_builder.json(&{{{paramName}}}); - {{/bodyParams}} - {{/hasBodyParam}} - - let local_var_req = local_var_req_builder.build()?; - let {{^supportAsync}}mut {{/supportAsync}}local_var_resp = local_var_client.execute(local_var_req){{#supportAsync}}.await{{/supportAsync}}?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text(){{#supportAsync}}.await{{/supportAsync}}?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - {{^supportMultipleResponses}} - {{^returnType}} - Ok(()) - {{/returnType}} - {{#returnType}} - serde_json::from_str(&local_var_content).map_err(Error::from) - {{/returnType}} - {{/supportMultipleResponses}} - {{#supportMultipleResponses}} - let local_var_entity: Option<{{{operationIdCamelCase}}}Success> = serde_json::from_str(&local_var_content).ok(); - let local_var_result = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Ok(local_var_result) - {{/supportMultipleResponses}} - } else { - let local_var_entity: Option<{{{operationIdCamelCase}}}Error> = serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; - Err(Error::ResponseError(local_var_error)) - } -} - -{{/operation}} -{{/operations}} diff --git a/openapi/templates/rust/reqwest/api_mod.mustache b/openapi/templates/rust/reqwest/api_mod.mustache deleted file mode 100644 index e4daf80c8f6..00000000000 --- a/openapi/templates/rust/reqwest/api_mod.mustache +++ /dev/null @@ -1,70 +0,0 @@ -use std::error; -use std::fmt; - -#[derive(Debug, Clone)] -pub struct ResponseContent { - pub status: reqwest::StatusCode, - pub content: String, - pub entity: Option, -} - -#[derive(Debug)] -pub enum Error { - Reqwest(reqwest::Error), - Serde(serde_json::Error), - Io(std::io::Error), - ResponseError(ResponseContent), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let (module, e) = match self { - Error::Reqwest(e) => ("reqwest", e.to_string()), - Error::Serde(e) => ("serde", e.to_string()), - Error::Io(e) => ("IO", e.to_string()), - Error::ResponseError(e) => ("response", format!("status code {}", e.status)), - }; - write!(f, "error in {}: {}", module, e) - } -} - -impl error::Error for Error { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { - Some(match self { - Error::Reqwest(e) => e, - Error::Serde(e) => e, - Error::Io(e) => e, - Error::ResponseError(_) => return None, - }) - } -} - -impl From for Error { - fn from(e: reqwest::Error) -> Self { - Error::Reqwest(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - Error::Serde(e) - } -} - -impl From for Error { - fn from(e: std::io::Error) -> Self { - Error::Io(e) - } -} - -pub fn urlencode>(s: T) -> String { - ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() -} - -{{#apiInfo}} -{{#apis}} -pub mod {{{classFilename}}}; -{{/apis}} -{{/apiInfo}} - -pub mod configuration; diff --git a/openapi/templates/rust/reqwest/configuration.mustache b/openapi/templates/rust/reqwest/configuration.mustache deleted file mode 100644 index 339be6bcced..00000000000 --- a/openapi/templates/rust/reqwest/configuration.mustache +++ /dev/null @@ -1,43 +0,0 @@ -{{>partial_header}} - -use reqwest; - -#[derive(Debug, Clone)] -pub struct Configuration { - pub base_path: String, - pub user_agent: Option, - pub client: reqwest::Client, - pub basic_auth: Option, - pub oauth_access_token: Option, - pub bearer_access_token: Option, - pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one -} - -pub type BasicAuth = (String, Option); - -#[derive(Debug, Clone)] -pub struct ApiKey { - pub prefix: Option, - pub key: String, -} - -impl Configuration { - pub fn new() -> Configuration { - Configuration::default() - } -} - -impl Default for Configuration { - fn default() -> Self { - Configuration { - base_path: "{{{basePath}}}".to_owned(), - user_agent: {{#httpUserAgent}}Some("{{{.}}}".to_owned()){{/httpUserAgent}}{{^httpUserAgent}}Some("OpenAPI-Generator/{{{version}}}/rust".to_owned()){{/httpUserAgent}}, - client: reqwest::Client::new(), - basic_auth: None, - oauth_access_token: None, - bearer_access_token: None, - api_key: None, - } - } -} diff --git a/scripts/generate.sh b/scripts/generate.sh index 0bdb36fd3a2..4a8df023553 100755 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -282,11 +282,8 @@ rust () { file="${dir}/Cargo.toml" - if [ $project != "client" ]; then - (sed "s/${VERSION}/${RAW_VERSION}"'"\ndescription = "SDK Client for Ory '"${PROJECT_UCF}"'"\ndocumentation = "https:\/\/www.ory.sh\/'"${PROJECT}"'\/docs\/sdk"\nhomepage = "https:\/\/www.ory.sh"\nlicense = "Apache-2.0/g' < "${file}") > tmp.$$.rb && mv tmp.$$.rb "${file}" - else - (sed "s/${VERSION}/${RAW_VERSION}"'"\ndescription = "SDK Client for Ory"\ndocumentation = "https:\/\/www.ory.sh\/docs\/sdk"\nhomepage = "https:\/\/www.ory.sh"\nlicense = "Apache-2.0/g' < "${file}") > tmp.$$.rb && mv tmp.$$.rb "${file}" - fi + sed -i "s/description = \"[^\"]*\"/description = \"${PACKAGE_DESCRIPTION}\"/g" "${file}" + cp "LICENSE" "clients/${PROJECT}/rust" } @@ -311,7 +308,12 @@ elixir () { -c ./config/client/elixir.yml.proc.yml (sed "s/licenses:.*$/licenses: [\"Apache-2.0\"],\n links: %{\n \"GitHub\" => \"https:\/\/github.com\/ory\/sdk\",\n \"Website\" => \"https:\/\/www.ory.sh\",\n \"Documentation\" => \"https:\/\/www.ory.sh\/docs\",\n \"Product\" => \"https:\/\/console.ory.sh\"\n }/g" < "${file}") > tmp.$$.exs && mv tmp.$$.exs "${file}" - (sed "s/${VERSION}/${RAW_VERSION}/g" < "${file}") > tmp.$$.exs && mv tmp.$$.exs "${file}" +# (sed "s/${VERSION}/${RAW_VERSION}/g" < "${file}") > tmp.$$.exs && mv tmp.$$.exs "${file}" + sed -i '/^\s*description: """$/,/^\s*""",$/c\ + description: """\ + '"${PACKAGE_DESCRIPTION}"'\ + """, + ' "${file}" cp "LICENSE" "clients/${PROJECT}/elixir" } diff --git a/scripts/prep.sh b/scripts/prep.sh index 73e8390342a..9bac615d827 100755 --- a/scripts/prep.sh +++ b/scripts/prep.sh @@ -67,10 +67,10 @@ export SPEC_FILE=${spec_file} # shellcheck disable=SC2155 export PROJECT_UCF="$(tr '[:lower:]' '[:upper:]' <<< "${project:0:1}")${project:1}" export GPG_OPTS='--pinentry-mode loopback' +export PACKAGE_DESCRIPTION=$(cat "config/descriptions/${PROJECT}.txt") export DOTNET_PACKAGE_NAME="Ory.$PROJECT_UCF.Client" export DART_PUB_NAME="ory_${PROJECT}_client" -export DART_PUB_DESCRIPTION=$(cat "config/descriptions/${PROJECT}.txt") export DART_PUB_REPOSITORY="https://github.com/ory/sdk/tree/master/clients/${PROJECT}/dart" export JAVA_GROUP_ID=sh.ory.$PROJECT diff --git a/scripts/release.sh b/scripts/release.sh index 293b47577fc..0a30ed93ea1 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -172,7 +172,7 @@ golang() { python() { dir="clients/${PROJECT}/python" - (cd "${dir}"; rm -rf "dist" || true; pip install wheel; python3 setup.py sdist bdist_wheel; python3 -m twine upload "dist/*") + (cd "${dir}"; rm -rf "dist" || true; pip install wheel; python3 setup.py sdist bdist_wheel; twine upload "dist/*") to_git "python" "yes" }