diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index 13a890147ad..21e69bc28f0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -22,6 +22,9 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.media.ComposedSchema; +import io.swagger.v3.oas.models.media.FileSchema; import io.swagger.v3.oas.models.media.XML; import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.RequestBody; @@ -119,6 +122,9 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon ) ); + // We need inline enums to be resolved to a separate model so that + // anyOf/oneOf that contain them work correctly. + inlineSchemaOption.put("RESOLVE_INLINE_ENUMS", "true"); // Show the generation timestamp by default hideGenerationTimestamp = Boolean.FALSE; @@ -1003,6 +1009,66 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon return codegenParameter; } + @Override + public String getTypeDeclaration(String name) { + return "models::" + name; + } + + private String modelFromSchema(Schema schema) { + String ref = null; + + if (schema != null) { + ref = schema.get$ref(); + } + + if (ref != null && ref.indexOf("#/components/schemas/") == 0) { + ref = toModelName(ref.substring("#/components/schemas/".length())); + } else { + ref = null; + } + + return ref; + } + + @Override + public String getTypeDeclaration(Schema p) { + LOGGER.trace("Getting type declaration for schema"); + + if (ModelUtils.isArraySchema(p)) { + ArraySchema ap = (ArraySchema) p; + Schema inner = ap.getItems(); + String innerType = getTypeDeclaration(inner); + return typeMapping.get("array") + "<" + innerType + ">"; + } else if (ModelUtils.isMapSchema(p)) { + Schema inner = ModelUtils.getAdditionalProperties(p); + String innerType = getTypeDeclaration(inner); + StringBuilder typeDeclaration = new StringBuilder(typeMapping.get("map")).append("<").append(typeMapping.get("string")).append(", "); + typeDeclaration.append(innerType).append(">"); + return typeDeclaration.toString(); + } else if (!StringUtils.isEmpty(p.get$ref())) { + String dataType; + try { + dataType = modelFromSchema(p); + + if (dataType != null) { + dataType = "models::" + dataType; + LOGGER.debug("Returning " + dataType + " from ref"); + } + } catch (Exception e) { + dataType = null; + LOGGER.error("Error obtaining the datatype from schema (model): " + p + ". Error was: " + e.getMessage(), e); + } + + LOGGER.debug("Returning " + dataType); + + return dataType; + } else if (p instanceof FileSchema) { + return typeMapping.get("File").toString(); + } + + return super.getTypeDeclaration(p); + } + @Override public String toInstantiationType(Schema p) { if (ModelUtils.isArraySchema(p)) { @@ -1023,6 +1089,17 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon Map allDefinitions = ModelUtils.getSchemas(this.openAPI); CodegenModel mdl = super.fromModel(name, model); + LOGGER.debug("fromModel (base end): " + mdl); + + if (!StringUtils.isEmpty(model.get$ref())) { + String ref = ModelUtils.getSimpleRef(model.get$ref()); + String dataType = toModelName(ref); + mdl.dataType = dataType; + mdl.isAlias = false; + LOGGER.debug("Schema for: " + name + " is wrapper for: " + dataType); + } + + if (ModelUtils.isArraySchema(model)) { Schema inner = ModelUtils.getSchemaItems(model); String xmlName = null; @@ -1060,49 +1137,84 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon additionalProperties.put("usesXmlNamespaces", true); } - LOGGER.trace("Created model: {}", mdl); + Schema modelAdditionalProperties = ModelUtils.getAdditionalProperties(model); - return mdl; - } - - @Override - public Map postProcessAllModels(Map objs) { - Map newObjs = super.postProcessAllModels(objs); - - //Index all CodegenModels by model name. - HashMap allModels = new HashMap<>(); - for (Entry entry : objs.entrySet()) { - String modelName = toModelName(entry.getKey()); - List models = entry.getValue().getModels(); - for (ModelMap mo : models) { - allModels.put(modelName, mo.getModel()); - } + if (modelAdditionalProperties != null) { + mdl.additionalPropertiesType = getTypeDeclaration(modelAdditionalProperties); } - for (Entry entry : allModels.entrySet()) { - CodegenModel model = entry.getValue(); + // Does this support partial ordering? + boolean partialOrdSupport = true; - if (uuidType.equals(model.dataType)) { + if (mdl.dataType != null && mdl.dataType.equals("object")) { + // Object isn't a sensible default. Instead, we set it to + // 'null'. This ensures that we treat this model as a struct + // with multiple parameters. + mdl.dataType = null; + } else if ("map".equals(mdl.dataType)) { + if (!mdl.allVars.isEmpty() || mdl.additionalPropertiesType == null) { + // We don't yet support `additionalProperties` that also have + // properties. If we see variables, we ignore the + // `additionalProperties` type ('map') and warn the user. This + // will produce code that compiles, but won't feature the + // `additionalProperties` - but that's likely more useful to + // the user than the alternative. + LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties"); + mdl.dataType = null; + } else { + mdl.dataType = "std::collections::HashMap"; + partialOrdSupport = false; + } + } else if (mdl.dataType != null && mdl.isAlias) { + // We need to hack about with single-parameter models to + // get them recognised correctly. + mdl.isAlias = false; + mdl.dataType = typeMapping.get(mdl.dataType); + } + + if (uuidType.equals(mdl.dataType)) { + additionalProperties.put("apiUsesUuid", true); + } + + for (CodegenProperty prop : mdl.vars) { + if (uuidType.equals(prop.dataType)) { additionalProperties.put("apiUsesUuid", true); } - for (CodegenProperty prop : model.vars) { - if (uuidType.equals(prop.dataType)) { - additionalProperties.put("apiUsesUuid", true); - } + String xmlName = modelXmlNames.get(prop.dataType); + if (xmlName != null) { + prop.vendorExtensions.put("x-item-xml-name", xmlName); + } + } - String xmlName = modelXmlNames.get(prop.dataType); - if (xmlName != null) { - prop.vendorExtensions.put("x-item-xml-name", xmlName); - } + // Do we suppport doing ToString/FromStr conversions for query parameters? + boolean toStringSupport = true; + boolean isString = "String".equals(mdl.dataType); - if (uuidType.equals(prop.dataType)) { - additionalProperties.put("apiUsesUuid", true); + if (isString) { + toStringSupport = true; + } else if (mdl.dataType != null + && (mdl.dataType.startsWith("swagger::OneOf") || mdl.dataType.startsWith("swagger::AnyOf"))) { + toStringSupport = false; + partialOrdSupport = false; + } else if (mdl.getAdditionalPropertiesType() != null) { + toStringSupport = false; + } else if (model instanceof ComposedSchema) { + for (Schema schema : ModelUtils.getInterfaces((ComposedSchema) model)) { + if (additionalProperties != null) { + toStringSupport = false; } } } - return newObjs; + mdl.vendorExtensions.put("x-upper-case-name", name.toUpperCase(Locale.ROOT)); + mdl.vendorExtensions.put("x-is-string", isString); + mdl.vendorExtensions.put("x-to-string-support", toStringSupport); + mdl.vendorExtensions.put("x-partial-ord", partialOrdSupport); + + LOGGER.trace("Created model: " + name + ": " + mdl + " from schema: " + model); + + return mdl; } @Override @@ -1231,6 +1343,14 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon @Override public String toOneOfName(List names, Schema composedSchema) { + Map exts = null; + if (composedSchema != null) { + exts = composedSchema.getExtensions(); + } + if (exts != null && exts.containsKey("x-one-of-name")) { + return (String) exts.get("x-one-of-name"); + } + List schemas = ModelUtils.getInterfaces(composedSchema); List types = new ArrayList<>(); @@ -1251,6 +1371,12 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon return "swagger::AnyOf" + types.size() + "<" + String.join(",", types) + ">"; } + @Override + public String toAllOfName(List names, Schema composedSchema) { + // Handle all of objects as freeform + return null; + } + @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { super.postProcessModelProperty(model, property); @@ -1327,47 +1453,10 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon @Override public ModelsMap postProcessModels(ModelsMap objs) { - for (ModelMap mo : objs.getModels()) { - CodegenModel cm = mo.getModel(); - - LOGGER.trace("Post processing model: {}", cm); - - if ("object".equals(cm.dataType)) { - // Object isn't a sensible default. Instead, we set it to - // 'null'. This ensures that we treat this model as a struct - // with multiple parameters. - cm.dataType = null; - } else if ("map".equals(cm.dataType)) { - if (!cm.allVars.isEmpty() || cm.additionalPropertiesType == null) { - // We don't yet support `additionalProperties` that also have - // properties. If we see variables, we ignore the - // `additionalProperties` type ('map') and warn the user. This - // will produce code that compiles, but won't feature the - // `additionalProperties` - but that's likely more useful to - // the user than the alternative. - LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties"); - cm.dataType = null; - } else { - cm.dataType = "std::collections::HashMap"; - } - } else if (cm.dataType != null) { - // We need to hack about with single-parameter models to - // get them recognised correctly. - cm.isAlias = false; - cm.dataType = typeMapping.get(cm.dataType); - - if (uuidType.equals(cm.dataType)) { - additionalProperties.put("apiUsesUuid", true); - } - } - - cm.vendorExtensions.put("x-is-string", "String".equals(cm.dataType)); - } return super.postProcessModelsEnum(objs); } private void processParam(CodegenParameter param, CodegenOperation op) { - String example = null; // If a parameter uses UUIDs, we need to import the UUID package. diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 12409addaf3..ab1814b7c6b 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -59,12 +59,7 @@ impl std::str::FromStr for {{{classname}}} { {{/isEnum}} {{^isEnum}} {{#dataType}} -{{#isMap}} -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -{{/isMap}} -{{^isMap}} -#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] -{{/isMap}} +#[derive(Debug, Clone, PartialEq, {{#vendorExtensions.x-partial-ord}}PartialOrd, {{/vendorExtensions.x-partial-ord}}serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] {{#xmlName}} #[serde(rename = "{{{.}}}")] @@ -76,21 +71,6 @@ impl std::convert::From<{{{dataType}}}> for {{{classname}}} { {{{classname}}}(x) } } -{{#vendorExtensions.x-is-string}} - -impl std::string::ToString for {{{classname}}} { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for {{{classname}}} { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok({{{classname}}}(x.to_string())) - } -} -{{/vendorExtensions.x-is-string}} impl std::convert::From<{{{classname}}}> for {{{dataType}}} { fn from(x: {{{classname}}}) -> Self { @@ -111,13 +91,53 @@ impl std::ops::DerefMut for {{{classname}}} { } } -{{#additionalPropertiesType}} +{{#vendorExtensions.x-to-string-support}} +{{#vendorExtensions.x-is-string}} +impl std::string::ToString for {{{classname}}} { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for {{{classname}}} { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok({{{classname}}}(x.to_owned())) + } +} +{{/vendorExtensions.x-is-string}} +{{^vendorExtensions.x-is-string}} /// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false) /// specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde serializer impl ::std::string::ToString for {{{classname}}} { fn to_string(&self) -> String { - // Skipping additionalProperties in query parameter serialization + self.0.to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a {{{classname}}} value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for {{{classname}}} { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match std::str::FromStr::from_str(s) { + std::result::Result::Ok(r) => std::result::Result::Ok({{{classname}}}(r)), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {} to {{{classname}}}: {:?}", s, e)), + } + } +} +{{/vendorExtensions.x-is-string}} +{{/vendorExtensions.x-to-string-support}} +{{^vendorExtensions.x-to-string-support}} +/// Converts the {{{classname}}} value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for {{{classname}}} { + fn to_string(&self) -> String { + // ToString for this model is not supported "".to_string() } } @@ -129,10 +149,10 @@ impl ::std::str::FromStr for {{{classname}}} { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err("Parsing additionalProperties for {{{classname}}} is not supported") + std::result::Result::Err("Parsing {{{classname}}} is not supported") } } -{{/additionalPropertiesType}} +{{/vendorExtensions.x-to-string-support}} {{/dataType}} {{^dataType}} {{#arrayModelType}} @@ -508,6 +528,8 @@ impl std::str::FromStr for {{{classname}}} { } } {{/arrayModelType}} +{{/dataType}} +{{/isEnum}} // Methods for converting between header::IntoHeaderValue<{{{classname}}}> and hyper::header::HeaderValue @@ -547,8 +569,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } -{{/dataType}} -{{/isEnum}} +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec<{{{classname}}}> = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match <{{{classname}}} as std::str::FromStr>::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into {{classname}} - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} {{#usesXml}} {{#usesXmlNamespaces}} {{#xmlNamespace}} diff --git a/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml b/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml index af7ac951593..13b04938eb6 100644 --- a/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/rust-server/openapi-v3.yaml @@ -480,6 +480,12 @@ components: - BAR - type: string description: Alternate option + AnyOfHashMapObject: + description: Test a model containing an anyOf of a hash map + anyOf: + - type: string + - additionalProperties: + type: string 12345AnyOfObject: description: Test a model containing an anyOf that starts with a number anyOf: diff --git a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs index ea0267cbe02..690641e4c55 100644 --- a/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/multipart-v3/src/models.rs @@ -144,6 +144,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MultipartRelatedRequest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -279,6 +324,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MultipartRequestObjectField - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -408,3 +498,48 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MultipleIdenticalMimeTypesPostRequest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} diff --git a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs index 07546b7a11f..31b5358ab60 100644 --- a/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/no-example-v3/src/models.rs @@ -124,3 +124,48 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OpGetRequest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} diff --git a/samples/server/petstore/rust-server/output/openapi-v3/.openapi-generator/FILES b/samples/server/petstore/rust-server/output/openapi-v3/.openapi-generator/FILES index 7d5a6131394..7b8ea8d79ca 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/.openapi-generator/FILES +++ b/samples/server/petstore/rust-server/output/openapi-v3/.openapi-generator/FILES @@ -8,13 +8,16 @@ docs/AnotherXmlArray.md docs/AnotherXmlInner.md docs/AnotherXmlObject.md docs/AnyOfGet202Response.md +docs/AnyOfHashMapObject.md docs/AnyOfObject.md +docs/AnyOfObjectAnyOf.md docs/AnyOfProperty.md docs/DuplicateXmlObject.md docs/EnumWithStarObject.md docs/Err.md docs/Error.md docs/Model12345AnyOfObject.md +docs/Model12345AnyOfObjectAnyOf.md docs/MultigetGet201Response.md docs/MyId.md docs/MyIdList.md diff --git a/samples/server/petstore/rust-server/output/openapi-v3/README.md b/samples/server/petstore/rust-server/output/openapi-v3/README.md index d190384fdcf..92452227c26 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/README.md +++ b/samples/server/petstore/rust-server/output/openapi-v3/README.md @@ -154,13 +154,16 @@ Method | HTTP request | Description - [AnotherXmlInner](docs/AnotherXmlInner.md) - [AnotherXmlObject](docs/AnotherXmlObject.md) - [AnyOfGet202Response](docs/AnyOfGet202Response.md) + - [AnyOfHashMapObject](docs/AnyOfHashMapObject.md) - [AnyOfObject](docs/AnyOfObject.md) + - [AnyOfObjectAnyOf](docs/AnyOfObjectAnyOf.md) - [AnyOfProperty](docs/AnyOfProperty.md) - [DuplicateXmlObject](docs/DuplicateXmlObject.md) - [EnumWithStarObject](docs/EnumWithStarObject.md) - [Err](docs/Err.md) - [Error](docs/Error.md) - [Model12345AnyOfObject](docs/Model12345AnyOfObject.md) + - [Model12345AnyOfObjectAnyOf](docs/Model12345AnyOfObjectAnyOf.md) - [MultigetGet201Response](docs/MultigetGet201Response.md) - [MyId](docs/MyId.md) - [MyIdList](docs/MyIdList.md) diff --git a/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml b/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml index 729b977ae32..4f311692224 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml +++ b/samples/server/petstore/rust-server/output/openapi-v3/api/openapi.yaml @@ -478,20 +478,20 @@ components: - requiredAnyOf AnyOfObject: anyOf: - - enum: - - FOO - - BAR - type: string + - $ref: '#/components/schemas/AnyOfObject_anyOf' - description: Alternate option type: string description: Test a model containing an anyOf + AnyOfHashMapObject: + anyOf: + - type: string + - additionalProperties: + type: string + type: object + description: Test a model containing an anyOf of a hash map "12345AnyOfObject": anyOf: - - enum: - - FOO - - BAR - - '*' - type: string + - $ref: '#/components/schemas/_12345AnyOfObject_anyOf' - description: Alternate option type: string description: Test a model containing an anyOf that starts with a number @@ -701,6 +701,17 @@ components: anyOf: - $ref: '#/components/schemas/StringObject' - $ref: '#/components/schemas/UuidObject' + AnyOfObject_anyOf: + enum: + - FOO + - BAR + type: string + _12345AnyOfObject_anyOf: + enum: + - FOO + - BAR + - '*' + type: string securitySchemes: authScheme: flows: diff --git a/samples/server/petstore/rust-server/output/openapi-v3/docs/AnyOfHashMapObject.md b/samples/server/petstore/rust-server/output/openapi-v3/docs/AnyOfHashMapObject.md new file mode 100644 index 00000000000..28263cd2a83 --- /dev/null +++ b/samples/server/petstore/rust-server/output/openapi-v3/docs/AnyOfHashMapObject.md @@ -0,0 +1,9 @@ +# AnyOfHashMapObject + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs index 007c0f268f8..043e71c56a1 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/models.rs @@ -40,7 +40,7 @@ impl std::ops::DerefMut for AdditionalPropertiesWithList { /// Should be implemented in a serde serializer impl ::std::string::ToString for AdditionalPropertiesWithList { fn to_string(&self) -> String { - // Skipping additionalProperties in query parameter serialization + // ToString for this model is not supported "".to_string() } } @@ -52,7 +52,91 @@ impl ::std::str::FromStr for AdditionalPropertiesWithList { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesWithList is not supported") + std::result::Result::Err("Parsing AdditionalPropertiesWithList is not supported") + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AdditionalPropertiesWithList - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AdditionalPropertiesWithList - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AdditionalPropertiesWithList - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } } } @@ -203,6 +287,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnotherXmlArray - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AnotherXmlArray { /// Helper function to allow us to convert this model to an XML string. @@ -224,19 +353,6 @@ impl std::convert::From for AnotherXmlInner { } } -impl std::string::ToString for AnotherXmlInner { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for AnotherXmlInner { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(AnotherXmlInner(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: AnotherXmlInner) -> Self { x.0 @@ -256,6 +372,102 @@ impl std::ops::DerefMut for AnotherXmlInner { } } +impl std::string::ToString for AnotherXmlInner { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for AnotherXmlInner { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(AnotherXmlInner(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AnotherXmlInner - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnotherXmlInner - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnotherXmlInner - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AnotherXmlInner { /// Helper function to allow us to convert this model to an XML string. @@ -391,6 +603,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnotherXmlObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AnotherXmlObject { /// Associated constant for this model's XML namespace. @@ -410,71 +667,53 @@ impl AnotherXmlObject { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct AnyOfGet202Response { +pub struct AnyOfGet202Response(swagger::AnyOf2); + +impl std::convert::From> for AnyOfGet202Response { + fn from(x: swagger::AnyOf2) -> Self { + AnyOfGet202Response(x) + } } +impl std::convert::From for swagger::AnyOf2 { + fn from(x: AnyOfGet202Response) -> Self { + x.0 + } +} -impl AnyOfGet202Response { - #[allow(clippy::new_without_default)] - pub fn new() -> AnyOfGet202Response { - AnyOfGet202Response { - } +impl std::ops::Deref for AnyOfGet202Response { + type Target = swagger::AnyOf2; + fn deref(&self) -> &swagger::AnyOf2 { + &self.0 + } +} + +impl std::ops::DerefMut for AnyOfGet202Response { + fn deref_mut(&mut self) -> &mut swagger::AnyOf2 { + &mut self.0 } } /// Converts the AnyOfGet202Response value to the Query Parameters representation (style=form, explode=false) /// specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde serializer -impl std::string::ToString for AnyOfGet202Response { +impl ::std::string::ToString for AnyOfGet202Response { fn to_string(&self) -> String { - let params: Vec> = vec![ - ]; - - params.into_iter().flatten().collect::>().join(",") + // ToString for this model is not supported + "".to_string() } } /// Converts Query Parameters representation (style=form, explode=false) to a AnyOfGet202Response value /// as specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde deserializer -impl std::str::FromStr for AnyOfGet202Response { - type Err = String; +impl ::std::str::FromStr for AnyOfGet202Response { + type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - /// An intermediate representation of the struct to use for parsing. - #[derive(Default)] - #[allow(dead_code)] - struct IntermediateRep { - } - - let mut intermediate_rep = IntermediateRep::default(); - - // Parse into intermediate representation - let mut string_iter = s.split(','); - let mut key_result = string_iter.next(); - - while key_result.is_some() { - let val = match string_iter.next() { - Some(x) => x, - None => return std::result::Result::Err("Missing value while parsing AnyOfGet202Response".to_string()) - }; - - if let Some(key) = key_result { - #[allow(clippy::match_single_binding)] - match key { - _ => return std::result::Result::Err("Unexpected key while parsing AnyOfGet202Response".to_string()) - } - } - - // Get the next key - key_result = string_iter.next(); - } - - // Use the intermediate representation to return the struct - std::result::Result::Ok(AnyOfGet202Response { - }) + std::result::Result::Err("Parsing AnyOfGet202Response is not supported") } } @@ -516,6 +755,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfGet202Response - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AnyOfGet202Response { /// Helper function to allow us to convert this model to an XML string. @@ -526,72 +810,198 @@ impl AnyOfGet202Response { } } -/// Test a model containing an anyOf -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] +/// Test a model containing an anyOf of a hash map +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct AnyOfObject { +pub struct AnyOfHashMapObject(swagger::AnyOf2>); + +impl std::convert::From>> for AnyOfHashMapObject { + fn from(x: swagger::AnyOf2>) -> Self { + AnyOfHashMapObject(x) + } } +impl std::convert::From for swagger::AnyOf2> { + fn from(x: AnyOfHashMapObject) -> Self { + x.0 + } +} -impl AnyOfObject { - #[allow(clippy::new_without_default)] - pub fn new() -> AnyOfObject { - AnyOfObject { +impl std::ops::Deref for AnyOfHashMapObject { + type Target = swagger::AnyOf2>; + fn deref(&self) -> &swagger::AnyOf2> { + &self.0 + } +} + +impl std::ops::DerefMut for AnyOfHashMapObject { + fn deref_mut(&mut self) -> &mut swagger::AnyOf2> { + &mut self.0 + } +} + +/// Converts the AnyOfHashMapObject value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for AnyOfHashMapObject { + fn to_string(&self) -> String { + // ToString for this model is not supported + "".to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a AnyOfHashMapObject value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for AnyOfHashMapObject { + type Err = &'static str; + + fn from_str(s: &str) -> std::result::Result { + std::result::Result::Err("Parsing AnyOfHashMapObject is not supported") + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AnyOfHashMapObject - value: {} is invalid {}", + hdr_value, e)) } } } +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfHashMapObject - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfHashMapObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl AnyOfHashMapObject { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Test a model containing an anyOf +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] +pub struct AnyOfObject(swagger::AnyOf2); + +impl std::convert::From> for AnyOfObject { + fn from(x: swagger::AnyOf2) -> Self { + AnyOfObject(x) + } +} + +impl std::convert::From for swagger::AnyOf2 { + fn from(x: AnyOfObject) -> Self { + x.0 + } +} + +impl std::ops::Deref for AnyOfObject { + type Target = swagger::AnyOf2; + fn deref(&self) -> &swagger::AnyOf2 { + &self.0 + } +} + +impl std::ops::DerefMut for AnyOfObject { + fn deref_mut(&mut self) -> &mut swagger::AnyOf2 { + &mut self.0 + } +} + /// Converts the AnyOfObject value to the Query Parameters representation (style=form, explode=false) /// specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde serializer -impl std::string::ToString for AnyOfObject { +impl ::std::string::ToString for AnyOfObject { fn to_string(&self) -> String { - let params: Vec> = vec![ - ]; - - params.into_iter().flatten().collect::>().join(",") + // ToString for this model is not supported + "".to_string() } } /// Converts Query Parameters representation (style=form, explode=false) to a AnyOfObject value /// as specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde deserializer -impl std::str::FromStr for AnyOfObject { - type Err = String; +impl ::std::str::FromStr for AnyOfObject { + type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - /// An intermediate representation of the struct to use for parsing. - #[derive(Default)] - #[allow(dead_code)] - struct IntermediateRep { - } - - let mut intermediate_rep = IntermediateRep::default(); - - // Parse into intermediate representation - let mut string_iter = s.split(','); - let mut key_result = string_iter.next(); - - while key_result.is_some() { - let val = match string_iter.next() { - Some(x) => x, - None => return std::result::Result::Err("Missing value while parsing AnyOfObject".to_string()) - }; - - if let Some(key) = key_result { - #[allow(clippy::match_single_binding)] - match key { - _ => return std::result::Result::Err("Unexpected key while parsing AnyOfObject".to_string()) - } - } - - // Get the next key - key_result = string_iter.next(); - } - - // Use the intermediate representation to return the struct - std::result::Result::Ok(AnyOfObject { - }) + std::result::Result::Err("Parsing AnyOfObject is not supported") } } @@ -633,6 +1043,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AnyOfObject { /// Helper function to allow us to convert this model to an XML string. @@ -643,6 +1098,134 @@ impl AnyOfObject { } } +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum AnyOfObjectAnyOf { + #[serde(rename = "FOO")] + Foo, + #[serde(rename = "BAR")] + Bar, +} + +impl std::fmt::Display for AnyOfObjectAnyOf { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + AnyOfObjectAnyOf::Foo => write!(f, "FOO"), + AnyOfObjectAnyOf::Bar => write!(f, "BAR"), + } + } +} + +impl std::str::FromStr for AnyOfObjectAnyOf { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "FOO" => std::result::Result::Ok(AnyOfObjectAnyOf::Foo), + "BAR" => std::result::Result::Ok(AnyOfObjectAnyOf::Bar), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AnyOfObjectAnyOf - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfObjectAnyOf - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfObjectAnyOf - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl AnyOfObjectAnyOf { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + /// Test containing an anyOf object #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -771,6 +1354,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnyOfProperty - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AnyOfProperty { /// Helper function to allow us to convert this model to an XML string. @@ -917,6 +1545,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into DuplicateXmlObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl DuplicateXmlObject { /// Associated constant for this model's XML namespace. @@ -976,6 +1649,90 @@ impl std::str::FromStr for EnumWithStarObject { } } +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumWithStarObject - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumWithStarObject - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumWithStarObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + impl EnumWithStarObject { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. @@ -995,19 +1752,6 @@ impl std::convert::From for Err { } } -impl std::string::ToString for Err { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for Err { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(Err(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: Err) -> Self { x.0 @@ -1027,6 +1771,102 @@ impl std::ops::DerefMut for Err { } } +impl std::string::ToString for Err { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for Err { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(Err(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Err - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Err - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Err - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Err { /// Helper function to allow us to convert this model to an XML string. @@ -1047,19 +1887,6 @@ impl std::convert::From for Error { } } -impl std::string::ToString for Error { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for Error { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(Error(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: Error) -> Self { x.0 @@ -1079,6 +1906,102 @@ impl std::ops::DerefMut for Error { } } +impl std::string::ToString for Error { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for Error { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(Error(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Error - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Error - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Error - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Error { /// Helper function to allow us to convert this model to an XML string. @@ -1090,71 +2013,53 @@ impl Error { } /// Test a model containing an anyOf that starts with a number -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct Model12345AnyOfObject { +pub struct Model12345AnyOfObject(swagger::AnyOf2); + +impl std::convert::From> for Model12345AnyOfObject { + fn from(x: swagger::AnyOf2) -> Self { + Model12345AnyOfObject(x) + } } +impl std::convert::From for swagger::AnyOf2 { + fn from(x: Model12345AnyOfObject) -> Self { + x.0 + } +} -impl Model12345AnyOfObject { - #[allow(clippy::new_without_default)] - pub fn new() -> Model12345AnyOfObject { - Model12345AnyOfObject { - } +impl std::ops::Deref for Model12345AnyOfObject { + type Target = swagger::AnyOf2; + fn deref(&self) -> &swagger::AnyOf2 { + &self.0 + } +} + +impl std::ops::DerefMut for Model12345AnyOfObject { + fn deref_mut(&mut self) -> &mut swagger::AnyOf2 { + &mut self.0 } } /// Converts the Model12345AnyOfObject value to the Query Parameters representation (style=form, explode=false) /// specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde serializer -impl std::string::ToString for Model12345AnyOfObject { +impl ::std::string::ToString for Model12345AnyOfObject { fn to_string(&self) -> String { - let params: Vec> = vec![ - ]; - - params.into_iter().flatten().collect::>().join(",") + // ToString for this model is not supported + "".to_string() } } /// Converts Query Parameters representation (style=form, explode=false) to a Model12345AnyOfObject value /// as specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde deserializer -impl std::str::FromStr for Model12345AnyOfObject { - type Err = String; +impl ::std::str::FromStr for Model12345AnyOfObject { + type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - /// An intermediate representation of the struct to use for parsing. - #[derive(Default)] - #[allow(dead_code)] - struct IntermediateRep { - } - - let mut intermediate_rep = IntermediateRep::default(); - - // Parse into intermediate representation - let mut string_iter = s.split(','); - let mut key_result = string_iter.next(); - - while key_result.is_some() { - let val = match string_iter.next() { - Some(x) => x, - None => return std::result::Result::Err("Missing value while parsing Model12345AnyOfObject".to_string()) - }; - - if let Some(key) = key_result { - #[allow(clippy::match_single_binding)] - match key { - _ => return std::result::Result::Err("Unexpected key while parsing Model12345AnyOfObject".to_string()) - } - } - - // Get the next key - key_result = string_iter.next(); - } - - // Use the intermediate representation to return the struct - std::result::Result::Ok(Model12345AnyOfObject { - }) + std::result::Result::Err("Parsing Model12345AnyOfObject is not supported") } } @@ -1196,6 +2101,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Model12345AnyOfObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Model12345AnyOfObject { /// Helper function to allow us to convert this model to an XML string. @@ -1206,6 +2156,138 @@ impl Model12345AnyOfObject { } } +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum Model12345AnyOfObjectAnyOf { + #[serde(rename = "FOO")] + Foo, + #[serde(rename = "BAR")] + Bar, + #[serde(rename = "*")] + Star, +} + +impl std::fmt::Display for Model12345AnyOfObjectAnyOf { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + Model12345AnyOfObjectAnyOf::Foo => write!(f, "FOO"), + Model12345AnyOfObjectAnyOf::Bar => write!(f, "BAR"), + Model12345AnyOfObjectAnyOf::Star => write!(f, "*"), + } + } +} + +impl std::str::FromStr for Model12345AnyOfObjectAnyOf { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "FOO" => std::result::Result::Ok(Model12345AnyOfObjectAnyOf::Foo), + "BAR" => std::result::Result::Ok(Model12345AnyOfObjectAnyOf::Bar), + "*" => std::result::Result::Ok(Model12345AnyOfObjectAnyOf::Star), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Model12345AnyOfObjectAnyOf - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Model12345AnyOfObjectAnyOf - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Model12345AnyOfObjectAnyOf - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl Model12345AnyOfObjectAnyOf { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MultigetGet201Response { @@ -1329,6 +2411,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MultigetGet201Response - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl MultigetGet201Response { /// Helper function to allow us to convert this model to an XML string. @@ -1368,6 +2495,112 @@ impl std::ops::DerefMut for MyId { } } +/// Converts the MyId value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for MyId { + fn to_string(&self) -> String { + self.0.to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a MyId value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for MyId { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match std::str::FromStr::from_str(s) { + std::result::Result::Ok(r) => std::result::Result::Ok(MyId(r)), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {} to MyId: {:?}", s, e)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for MyId - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MyId - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MyId - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl MyId { /// Helper function to allow us to convert this model to an XML string. @@ -1506,6 +2739,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MyIdList - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl MyIdList { /// Helper function to allow us to convert this model to an XML string. @@ -1762,6 +3040,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into NullableTest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl NullableTest { /// Helper function to allow us to convert this model to an XML string. @@ -1907,6 +3230,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectHeader - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ObjectHeader { /// Helper function to allow us to convert this model to an XML string. @@ -2052,6 +3420,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectParam - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ObjectParam { /// Helper function to allow us to convert this model to an XML string. @@ -2209,6 +3622,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectUntypedProps - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ObjectUntypedProps { /// Helper function to allow us to convert this model to an XML string. @@ -2341,6 +3799,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectWithArrayOfObjects - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ObjectWithArrayOfObjects { /// Helper function to allow us to convert this model to an XML string. @@ -2361,19 +3864,6 @@ impl std::convert::From for Ok { } } -impl std::string::ToString for Ok { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for Ok { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(Ok(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: Ok) -> Self { x.0 @@ -2393,6 +3883,102 @@ impl std::ops::DerefMut for Ok { } } +impl std::string::ToString for Ok { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for Ok { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(Ok(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Ok - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Ok - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Ok - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Ok { /// Helper function to allow us to convert this model to an XML string. @@ -2403,71 +3989,53 @@ impl Ok { } } -#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] +#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] -pub struct OneOfGet200Response { +pub struct OneOfGet200Response(swagger::OneOf2>); + +impl std::convert::From>> for OneOfGet200Response { + fn from(x: swagger::OneOf2>) -> Self { + OneOfGet200Response(x) + } } +impl std::convert::From for swagger::OneOf2> { + fn from(x: OneOfGet200Response) -> Self { + x.0 + } +} -impl OneOfGet200Response { - #[allow(clippy::new_without_default)] - pub fn new() -> OneOfGet200Response { - OneOfGet200Response { - } +impl std::ops::Deref for OneOfGet200Response { + type Target = swagger::OneOf2>; + fn deref(&self) -> &swagger::OneOf2> { + &self.0 + } +} + +impl std::ops::DerefMut for OneOfGet200Response { + fn deref_mut(&mut self) -> &mut swagger::OneOf2> { + &mut self.0 } } /// Converts the OneOfGet200Response value to the Query Parameters representation (style=form, explode=false) /// specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde serializer -impl std::string::ToString for OneOfGet200Response { +impl ::std::string::ToString for OneOfGet200Response { fn to_string(&self) -> String { - let params: Vec> = vec![ - ]; - - params.into_iter().flatten().collect::>().join(",") + // ToString for this model is not supported + "".to_string() } } /// Converts Query Parameters representation (style=form, explode=false) to a OneOfGet200Response value /// as specified in https://swagger.io/docs/specification/serialization/ /// Should be implemented in a serde deserializer -impl std::str::FromStr for OneOfGet200Response { - type Err = String; +impl ::std::str::FromStr for OneOfGet200Response { + type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - /// An intermediate representation of the struct to use for parsing. - #[derive(Default)] - #[allow(dead_code)] - struct IntermediateRep { - } - - let mut intermediate_rep = IntermediateRep::default(); - - // Parse into intermediate representation - let mut string_iter = s.split(','); - let mut key_result = string_iter.next(); - - while key_result.is_some() { - let val = match string_iter.next() { - Some(x) => x, - None => return std::result::Result::Err("Missing value while parsing OneOfGet200Response".to_string()) - }; - - if let Some(key) = key_result { - #[allow(clippy::match_single_binding)] - match key { - _ => return std::result::Result::Err("Unexpected key while parsing OneOfGet200Response".to_string()) - } - } - - // Get the next key - key_result = string_iter.next(); - } - - // Use the intermediate representation to return the struct - std::result::Result::Ok(OneOfGet200Response { - }) + std::result::Result::Err("Parsing OneOfGet200Response is not supported") } } @@ -2509,6 +4077,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OneOfGet200Response - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl OneOfGet200Response { /// Helper function to allow us to convert this model to an XML string. @@ -2548,6 +4161,112 @@ impl std::ops::DerefMut for OptionalObjectHeader { } } +/// Converts the OptionalObjectHeader value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for OptionalObjectHeader { + fn to_string(&self) -> String { + self.0.to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a OptionalObjectHeader value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for OptionalObjectHeader { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match std::str::FromStr::from_str(s) { + std::result::Result::Ok(r) => std::result::Result::Ok(OptionalObjectHeader(r)), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {} to OptionalObjectHeader: {:?}", s, e)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for OptionalObjectHeader - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OptionalObjectHeader - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OptionalObjectHeader - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl OptionalObjectHeader { /// Helper function to allow us to convert this model to an XML string. @@ -2587,6 +4306,112 @@ impl std::ops::DerefMut for RequiredObjectHeader { } } +/// Converts the RequiredObjectHeader value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for RequiredObjectHeader { + fn to_string(&self) -> String { + self.0.to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a RequiredObjectHeader value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for RequiredObjectHeader { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match std::str::FromStr::from_str(s) { + std::result::Result::Ok(r) => std::result::Result::Ok(RequiredObjectHeader(r)), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {} to RequiredObjectHeader: {:?}", s, e)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for RequiredObjectHeader - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into RequiredObjectHeader - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into RequiredObjectHeader - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl RequiredObjectHeader { /// Helper function to allow us to convert this model to an XML string. @@ -2607,19 +4432,6 @@ impl std::convert::From for Result { } } -impl std::string::ToString for Result { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for Result { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(Result(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: Result) -> Self { x.0 @@ -2639,6 +4451,102 @@ impl std::ops::DerefMut for Result { } } +impl std::string::ToString for Result { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for Result { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(Result(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for Result - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Result - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Result - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Result { /// Helper function to allow us to convert this model to an XML string. @@ -2684,6 +4592,90 @@ impl std::str::FromStr for StringEnum { } } +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for StringEnum - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into StringEnum - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into StringEnum - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + impl StringEnum { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. @@ -2703,19 +4695,6 @@ impl std::convert::From for StringObject { } } -impl std::string::ToString for StringObject { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for StringObject { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(StringObject(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: StringObject) -> Self { x.0 @@ -2735,6 +4714,102 @@ impl std::ops::DerefMut for StringObject { } } +impl std::string::ToString for StringObject { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for StringObject { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(StringObject(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for StringObject - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into StringObject - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into StringObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl StringObject { /// Helper function to allow us to convert this model to an XML string. @@ -2775,6 +4850,112 @@ impl std::ops::DerefMut for UuidObject { } } +/// Converts the UuidObject value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for UuidObject { + fn to_string(&self) -> String { + self.0.to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a UuidObject value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for UuidObject { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match std::str::FromStr::from_str(s) { + std::result::Result::Ok(r) => std::result::Result::Ok(UuidObject(r)), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {} to UuidObject: {:?}", s, e)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for UuidObject - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into UuidObject - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into UuidObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl UuidObject { /// Helper function to allow us to convert this model to an XML string. @@ -2923,6 +5104,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into XmlArray - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl XmlArray { /// Helper function to allow us to convert this model to an XML string. @@ -2944,19 +5170,6 @@ impl std::convert::From for XmlInner { } } -impl std::string::ToString for XmlInner { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for XmlInner { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(XmlInner(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: XmlInner) -> Self { x.0 @@ -2976,6 +5189,102 @@ impl std::ops::DerefMut for XmlInner { } } +impl std::string::ToString for XmlInner { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for XmlInner { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(XmlInner(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for XmlInner - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into XmlInner - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into XmlInner - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl XmlInner { /// Helper function to allow us to convert this model to an XML string. @@ -3128,6 +5437,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into XmlObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl XmlObject { /// Associated constant for this model's XML namespace. diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/FILES b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/FILES index d72d04fabfa..a0e98549a01 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/FILES +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/.openapi-generator/FILES @@ -18,12 +18,19 @@ docs/Client.md docs/Dog.md docs/DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket.md docs/EnumArrays.md +docs/EnumArraysArrayArrayEnumInnerInner.md +docs/EnumArraysArrayEnumInner.md +docs/EnumArraysJustSymbol.md docs/EnumClass.md docs/EnumTest.md +docs/EnumTestEnumInteger.md +docs/EnumTestEnumString.md +docs/FindPetsByStatusStatusParameterInner.md docs/FormatTest.md docs/HasOnlyReadOnly.md docs/List.md docs/MapTest.md +docs/MapTestMapMapOfEnumValueValue.md docs/MixedPropertiesAndAdditionalPropertiesClass.md docs/Model200Response.md docs/Name.md @@ -31,15 +38,22 @@ docs/NumberOnly.md docs/ObjectContainingObjectWithOnlyAdditionalProperties.md docs/ObjectWithOnlyAdditionalProperties.md docs/Order.md +docs/OrderStatus.md docs/OuterBoolean.md docs/OuterComposite.md docs/OuterEnum.md docs/OuterNumber.md docs/OuterString.md docs/Pet.md +docs/PetStatus.md docs/ReadOnlyFirst.md docs/Return.md docs/Tag.md +docs/TestEnumParametersEnumHeaderStringArrayParameterInner.md +docs/TestEnumParametersEnumHeaderStringParameter.md +docs/TestEnumParametersEnumQueryDoubleParameter.md +docs/TestEnumParametersEnumQueryIntegerParameter.md +docs/TestEnumParametersRequestEnumFormString.md docs/User.md docs/another_fake_api.md docs/fake_api.md diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md index 459405c67b5..15d416ccaaf 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/README.md @@ -173,12 +173,19 @@ Method | HTTP request | Description - [Dog](docs/Dog.md) - [DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket](docs/DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket.md) - [EnumArrays](docs/EnumArrays.md) + - [EnumArraysArrayArrayEnumInnerInner](docs/EnumArraysArrayArrayEnumInnerInner.md) + - [EnumArraysArrayEnumInner](docs/EnumArraysArrayEnumInner.md) + - [EnumArraysJustSymbol](docs/EnumArraysJustSymbol.md) - [EnumClass](docs/EnumClass.md) - [EnumTest](docs/EnumTest.md) + - [EnumTestEnumInteger](docs/EnumTestEnumInteger.md) + - [EnumTestEnumString](docs/EnumTestEnumString.md) + - [FindPetsByStatusStatusParameterInner](docs/FindPetsByStatusStatusParameterInner.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - [List](docs/List.md) - [MapTest](docs/MapTest.md) + - [MapTestMapMapOfEnumValueValue](docs/MapTestMapMapOfEnumValueValue.md) - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - [Model200Response](docs/Model200Response.md) - [Name](docs/Name.md) @@ -186,15 +193,22 @@ Method | HTTP request | Description - [ObjectContainingObjectWithOnlyAdditionalProperties](docs/ObjectContainingObjectWithOnlyAdditionalProperties.md) - [ObjectWithOnlyAdditionalProperties](docs/ObjectWithOnlyAdditionalProperties.md) - [Order](docs/Order.md) + - [OrderStatus](docs/OrderStatus.md) - [OuterBoolean](docs/OuterBoolean.md) - [OuterComposite](docs/OuterComposite.md) - [OuterEnum](docs/OuterEnum.md) - [OuterNumber](docs/OuterNumber.md) - [OuterString](docs/OuterString.md) - [Pet](docs/Pet.md) + - [PetStatus](docs/PetStatus.md) - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Return](docs/Return.md) - [Tag](docs/Tag.md) + - [TestEnumParametersEnumHeaderStringArrayParameterInner](docs/TestEnumParametersEnumHeaderStringArrayParameterInner.md) + - [TestEnumParametersEnumHeaderStringParameter](docs/TestEnumParametersEnumHeaderStringParameter.md) + - [TestEnumParametersEnumQueryDoubleParameter](docs/TestEnumParametersEnumQueryDoubleParameter.md) + - [TestEnumParametersEnumQueryIntegerParameter](docs/TestEnumParametersEnumQueryIntegerParameter.md) + - [TestEnumParametersRequestEnumFormString](docs/TestEnumParametersRequestEnumFormString.md) - [User](docs/User.md) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/api/openapi.yaml b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/api/openapi.yaml index 534372bf58f..55cf1881c2c 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/api/openapi.yaml +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/api/openapi.yaml @@ -85,12 +85,7 @@ paths: required: true schema: items: - default: available - enum: - - available - - pending - - sold - type: string + $ref: '#/components/schemas/findPetsByStatus_status_parameter_inner' type: array style: form responses: @@ -597,64 +592,38 @@ paths: name: enum_header_string_array schema: items: - default: $ - enum: - - '>' - - $ - type: string + $ref: '#/components/schemas/testEnumParameters_enum_header_string_array_parameter_inner' type: array style: simple - description: Header parameter enum test (string) in: header name: enum_header_string schema: - default: -efg - enum: - - _abc - - -efg - - (xyz) - type: string + $ref: '#/components/schemas/testEnumParameters_enum_header_string_parameter' - description: Query parameter enum test (string array) explode: false in: query name: enum_query_string_array schema: items: - default: $ - enum: - - '>' - - $ - type: string + $ref: '#/components/schemas/testEnumParameters_enum_header_string_array_parameter_inner' type: array style: form - description: Query parameter enum test (string) in: query name: enum_query_string schema: - default: -efg - enum: - - _abc - - -efg - - (xyz) - type: string + $ref: '#/components/schemas/testEnumParameters_enum_header_string_parameter' - description: Query parameter enum test (double) in: query name: enum_query_integer schema: - enum: - - 1 - - -2 - format: int32 - type: integer + $ref: '#/components/schemas/testEnumParameters_enum_query_integer_parameter' - description: Query parameter enum test (double) in: query name: enum_query_double schema: - enum: - - 1.1 - - -1.2 - format: double - type: number + $ref: '#/components/schemas/testEnumParameters_enum_query_double_parameter' requestBody: content: application/x-www-form-urlencoded: @@ -943,12 +912,7 @@ components: format: date-time type: string status: - description: Order Status - enum: - - placed - - approved - - delivered - type: string + $ref: '#/components/schemas/Order_status' complete: default: false type: boolean @@ -1056,12 +1020,7 @@ components: name: tag wrapped: true status: - description: pet status in the store - enum: - - available - - pending - - sold - type: string + $ref: '#/components/schemas/Pet_status' required: - name - photoUrls @@ -1234,29 +1193,13 @@ components: Enum_Test: properties: enum_string: - enum: - - UPPER - - lower - - "" - type: string + $ref: '#/components/schemas/Enum_Test_enum_string' enum_string_required: - enum: - - UPPER - - lower - - "" - type: string + $ref: '#/components/schemas/Enum_Test_enum_string' enum_integer: - enum: - - 1 - - -1 - format: int32 - type: integer + $ref: '#/components/schemas/Enum_Test_enum_integer' enum_number: - enum: - - 1.1 - - -1.2 - format: double - type: number + $ref: '#/components/schemas/testEnumParameters_enum_query_double_parameter' outerEnum: $ref: '#/components/schemas/OuterEnum' required: @@ -1354,18 +1297,12 @@ components: map_map_of_enum: additionalProperties: additionalProperties: - enum: - - UPPER - - lower - type: string + $ref: '#/components/schemas/MapTest_map_map_of_enum_value_value' type: object type: object map_of_enum_string: additionalProperties: - enum: - - UPPER - - lower - type: string + $ref: '#/components/schemas/MapTest_map_map_of_enum_value_value' type: object type: object ArrayTest: @@ -1389,10 +1326,7 @@ components: type: array array_of_enum: items: - enum: - - UPPER - - lower - type: string + $ref: '#/components/schemas/MapTest_map_map_of_enum_value_value' type: array type: object NumberOnly: @@ -1419,24 +1353,15 @@ components: EnumArrays: properties: just_symbol: - enum: - - '>=' - - $ - type: string + $ref: '#/components/schemas/EnumArrays_just_symbol' array_enum: items: - enum: - - fish - - crab - type: string + $ref: '#/components/schemas/EnumArrays_array_enum_inner' type: array array_array_enum: items: items: - enum: - - Cat - - Dog - type: string + $ref: '#/components/schemas/EnumArrays_array_array_enum_inner_inner' type: array type: array type: object @@ -1467,6 +1392,13 @@ components: OuterBoolean: type: boolean x-codegen-body-parameter-name: boolean_post_body + findPetsByStatus_status_parameter_inner: + default: available + enum: + - available + - pending + - sold + type: string updatePetWithForm_request: properties: name: @@ -1486,17 +1418,44 @@ components: format: binary type: string type: object + testEnumParameters_request_enum_form_string: + default: -efg + description: Form parameter enum test (string) + enum: + - _abc + - -efg + - (xyz) + type: string testEnumParameters_request: properties: enum_form_string: - default: -efg - description: Form parameter enum test (string) - enum: - - _abc - - -efg - - (xyz) - type: string + $ref: '#/components/schemas/testEnumParameters_request_enum_form_string' type: object + testEnumParameters_enum_header_string_array_parameter_inner: + default: $ + enum: + - '>' + - $ + type: string + testEnumParameters_enum_header_string_parameter: + default: -efg + enum: + - _abc + - -efg + - (xyz) + type: string + testEnumParameters_enum_query_integer_parameter: + enum: + - 1 + - -2 + format: int32 + type: integer + testEnumParameters_enum_query_double_parameter: + enum: + - 1.1 + - -1.2 + format: double + type: number testEndpointParameters_request: properties: integer: @@ -1582,6 +1541,52 @@ components: - param - param2 type: object + Order_status: + description: Order Status + enum: + - placed + - approved + - delivered + type: string + Pet_status: + description: pet status in the store + enum: + - available + - pending + - sold + type: string + Enum_Test_enum_string: + enum: + - UPPER + - lower + - "" + type: string + Enum_Test_enum_integer: + enum: + - 1 + - -1 + format: int32 + type: integer + MapTest_map_map_of_enum_value_value: + enum: + - UPPER + - lower + type: string + EnumArrays_just_symbol: + enum: + - '>=' + - $ + type: string + EnumArrays_array_enum_inner: + enum: + - fish + - crab + type: string + EnumArrays_array_array_enum_inner_inner: + enum: + - Cat + - Dog + type: string securitySchemes: petstore_auth: flows: diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/ArrayTest.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/ArrayTest.md index cfa79518c0a..b563bd578c8 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/ArrayTest.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/ArrayTest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes **array_of_string** | **Vec** | | [optional] [default to None] **array_array_of_integer** | [**Vec>**](array.md) | | [optional] [default to None] **array_array_of_model** | [**Vec>**](array.md) | | [optional] [default to None] -**array_of_enum** | **Vec** | | [optional] [default to None] +**array_of_enum** | [**Vec**](MapTest_map_map_of_enum_value_value.md) | | [optional] [default to None] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArrays.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArrays.md index 5e5f3548ebb..f829bdd18ce 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArrays.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArrays.md @@ -3,9 +3,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**just_symbol** | **String** | | [optional] [default to None] -**array_enum** | **Vec** | | [optional] [default to None] -**array_array_enum** | [**Vec>**](array.md) | | [optional] [default to None] +**just_symbol** | [***models::EnumArraysJustSymbol**](EnumArrays_just_symbol.md) | | [optional] [default to None] +**array_enum** | [**Vec**](EnumArrays_array_enum_inner.md) | | [optional] [default to None] +**array_array_enum** | [**Vec>**](array.md) | | [optional] [default to None] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysArrayArrayEnumInnerInner.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysArrayArrayEnumInnerInner.md new file mode 100644 index 00000000000..e811ef49a7b --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysArrayArrayEnumInnerInner.md @@ -0,0 +1,9 @@ +# EnumArraysArrayArrayEnumInnerInner + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysArrayEnumInner.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysArrayEnumInner.md new file mode 100644 index 00000000000..c976bdf9349 --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysArrayEnumInner.md @@ -0,0 +1,9 @@ +# EnumArraysArrayEnumInner + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysJustSymbol.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysJustSymbol.md new file mode 100644 index 00000000000..ebdd890812b --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumArraysJustSymbol.md @@ -0,0 +1,9 @@ +# EnumArraysJustSymbol + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTest.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTest.md index 89b555dd5de..cf89b12718d 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTest.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTest.md @@ -3,10 +3,10 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**enum_string** | **String** | | [optional] [default to None] -**enum_string_required** | **String** | | -**enum_integer** | **i32** | | [optional] [default to None] -**enum_number** | **f64** | | [optional] [default to None] +**enum_string** | [***models::EnumTestEnumString**](Enum_Test_enum_string.md) | | [optional] [default to None] +**enum_string_required** | [***models::EnumTestEnumString**](Enum_Test_enum_string.md) | | +**enum_integer** | [***models::EnumTestEnumInteger**](Enum_Test_enum_integer.md) | | [optional] [default to None] +**enum_number** | [***models::TestEnumParametersEnumQueryDoubleParameter**](testEnumParameters_enum_query_double_parameter.md) | | [optional] [default to None] **outer_enum** | [***models::OuterEnum**](OuterEnum.md) | | [optional] [default to None] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTestEnumInteger.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTestEnumInteger.md new file mode 100644 index 00000000000..888dc92561e --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTestEnumInteger.md @@ -0,0 +1,9 @@ +# EnumTestEnumInteger + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTestEnumString.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTestEnumString.md new file mode 100644 index 00000000000..9c8ada5e8f5 --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/EnumTestEnumString.md @@ -0,0 +1,9 @@ +# EnumTestEnumString + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/FindPetsByStatusStatusParameterInner.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/FindPetsByStatusStatusParameterInner.md new file mode 100644 index 00000000000..eb650a9da34 --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/FindPetsByStatusStatusParameterInner.md @@ -0,0 +1,9 @@ +# FindPetsByStatusStatusParameterInner + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/MapTest.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/MapTest.md index d3bdfd717a9..590eae909b9 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/MapTest.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/MapTest.md @@ -4,8 +4,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **map_map_of_string** | [**std::collections::HashMap>**](map.md) | | [optional] [default to None] -**map_map_of_enum** | [**std::collections::HashMap>**](map.md) | | [optional] [default to None] -**map_of_enum_string** | **std::collections::HashMap** | | [optional] [default to None] +**map_map_of_enum** | [**std::collections::HashMap>**](map.md) | | [optional] [default to None] +**map_of_enum_string** | [**std::collections::HashMap**](MapTest_map_map_of_enum_value_value.md) | | [optional] [default to None] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/MapTestMapMapOfEnumValueValue.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/MapTestMapMapOfEnumValueValue.md new file mode 100644 index 00000000000..98f437d887b --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/MapTestMapMapOfEnumValueValue.md @@ -0,0 +1,9 @@ +# MapTestMapMapOfEnumValueValue + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Order.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Order.md index f94865fdaa8..ab8ebad2cef 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Order.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Order.md @@ -7,7 +7,7 @@ Name | Type | Description | Notes **pet_id** | **i64** | | [optional] [default to None] **quantity** | **i32** | | [optional] [default to None] **ship_date** | [**chrono::DateTime::**](DateTime.md) | | [optional] [default to None] -**status** | **String** | Order Status | [optional] [default to None] +**status** | [***models::OrderStatus**](Order_status.md) | | [optional] [default to None] **complete** | **bool** | | [optional] [default to Some(false)] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/OrderStatus.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/OrderStatus.md new file mode 100644 index 00000000000..bf3cc64b90e --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/OrderStatus.md @@ -0,0 +1,9 @@ +# OrderStatus + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Pet.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Pet.md index 25930379f20..b82e37a480e 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Pet.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/Pet.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | [**Vec**](Tag.md) | | [optional] [default to None] -**status** | **String** | pet status in the store | [optional] [default to None] +**status** | [***models::PetStatus**](Pet_status.md) | | [optional] [default to None] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/PetStatus.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/PetStatus.md new file mode 100644 index 00000000000..a052000ba75 --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/PetStatus.md @@ -0,0 +1,9 @@ +# PetStatus + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumHeaderStringArrayParameterInner.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumHeaderStringArrayParameterInner.md new file mode 100644 index 00000000000..0035e028cca --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumHeaderStringArrayParameterInner.md @@ -0,0 +1,9 @@ +# TestEnumParametersEnumHeaderStringArrayParameterInner + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumHeaderStringParameter.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumHeaderStringParameter.md new file mode 100644 index 00000000000..2fae5705bd5 --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumHeaderStringParameter.md @@ -0,0 +1,9 @@ +# TestEnumParametersEnumHeaderStringParameter + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumQueryDoubleParameter.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumQueryDoubleParameter.md new file mode 100644 index 00000000000..2945c91e223 --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumQueryDoubleParameter.md @@ -0,0 +1,9 @@ +# TestEnumParametersEnumQueryDoubleParameter + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumQueryIntegerParameter.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumQueryIntegerParameter.md new file mode 100644 index 00000000000..95ad64f68da --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersEnumQueryIntegerParameter.md @@ -0,0 +1,9 @@ +# TestEnumParametersEnumQueryIntegerParameter + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersRequestEnumFormString.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersRequestEnumFormString.md new file mode 100644 index 00000000000..63a0cf68d6a --- /dev/null +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/TestEnumParametersRequestEnumFormString.md @@ -0,0 +1,9 @@ +# TestEnumParametersRequestEnumFormString + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md index e2821df2e6d..27c59de54b2 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/fake_api.md @@ -321,13 +321,13 @@ Optional parameters are passed through a map[string]interface{}. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **enum_header_string_array** | [**String**](String.md)| Header parameter enum test (string array) | - **enum_header_string** | **String**| Header parameter enum test (string) | [default to "-efg".to_string()] - **enum_query_string_array** | [**String**](String.md)| Query parameter enum test (string array) | - **enum_query_string** | **String**| Query parameter enum test (string) | [default to "-efg".to_string()] - **enum_query_integer** | **i32**| Query parameter enum test (double) | - **enum_query_double** | **f64**| Query parameter enum test (double) | - **enum_form_string** | **String**| Form parameter enum test (string) | [default to "-efg".to_string()] + **enum_header_string_array** | [**models::TestEnumParametersEnumHeaderStringArrayParameterInner**](models::TestEnumParametersEnumHeaderStringArrayParameterInner.md)| Header parameter enum test (string array) | + **enum_header_string** | [****](.md)| Header parameter enum test (string) | + **enum_query_string_array** | [**models::TestEnumParametersEnumHeaderStringArrayParameterInner**](models::TestEnumParametersEnumHeaderStringArrayParameterInner.md)| Query parameter enum test (string array) | + **enum_query_string** | [****](.md)| Query parameter enum test (string) | + **enum_query_integer** | [****](.md)| Query parameter enum test (double) | + **enum_query_double** | [****](.md)| Query parameter enum test (double) | + **enum_form_string** | [**testEnumParameters_request_enum_form_string**](testEnumParameters_request_enum_form_string.md)| | ### Return type diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md index 636d660c548..26e6a98d32f 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/docs/pet_api.md @@ -51,7 +51,7 @@ Multiple status values can be provided with comma separated strings Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context containing the authentication | nil if no authentication - **status** | [**String**](String.md)| Status values that need to be considered for filter | + **status** | [**models::FindPetsByStatusStatusParameterInner**](models::FindPetsByStatusStatusParameterInner.md)| Status values that need to be considered for filter | ### Return type diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs index b0e76ca713c..62b1a8c1389 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/client/main.rs @@ -245,12 +245,12 @@ fn main() { Some("TestEnumParameters") => { let result = rt.block_on(client.test_enum_parameters( Some(&Vec::new()), - Some("enum_header_string_example".to_string()), + None, Some(&Vec::new()), - Some("enum_query_string_example".to_string()), - Some(56), - Some(1.2), - Some("enum_form_string_example".to_string()) + None, + None, + None, + None )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs index 06a4cfe60a8..2920da48619 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/examples/server/server.rs @@ -253,13 +253,13 @@ impl Api for Server where C: Has + Send + Sync /// To test enum parameters async fn test_enum_parameters( &self, - enum_header_string_array: Option<&Vec>, - enum_header_string: Option, - enum_query_string_array: Option<&Vec>, - enum_query_string: Option, - enum_query_integer: Option, - enum_query_double: Option, - enum_form_string: Option, + enum_header_string_array: Option<&Vec>, + enum_header_string: Option, + enum_query_string_array: Option<&Vec>, + enum_query_string: Option, + enum_query_integer: Option, + enum_query_double: Option, + enum_form_string: Option, context: &C) -> Result { info!("test_enum_parameters({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", enum_header_string_array, enum_header_string, enum_query_string_array, enum_query_string, enum_query_integer, enum_query_double, enum_form_string, context.get().0.clone()); @@ -319,7 +319,7 @@ impl Api for Server where C: Has + Send + Sync /// Finds Pets by status async fn find_pets_by_status( &self, - status: &Vec, + status: &Vec, context: &C) -> Result { info!("find_pets_by_status({:?}) - X-Span-ID: {:?}", status, context.get().0.clone()); diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs index 6accda4cb1e..96e66db706f 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/client/mod.rs @@ -1325,13 +1325,13 @@ impl Api for Client where async fn test_enum_parameters( &self, - param_enum_header_string_array: Option<&Vec>, - param_enum_header_string: Option, - param_enum_query_string_array: Option<&Vec>, - param_enum_query_string: Option, - param_enum_query_integer: Option, - param_enum_query_double: Option, - param_enum_form_string: Option, + param_enum_header_string_array: Option<&Vec>, + param_enum_header_string: Option, + param_enum_query_string_array: Option<&Vec>, + param_enum_query_string: Option, + param_enum_query_integer: Option, + param_enum_query_double: Option, + param_enum_form_string: Option, context: &C) -> Result { let mut client_service = self.client_service.clone(); @@ -1349,7 +1349,7 @@ impl Api for Client where } if let Some(param_enum_query_string) = param_enum_query_string { query_string.append_pair("enum_query_string", - ¶m_enum_query_string); + ¶m_enum_query_string.to_string()); } if let Some(param_enum_query_integer) = param_enum_query_integer { query_string.append_pair("enum_query_integer", @@ -1381,7 +1381,7 @@ impl Api for Client where // Consumes form body let params = &[ - ("enum_form_string", param_enum_form_string), + ("enum_form_string", param_enum_form_string.map(|param| format!("{:?}", param))), ]; let body = serde_urlencoded::to_string(params).expect("impossible to fail to serialize"); @@ -1907,7 +1907,7 @@ impl Api for Client where async fn find_pets_by_status( &self, - param_status: &Vec, + param_status: &Vec, context: &C) -> Result { let mut client_service = self.client_service.clone(); diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs index 93d3dbb0e47..b910c9ae6b2 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/lib.rs @@ -397,13 +397,13 @@ pub trait Api { /// To test enum parameters async fn test_enum_parameters( &self, - enum_header_string_array: Option<&Vec>, - enum_header_string: Option, - enum_query_string_array: Option<&Vec>, - enum_query_string: Option, - enum_query_integer: Option, - enum_query_double: Option, - enum_form_string: Option, + enum_header_string_array: Option<&Vec>, + enum_header_string: Option, + enum_query_string_array: Option<&Vec>, + enum_query_string: Option, + enum_query_integer: Option, + enum_query_double: Option, + enum_form_string: Option, context: &C) -> Result; /// test inline additionalProperties @@ -439,7 +439,7 @@ pub trait Api { /// Finds Pets by status async fn find_pets_by_status( &self, - status: &Vec, + status: &Vec, context: &C) -> Result; /// Finds Pets by tags @@ -634,13 +634,13 @@ pub trait ApiNoContext { /// To test enum parameters async fn test_enum_parameters( &self, - enum_header_string_array: Option<&Vec>, - enum_header_string: Option, - enum_query_string_array: Option<&Vec>, - enum_query_string: Option, - enum_query_integer: Option, - enum_query_double: Option, - enum_form_string: Option, + enum_header_string_array: Option<&Vec>, + enum_header_string: Option, + enum_query_string_array: Option<&Vec>, + enum_query_string: Option, + enum_query_integer: Option, + enum_query_double: Option, + enum_form_string: Option, ) -> Result; /// test inline additionalProperties @@ -676,7 +676,7 @@ pub trait ApiNoContext { /// Finds Pets by status async fn find_pets_by_status( &self, - status: &Vec, + status: &Vec, ) -> Result; /// Finds Pets by tags @@ -925,13 +925,13 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex /// To test enum parameters async fn test_enum_parameters( &self, - enum_header_string_array: Option<&Vec>, - enum_header_string: Option, - enum_query_string_array: Option<&Vec>, - enum_query_string: Option, - enum_query_integer: Option, - enum_query_double: Option, - enum_form_string: Option, + enum_header_string_array: Option<&Vec>, + enum_header_string: Option, + enum_query_string_array: Option<&Vec>, + enum_query_string: Option, + enum_query_integer: Option, + enum_query_double: Option, + enum_form_string: Option, ) -> Result { let context = self.context().clone(); @@ -991,7 +991,7 @@ impl + Send + Sync, C: Clone + Send + Sync> ApiNoContext for Contex /// Finds Pets by status async fn find_pets_by_status( &self, - status: &Vec, + status: &Vec, ) -> Result { let context = self.context().clone(); diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs index c77a7acf838..ff6ade7e2b2 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/models.rs @@ -133,6 +133,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AdditionalPropertiesClass - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AdditionalPropertiesClass { /// Helper function to allow us to convert this model to an XML string. @@ -278,6 +323,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Animal - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Animal { /// Helper function to allow us to convert this model to an XML string. @@ -416,6 +506,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AnimalFarm - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl AnimalFarm { /// Helper function to allow us to convert this model to an XML string. @@ -583,6 +718,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ApiResponse - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ApiResponse { /// Helper function to allow us to convert this model to an XML string. @@ -709,6 +889,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ArrayOfArrayOfNumberOnly - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ArrayOfArrayOfNumberOnly { /// Helper function to allow us to convert this model to an XML string. @@ -841,6 +1066,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ArrayOfNumberOnly - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ArrayOfNumberOnly { /// Helper function to allow us to convert this model to an XML string. @@ -866,10 +1136,9 @@ pub struct ArrayTest { #[serde(skip_serializing_if="Option::is_none")] pub array_array_of_model: Option>>, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "array_of_enum")] #[serde(skip_serializing_if="Option::is_none")] - pub array_of_enum: Option>, + pub array_of_enum: Option>, } @@ -904,13 +1173,7 @@ impl std::string::ToString for ArrayTest { // Skipping array_array_of_model in query parameter serialization - - self.array_of_enum.as_ref().map(|array_of_enum| { - [ - "array_of_enum".to_string(), - array_of_enum.iter().map(|x| x.to_string()).collect::>().join(","), - ].join(",") - }), + // Skipping array_of_enum in query parameter serialization ]; @@ -932,7 +1195,7 @@ impl std::str::FromStr for ArrayTest { pub array_of_string: Vec>, pub array_array_of_integer: Vec>>, pub array_array_of_model: Vec>>, - pub array_of_enum: Vec>, + pub array_of_enum: Vec>, } let mut intermediate_rep = IntermediateRep::default(); @@ -1010,6 +1273,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ArrayTest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ArrayTest { /// Helper function to allow us to convert this model to an XML string. @@ -1229,6 +1537,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Capitalization - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Capitalization { /// Helper function to allow us to convert this model to an XML string. @@ -1391,6 +1744,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Cat - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Cat { /// Helper function to allow us to convert this model to an XML string. @@ -1542,6 +1940,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Category - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Category { /// Helper function to allow us to convert this model to an XML string. @@ -1676,6 +2119,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ClassModel - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ClassModel { /// Helper function to allow us to convert this model to an XML string. @@ -1809,6 +2297,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Client - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Client { /// Helper function to allow us to convert this model to an XML string. @@ -1971,6 +2504,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Dog - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Dog { /// Helper function to allow us to convert this model to an XML string. @@ -2105,6 +2683,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { /// Helper function to allow us to convert this model to an XML string. @@ -2118,20 +2741,17 @@ impl DollarSpecialLeftSquareBracketModelPeriodNameRightSquareBracket { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumArrays { - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "just_symbol")] #[serde(skip_serializing_if="Option::is_none")] - pub just_symbol: Option, + pub just_symbol: Option, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "array_enum")] #[serde(skip_serializing_if="Option::is_none")] - pub array_enum: Option>, + pub array_enum: Option>, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "array_array_enum")] #[serde(skip_serializing_if="Option::is_none")] - pub array_array_enum: Option>>, + pub array_array_enum: Option>>, } @@ -2153,21 +2773,9 @@ impl EnumArrays { impl std::string::ToString for EnumArrays { fn to_string(&self) -> String { let params: Vec> = vec![ + // Skipping just_symbol in query parameter serialization - self.just_symbol.as_ref().map(|just_symbol| { - [ - "just_symbol".to_string(), - just_symbol.to_string(), - ].join(",") - }), - - - self.array_enum.as_ref().map(|array_enum| { - [ - "array_enum".to_string(), - array_enum.iter().map(|x| x.to_string()).collect::>().join(","), - ].join(",") - }), + // Skipping array_enum in query parameter serialization // Skipping array_array_enum in query parameter serialization @@ -2188,9 +2796,9 @@ impl std::str::FromStr for EnumArrays { #[derive(Default)] #[allow(dead_code)] struct IntermediateRep { - pub just_symbol: Vec, - pub array_enum: Vec>, - pub array_array_enum: Vec>>, + pub just_symbol: Vec, + pub array_enum: Vec>, + pub array_array_enum: Vec>>, } let mut intermediate_rep = IntermediateRep::default(); @@ -2209,7 +2817,7 @@ impl std::str::FromStr for EnumArrays { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "just_symbol" => intermediate_rep.just_symbol.push(::from_str(val).map_err(|x| x.to_string())?), + "just_symbol" => intermediate_rep.just_symbol.push(::from_str(val).map_err(|x| x.to_string())?), "array_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in EnumArrays".to_string()), "array_array_enum" => return std::result::Result::Err("Parsing a container in this style is not supported in EnumArrays".to_string()), _ => return std::result::Result::Err("Unexpected key while parsing EnumArrays".to_string()) @@ -2267,6 +2875,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArrays - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl EnumArrays { /// Helper function to allow us to convert this model to an XML string. @@ -2277,6 +2930,390 @@ impl EnumArrays { } } +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum EnumArraysArrayArrayEnumInnerInner { + #[serde(rename = "Cat")] + Cat, + #[serde(rename = "Dog")] + Dog, +} + +impl std::fmt::Display for EnumArraysArrayArrayEnumInnerInner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + EnumArraysArrayArrayEnumInnerInner::Cat => write!(f, "Cat"), + EnumArraysArrayArrayEnumInnerInner::Dog => write!(f, "Dog"), + } + } +} + +impl std::str::FromStr for EnumArraysArrayArrayEnumInnerInner { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "Cat" => std::result::Result::Ok(EnumArraysArrayArrayEnumInnerInner::Cat), + "Dog" => std::result::Result::Ok(EnumArraysArrayArrayEnumInnerInner::Dog), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumArraysArrayArrayEnumInnerInner - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArraysArrayArrayEnumInnerInner - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArraysArrayArrayEnumInnerInner - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl EnumArraysArrayArrayEnumInnerInner { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum EnumArraysArrayEnumInner { + #[serde(rename = "fish")] + Fish, + #[serde(rename = "crab")] + Crab, +} + +impl std::fmt::Display for EnumArraysArrayEnumInner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + EnumArraysArrayEnumInner::Fish => write!(f, "fish"), + EnumArraysArrayEnumInner::Crab => write!(f, "crab"), + } + } +} + +impl std::str::FromStr for EnumArraysArrayEnumInner { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "fish" => std::result::Result::Ok(EnumArraysArrayEnumInner::Fish), + "crab" => std::result::Result::Ok(EnumArraysArrayEnumInner::Crab), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumArraysArrayEnumInner - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArraysArrayEnumInner - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArraysArrayEnumInner - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl EnumArraysArrayEnumInner { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum EnumArraysJustSymbol { + #[serde(rename = ">=")] + GreaterThanEqual, + #[serde(rename = "$")] + Dollar, +} + +impl std::fmt::Display for EnumArraysJustSymbol { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + EnumArraysJustSymbol::GreaterThanEqual => write!(f, ">="), + EnumArraysJustSymbol::Dollar => write!(f, "$"), + } + } +} + +impl std::str::FromStr for EnumArraysJustSymbol { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + ">=" => std::result::Result::Ok(EnumArraysJustSymbol::GreaterThanEqual), + "$" => std::result::Result::Ok(EnumArraysJustSymbol::Dollar), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumArraysJustSymbol - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArraysJustSymbol - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumArraysJustSymbol - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl EnumArraysJustSymbol { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + /// Enumeration of values. /// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` /// which helps with FFI. @@ -2316,6 +3353,90 @@ impl std::str::FromStr for EnumClass { } } +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumClass - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumClass - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumClass - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + impl EnumClass { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. @@ -2328,24 +3449,20 @@ impl EnumClass { #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct EnumTest { - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_string")] #[serde(skip_serializing_if="Option::is_none")] - pub enum_string: Option, + pub enum_string: Option, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_string_required")] - pub enum_string_required: String, + pub enum_string_required: models::EnumTestEnumString, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_integer")] #[serde(skip_serializing_if="Option::is_none")] - pub enum_integer: Option, + pub enum_integer: Option, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "enum_number")] #[serde(skip_serializing_if="Option::is_none")] - pub enum_number: Option, + pub enum_number: Option, #[serde(rename = "outerEnum")] #[serde(skip_serializing_if="Option::is_none")] @@ -2356,7 +3473,7 @@ pub struct EnumTest { impl EnumTest { #[allow(clippy::new_without_default)] - pub fn new(enum_string_required: String, ) -> EnumTest { + pub fn new(enum_string_required: models::EnumTestEnumString, ) -> EnumTest { EnumTest { enum_string: None, enum_string_required, @@ -2373,33 +3490,13 @@ impl EnumTest { impl std::string::ToString for EnumTest { fn to_string(&self) -> String { let params: Vec> = vec![ + // Skipping enum_string in query parameter serialization - self.enum_string.as_ref().map(|enum_string| { - [ - "enum_string".to_string(), - enum_string.to_string(), - ].join(",") - }), + // Skipping enum_string_required in query parameter serialization + // Skipping enum_integer in query parameter serialization - Some("enum_string_required".to_string()), - Some(self.enum_string_required.to_string()), - - - self.enum_integer.as_ref().map(|enum_integer| { - [ - "enum_integer".to_string(), - enum_integer.to_string(), - ].join(",") - }), - - - self.enum_number.as_ref().map(|enum_number| { - [ - "enum_number".to_string(), - enum_number.to_string(), - ].join(",") - }), + // Skipping enum_number in query parameter serialization // Skipping outerEnum in query parameter serialization @@ -2420,10 +3517,10 @@ impl std::str::FromStr for EnumTest { #[derive(Default)] #[allow(dead_code)] struct IntermediateRep { - pub enum_string: Vec, - pub enum_string_required: Vec, - pub enum_integer: Vec, - pub enum_number: Vec, + pub enum_string: Vec, + pub enum_string_required: Vec, + pub enum_integer: Vec, + pub enum_number: Vec, pub outer_enum: Vec, } @@ -2443,13 +3540,13 @@ impl std::str::FromStr for EnumTest { #[allow(clippy::match_single_binding)] match key { #[allow(clippy::redundant_clone)] - "enum_string" => intermediate_rep.enum_string.push(::from_str(val).map_err(|x| x.to_string())?), + "enum_string" => intermediate_rep.enum_string.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "enum_string_required" => intermediate_rep.enum_string_required.push(::from_str(val).map_err(|x| x.to_string())?), + "enum_string_required" => intermediate_rep.enum_string_required.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "enum_integer" => intermediate_rep.enum_integer.push(::from_str(val).map_err(|x| x.to_string())?), + "enum_integer" => intermediate_rep.enum_integer.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "enum_number" => intermediate_rep.enum_number.push(::from_str(val).map_err(|x| x.to_string())?), + "enum_number" => intermediate_rep.enum_number.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] "outerEnum" => intermediate_rep.outer_enum.push(::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing EnumTest".to_string()) @@ -2509,6 +3606,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumTest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl EnumTest { /// Helper function to allow us to convert this model to an XML string. @@ -2519,6 +3661,398 @@ impl EnumTest { } } +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum EnumTestEnumInteger { + #[serde(rename = "1")] + Variant1, + #[serde(rename = "-1")] + Variant12, +} + +impl std::fmt::Display for EnumTestEnumInteger { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + EnumTestEnumInteger::Variant1 => write!(f, "1"), + EnumTestEnumInteger::Variant12 => write!(f, "-1"), + } + } +} + +impl std::str::FromStr for EnumTestEnumInteger { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "1" => std::result::Result::Ok(EnumTestEnumInteger::Variant1), + "-1" => std::result::Result::Ok(EnumTestEnumInteger::Variant12), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumTestEnumInteger - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumTestEnumInteger - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumTestEnumInteger - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl EnumTestEnumInteger { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum EnumTestEnumString { + #[serde(rename = "UPPER")] + Upper, + #[serde(rename = "lower")] + Lower, + #[serde(rename = "")] + Empty, +} + +impl std::fmt::Display for EnumTestEnumString { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + EnumTestEnumString::Upper => write!(f, "UPPER"), + EnumTestEnumString::Lower => write!(f, "lower"), + EnumTestEnumString::Empty => write!(f, ""), + } + } +} + +impl std::str::FromStr for EnumTestEnumString { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "UPPER" => std::result::Result::Ok(EnumTestEnumString::Upper), + "lower" => std::result::Result::Ok(EnumTestEnumString::Lower), + "" => std::result::Result::Ok(EnumTestEnumString::Empty), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for EnumTestEnumString - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumTestEnumString - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into EnumTestEnumString - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl EnumTestEnumString { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum FindPetsByStatusStatusParameterInner { + #[serde(rename = "available")] + Available, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "sold")] + Sold, +} + +impl std::fmt::Display for FindPetsByStatusStatusParameterInner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + FindPetsByStatusStatusParameterInner::Available => write!(f, "available"), + FindPetsByStatusStatusParameterInner::Pending => write!(f, "pending"), + FindPetsByStatusStatusParameterInner::Sold => write!(f, "sold"), + } + } +} + +impl std::str::FromStr for FindPetsByStatusStatusParameterInner { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "available" => std::result::Result::Ok(FindPetsByStatusStatusParameterInner::Available), + "pending" => std::result::Result::Ok(FindPetsByStatusStatusParameterInner::Pending), + "sold" => std::result::Result::Ok(FindPetsByStatusStatusParameterInner::Sold), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for FindPetsByStatusStatusParameterInner - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into FindPetsByStatusStatusParameterInner - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into FindPetsByStatusStatusParameterInner - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl FindPetsByStatusStatusParameterInner { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct FormatTest { @@ -2842,6 +4376,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into FormatTest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl FormatTest { /// Helper function to allow us to convert this model to an XML string. @@ -2992,6 +4571,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into HasOnlyReadOnly - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl HasOnlyReadOnly { /// Helper function to allow us to convert this model to an XML string. @@ -3125,6 +4749,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into List - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl List { /// Helper function to allow us to convert this model to an XML string. @@ -3142,15 +4811,13 @@ pub struct MapTest { #[serde(skip_serializing_if="Option::is_none")] pub map_map_of_string: Option>>, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "map_map_of_enum")] #[serde(skip_serializing_if="Option::is_none")] - pub map_map_of_enum: Option>>, + pub map_map_of_enum: Option>>, - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "map_of_enum_string")] #[serde(skip_serializing_if="Option::is_none")] - pub map_of_enum_string: Option>, + pub map_of_enum_string: Option>, } @@ -3179,6 +4846,7 @@ impl std::string::ToString for MapTest { // Skipping map_map_of_enum in query parameter serialization // Skipping map_of_enum_string in query parameter serialization + // Skipping map_of_enum_string in query parameter serialization ]; @@ -3198,8 +4866,8 @@ impl std::str::FromStr for MapTest { #[allow(dead_code)] struct IntermediateRep { pub map_map_of_string: Vec>>, - pub map_map_of_enum: Vec>>, - pub map_of_enum_string: Vec>, + pub map_map_of_enum: Vec>>, + pub map_of_enum_string: Vec>, } let mut intermediate_rep = IntermediateRep::default(); @@ -3275,6 +4943,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MapTest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl MapTest { /// Helper function to allow us to convert this model to an XML string. @@ -3285,6 +4998,134 @@ impl MapTest { } } +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum MapTestMapMapOfEnumValueValue { + #[serde(rename = "UPPER")] + Upper, + #[serde(rename = "lower")] + Lower, +} + +impl std::fmt::Display for MapTestMapMapOfEnumValueValue { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + MapTestMapMapOfEnumValueValue::Upper => write!(f, "UPPER"), + MapTestMapMapOfEnumValueValue::Lower => write!(f, "lower"), + } + } +} + +impl std::str::FromStr for MapTestMapMapOfEnumValueValue { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "UPPER" => std::result::Result::Ok(MapTestMapMapOfEnumValueValue::Upper), + "lower" => std::result::Result::Ok(MapTestMapMapOfEnumValueValue::Lower), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for MapTestMapMapOfEnumValueValue - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MapTestMapMapOfEnumValueValue - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MapTestMapMapOfEnumValueValue - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl MapTestMapMapOfEnumValueValue { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct MixedPropertiesAndAdditionalPropertiesClass { @@ -3424,6 +5265,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into MixedPropertiesAndAdditionalPropertiesClass - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl MixedPropertiesAndAdditionalPropertiesClass { /// Helper function to allow us to convert this model to an XML string. @@ -3576,6 +5462,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Model200Response - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Model200Response { /// Helper function to allow us to convert this model to an XML string. @@ -3757,6 +5688,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Name - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Name { /// Helper function to allow us to convert this model to an XML string. @@ -3890,6 +5866,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into NumberOnly - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl NumberOnly { /// Helper function to allow us to convert this model to an XML string. @@ -4017,6 +6038,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectContainingObjectWithOnlyAdditionalProperties - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ObjectContainingObjectWithOnlyAdditionalProperties { /// Helper function to allow us to convert this model to an XML string. @@ -4061,7 +6127,7 @@ impl std::ops::DerefMut for ObjectWithOnlyAdditionalProperties { /// Should be implemented in a serde serializer impl ::std::string::ToString for ObjectWithOnlyAdditionalProperties { fn to_string(&self) -> String { - // Skipping additionalProperties in query parameter serialization + // ToString for this model is not supported "".to_string() } } @@ -4073,7 +6139,91 @@ impl ::std::str::FromStr for ObjectWithOnlyAdditionalProperties { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err("Parsing additionalProperties for ObjectWithOnlyAdditionalProperties is not supported") + std::result::Result::Err("Parsing ObjectWithOnlyAdditionalProperties is not supported") + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for ObjectWithOnlyAdditionalProperties - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectWithOnlyAdditionalProperties - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectWithOnlyAdditionalProperties - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } } } @@ -4106,11 +6256,9 @@ pub struct Order { #[serde(skip_serializing_if="Option::is_none")] pub ship_date: Option>, - /// Order Status - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "status")] #[serde(skip_serializing_if="Option::is_none")] - pub status: Option, + pub status: Option, #[serde(rename = "complete")] #[serde(skip_serializing_if="Option::is_none")] @@ -4165,13 +6313,7 @@ impl std::string::ToString for Order { // Skipping shipDate in query parameter serialization - - self.status.as_ref().map(|status| { - [ - "status".to_string(), - status.to_string(), - ].join(",") - }), + // Skipping status in query parameter serialization self.complete.as_ref().map(|complete| { @@ -4202,7 +6344,7 @@ impl std::str::FromStr for Order { pub pet_id: Vec, pub quantity: Vec, pub ship_date: Vec>, - pub status: Vec, + pub status: Vec, pub complete: Vec, } @@ -4230,7 +6372,7 @@ impl std::str::FromStr for Order { #[allow(clippy::redundant_clone)] "shipDate" => intermediate_rep.ship_date.push( as std::str::FromStr>::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] - "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), + "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), #[allow(clippy::redundant_clone)] "complete" => intermediate_rep.complete.push(::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Order".to_string()) @@ -4291,6 +6433,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Order - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Order { /// Helper function to allow us to convert this model to an XML string. @@ -4301,6 +6488,139 @@ impl Order { } } +/// Order Status +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum OrderStatus { + #[serde(rename = "placed")] + Placed, + #[serde(rename = "approved")] + Approved, + #[serde(rename = "delivered")] + Delivered, +} + +impl std::fmt::Display for OrderStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + OrderStatus::Placed => write!(f, "placed"), + OrderStatus::Approved => write!(f, "approved"), + OrderStatus::Delivered => write!(f, "delivered"), + } + } +} + +impl std::str::FromStr for OrderStatus { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "placed" => std::result::Result::Ok(OrderStatus::Placed), + "approved" => std::result::Result::Ok(OrderStatus::Approved), + "delivered" => std::result::Result::Ok(OrderStatus::Delivered), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for OrderStatus - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OrderStatus - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OrderStatus - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl OrderStatus { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + #[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct OuterBoolean(bool); @@ -4330,6 +6650,112 @@ impl std::ops::DerefMut for OuterBoolean { } } +/// Converts the OuterBoolean value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for OuterBoolean { + fn to_string(&self) -> String { + self.0.to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a OuterBoolean value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for OuterBoolean { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match std::str::FromStr::from_str(s) { + std::result::Result::Ok(r) => std::result::Result::Ok(OuterBoolean(r)), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {} to OuterBoolean: {:?}", s, e)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for OuterBoolean - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterBoolean - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterBoolean - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl OuterBoolean { /// Helper function to allow us to convert this model to an XML string. @@ -4497,6 +6923,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterComposite - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl OuterComposite { /// Helper function to allow us to convert this model to an XML string. @@ -4546,6 +7017,90 @@ impl std::str::FromStr for OuterEnum { } } +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for OuterEnum - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterEnum - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterEnum - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + impl OuterEnum { /// Helper function to allow us to convert this model to an XML string. /// Will panic if serialisation fails. @@ -4584,6 +7139,112 @@ impl std::ops::DerefMut for OuterNumber { } } +/// Converts the OuterNumber value to the Query Parameters representation (style=form, explode=false) +/// specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde serializer +impl ::std::string::ToString for OuterNumber { + fn to_string(&self) -> String { + self.0.to_string() + } +} + +/// Converts Query Parameters representation (style=form, explode=false) to a OuterNumber value +/// as specified in https://swagger.io/docs/specification/serialization/ +/// Should be implemented in a serde deserializer +impl ::std::str::FromStr for OuterNumber { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match std::str::FromStr::from_str(s) { + std::result::Result::Ok(r) => std::result::Result::Ok(OuterNumber(r)), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {} to OuterNumber: {:?}", s, e)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for OuterNumber - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterNumber - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterNumber - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl OuterNumber { /// Helper function to allow us to convert this model to an XML string. @@ -4604,19 +7265,6 @@ impl std::convert::From for OuterString { } } -impl std::string::ToString for OuterString { - fn to_string(&self) -> String { - self.0.to_string() - } -} - -impl std::str::FromStr for OuterString { - type Err = std::string::ParseError; - fn from_str(x: &str) -> std::result::Result { - std::result::Result::Ok(OuterString(x.to_string())) - } -} - impl std::convert::From for String { fn from(x: OuterString) -> Self { x.0 @@ -4636,6 +7284,102 @@ impl std::ops::DerefMut for OuterString { } } +impl std::string::ToString for OuterString { + fn to_string(&self) -> String { + self.0.clone() + } +} + +impl std::str::FromStr for OuterString { + type Err = ::std::convert::Infallible; + fn from_str(x: &str) -> std::result::Result { + std::result::Result::Ok(OuterString(x.to_owned())) + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for OuterString - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterString - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into OuterString - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl OuterString { /// Helper function to allow us to convert this model to an XML string. @@ -4668,11 +7412,9 @@ pub struct Pet { #[serde(skip_serializing_if="Option::is_none")] pub tags: Option>, - /// pet status in the store - // Note: inline enums are not fully supported by openapi-generator #[serde(rename = "status")] #[serde(skip_serializing_if="Option::is_none")] - pub status: Option, + pub status: Option, } @@ -4717,13 +7459,7 @@ impl std::string::ToString for Pet { // Skipping tags in query parameter serialization - - self.status.as_ref().map(|status| { - [ - "status".to_string(), - status.to_string(), - ].join(",") - }), + // Skipping status in query parameter serialization ]; @@ -4747,7 +7483,7 @@ impl std::str::FromStr for Pet { pub name: Vec, pub photo_urls: Vec>, pub tags: Vec>, - pub status: Vec, + pub status: Vec, } let mut intermediate_rep = IntermediateRep::default(); @@ -4774,7 +7510,7 @@ impl std::str::FromStr for Pet { "photoUrls" => return std::result::Result::Err("Parsing a container in this style is not supported in Pet".to_string()), "tags" => return std::result::Result::Err("Parsing a container in this style is not supported in Pet".to_string()), #[allow(clippy::redundant_clone)] - "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), + "status" => intermediate_rep.status.push(::from_str(val).map_err(|x| x.to_string())?), _ => return std::result::Result::Err("Unexpected key while parsing Pet".to_string()) } } @@ -4833,6 +7569,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Pet - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Pet { /// Helper function to allow us to convert this model to an XML string. @@ -4843,6 +7624,139 @@ impl Pet { } } +/// pet status in the store +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum PetStatus { + #[serde(rename = "available")] + Available, + #[serde(rename = "pending")] + Pending, + #[serde(rename = "sold")] + Sold, +} + +impl std::fmt::Display for PetStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + PetStatus::Available => write!(f, "available"), + PetStatus::Pending => write!(f, "pending"), + PetStatus::Sold => write!(f, "sold"), + } + } +} + +impl std::str::FromStr for PetStatus { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "available" => std::result::Result::Ok(PetStatus::Available), + "pending" => std::result::Result::Ok(PetStatus::Pending), + "sold" => std::result::Result::Ok(PetStatus::Sold), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for PetStatus - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into PetStatus - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into PetStatus - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl PetStatus { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct ReadOnlyFirst { @@ -4983,6 +7897,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ReadOnlyFirst - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl ReadOnlyFirst { /// Helper function to allow us to convert this model to an XML string. @@ -5118,6 +8077,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Return - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Return { /// Helper function to allow us to convert this model to an XML string. @@ -5269,6 +8273,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into Tag - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl Tag { /// Helper function to allow us to convert this model to an XML string. @@ -5279,6 +8328,655 @@ impl Tag { } } +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum TestEnumParametersEnumHeaderStringArrayParameterInner { + #[serde(rename = ">")] + GreaterThan, + #[serde(rename = "$")] + Dollar, +} + +impl std::fmt::Display for TestEnumParametersEnumHeaderStringArrayParameterInner { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + TestEnumParametersEnumHeaderStringArrayParameterInner::GreaterThan => write!(f, ">"), + TestEnumParametersEnumHeaderStringArrayParameterInner::Dollar => write!(f, "$"), + } + } +} + +impl std::str::FromStr for TestEnumParametersEnumHeaderStringArrayParameterInner { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + ">" => std::result::Result::Ok(TestEnumParametersEnumHeaderStringArrayParameterInner::GreaterThan), + "$" => std::result::Result::Ok(TestEnumParametersEnumHeaderStringArrayParameterInner::Dollar), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for TestEnumParametersEnumHeaderStringArrayParameterInner - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumHeaderStringArrayParameterInner - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumHeaderStringArrayParameterInner - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl TestEnumParametersEnumHeaderStringArrayParameterInner { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum TestEnumParametersEnumHeaderStringParameter { + #[serde(rename = "_abc")] + Abc, + #[serde(rename = "-efg")] + Efg, + #[serde(rename = "(xyz)")] + LeftParenthesisXyzRightParenthesis, +} + +impl std::fmt::Display for TestEnumParametersEnumHeaderStringParameter { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + TestEnumParametersEnumHeaderStringParameter::Abc => write!(f, "_abc"), + TestEnumParametersEnumHeaderStringParameter::Efg => write!(f, "-efg"), + TestEnumParametersEnumHeaderStringParameter::LeftParenthesisXyzRightParenthesis => write!(f, "(xyz)"), + } + } +} + +impl std::str::FromStr for TestEnumParametersEnumHeaderStringParameter { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "_abc" => std::result::Result::Ok(TestEnumParametersEnumHeaderStringParameter::Abc), + "-efg" => std::result::Result::Ok(TestEnumParametersEnumHeaderStringParameter::Efg), + "(xyz)" => std::result::Result::Ok(TestEnumParametersEnumHeaderStringParameter::LeftParenthesisXyzRightParenthesis), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for TestEnumParametersEnumHeaderStringParameter - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumHeaderStringParameter - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumHeaderStringParameter - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl TestEnumParametersEnumHeaderStringParameter { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum TestEnumParametersEnumQueryDoubleParameter { + #[serde(rename = "1.1")] + Variant1Period1, + #[serde(rename = "-1.2")] + Variant1Period2, +} + +impl std::fmt::Display for TestEnumParametersEnumQueryDoubleParameter { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + TestEnumParametersEnumQueryDoubleParameter::Variant1Period1 => write!(f, "1.1"), + TestEnumParametersEnumQueryDoubleParameter::Variant1Period2 => write!(f, "-1.2"), + } + } +} + +impl std::str::FromStr for TestEnumParametersEnumQueryDoubleParameter { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "1.1" => std::result::Result::Ok(TestEnumParametersEnumQueryDoubleParameter::Variant1Period1), + "-1.2" => std::result::Result::Ok(TestEnumParametersEnumQueryDoubleParameter::Variant1Period2), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for TestEnumParametersEnumQueryDoubleParameter - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumQueryDoubleParameter - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumQueryDoubleParameter - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl TestEnumParametersEnumQueryDoubleParameter { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum TestEnumParametersEnumQueryIntegerParameter { + #[serde(rename = "1")] + Variant1, + #[serde(rename = "-2")] + Variant2, +} + +impl std::fmt::Display for TestEnumParametersEnumQueryIntegerParameter { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + TestEnumParametersEnumQueryIntegerParameter::Variant1 => write!(f, "1"), + TestEnumParametersEnumQueryIntegerParameter::Variant2 => write!(f, "-2"), + } + } +} + +impl std::str::FromStr for TestEnumParametersEnumQueryIntegerParameter { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "1" => std::result::Result::Ok(TestEnumParametersEnumQueryIntegerParameter::Variant1), + "-2" => std::result::Result::Ok(TestEnumParametersEnumQueryIntegerParameter::Variant2), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for TestEnumParametersEnumQueryIntegerParameter - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumQueryIntegerParameter - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersEnumQueryIntegerParameter - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl TestEnumParametersEnumQueryIntegerParameter { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + +/// Form parameter enum test (string) +/// Enumeration of values. +/// Since this enum's variants do not hold data, we can easily define them as `#[repr(C)]` +/// which helps with FFI. +#[allow(non_camel_case_types)] +#[repr(C)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))] +pub enum TestEnumParametersRequestEnumFormString { + #[serde(rename = "_abc")] + Abc, + #[serde(rename = "-efg")] + Efg, + #[serde(rename = "(xyz)")] + LeftParenthesisXyzRightParenthesis, +} + +impl std::fmt::Display for TestEnumParametersRequestEnumFormString { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + TestEnumParametersRequestEnumFormString::Abc => write!(f, "_abc"), + TestEnumParametersRequestEnumFormString::Efg => write!(f, "-efg"), + TestEnumParametersRequestEnumFormString::LeftParenthesisXyzRightParenthesis => write!(f, "(xyz)"), + } + } +} + +impl std::str::FromStr for TestEnumParametersRequestEnumFormString { + type Err = String; + + fn from_str(s: &str) -> std::result::Result { + match s { + "_abc" => std::result::Result::Ok(TestEnumParametersRequestEnumFormString::Abc), + "-efg" => std::result::Result::Ok(TestEnumParametersRequestEnumFormString::Efg), + "(xyz)" => std::result::Result::Ok(TestEnumParametersRequestEnumFormString::LeftParenthesisXyzRightParenthesis), + _ => std::result::Result::Err(format!("Value not valid: {}", s)), + } + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for TestEnumParametersRequestEnumFormString - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersRequestEnumFormString - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into TestEnumParametersRequestEnumFormString - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} + +impl TestEnumParametersRequestEnumFormString { + /// Helper function to allow us to convert this model to an XML string. + /// Will panic if serialisation fails. + #[allow(dead_code)] + pub(crate) fn as_xml(&self) -> String { + serde_xml_rs::to_string(&self).expect("impossible to fail to serialize") + } +} + #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] #[serde(rename = "User")] @@ -5523,6 +9221,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into User - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} impl User { /// Helper function to allow us to convert this model to an XML string. diff --git a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs index 1de6df73bc7..b0d83b6a727 100644 --- a/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/server/mod.rs @@ -1012,7 +1012,7 @@ impl hyper::service::Service<(Request, C)> for Service where let param_enum_header_string_array = headers.get(HeaderName::from_static("enum_header_string_array")); let param_enum_header_string_array = match param_enum_header_string_array { - Some(v) => match header::IntoHeaderValue::>::try_from((*v).clone()) { + Some(v) => match header::IntoHeaderValue::>::try_from((*v).clone()) { Ok(result) => Some(result.0), Err(err) => { @@ -1030,7 +1030,7 @@ impl hyper::service::Service<(Request, C)> for Service where let param_enum_header_string = headers.get(HeaderName::from_static("enum_header_string")); let param_enum_header_string = match param_enum_header_string { - Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { + Some(v) => match header::IntoHeaderValue::::try_from((*v).clone()) { Ok(result) => Some(result.0), Err(err) => { @@ -1061,7 +1061,7 @@ impl hyper::service::Service<(Request, C)> for Service where let param_enum_query_string = match param_enum_query_string { Some(param_enum_query_string) => { let param_enum_query_string = - ::from_str + ::from_str (¶m_enum_query_string); match param_enum_query_string { Ok(param_enum_query_string) => Some(param_enum_query_string), @@ -1078,7 +1078,7 @@ impl hyper::service::Service<(Request, C)> for Service where let param_enum_query_integer = match param_enum_query_integer { Some(param_enum_query_integer) => { let param_enum_query_integer = - ::from_str + ::from_str (¶m_enum_query_integer); match param_enum_query_integer { Ok(param_enum_query_integer) => Some(param_enum_query_integer), @@ -1095,7 +1095,7 @@ impl hyper::service::Service<(Request, C)> for Service where let param_enum_query_double = match param_enum_query_double { Some(param_enum_query_double) => { let param_enum_query_double = - ::from_str + ::from_str (¶m_enum_query_double); match param_enum_query_double { Ok(param_enum_query_double) => Some(param_enum_query_double), @@ -1116,7 +1116,7 @@ impl hyper::service::Service<(Request, C)> for Service where Ok(body) => { // Form parameters let param_enum_form_string = - Some("enum_form_string_example".to_string()); + None; let result = api_impl.test_enum_parameters( diff --git a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs index 0915bf515e2..1d6e6f7be63 100644 --- a/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs +++ b/samples/server/petstore/rust-server/output/rust-server-test/src/models.rs @@ -141,6 +141,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ANullableContainer - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} /// An additionalPropertiesObject #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -177,7 +222,7 @@ impl std::ops::DerefMut for AdditionalPropertiesObject { /// Should be implemented in a serde serializer impl ::std::string::ToString for AdditionalPropertiesObject { fn to_string(&self) -> String { - // Skipping additionalProperties in query parameter serialization + // ToString for this model is not supported "".to_string() } } @@ -189,7 +234,91 @@ impl ::std::str::FromStr for AdditionalPropertiesObject { type Err = &'static str; fn from_str(s: &str) -> std::result::Result { - std::result::Result::Err("Parsing additionalProperties for AdditionalPropertiesObject is not supported") + std::result::Result::Err("Parsing AdditionalPropertiesObject is not supported") + } +} + +// Methods for converting between header::IntoHeaderValue and hyper::header::HeaderValue + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_value: header::IntoHeaderValue) -> std::result::Result { + let hdr_value = hdr_value.to_string(); + match hyper::header::HeaderValue::from_str(&hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(e) => std::result::Result::Err( + format!("Invalid header value for AdditionalPropertiesObject - value: {} is invalid {}", + hdr_value, e)) + } + } +} + +#[cfg(any(feature = "client", feature = "server"))] +impl std::convert::TryFrom for header::IntoHeaderValue { + type Error = String; + + fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result { + match hdr_value.to_str() { + std::result::Result::Ok(value) => { + match ::from_str(value) { + std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AdditionalPropertiesObject - {}", + value, err)) + } + }, + std::result::Result::Err(e) => std::result::Result::Err( + format!("Unable to convert header: {:?} to string: {}", + hdr_value, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AdditionalPropertiesObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } } } @@ -333,6 +462,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into AllOfObject - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -457,6 +631,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into BaseAllOf - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -593,6 +812,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into DummyPutRequest - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} /// structured response #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] @@ -719,6 +983,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into GetYamlResponse - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} /// An object of objects #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] @@ -838,6 +1147,51 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectOfObjects - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, validator::Validate)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] @@ -974,3 +1328,48 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } +#[cfg(feature = "server")] +impl std::convert::TryFrom>> for hyper::header::HeaderValue { + type Error = String; + + fn try_from(hdr_values: header::IntoHeaderValue>) -> std::result::Result { + let hdr_values : Vec = hdr_values.0.into_iter().map(|hdr_value| { + hdr_value.to_string() + }).collect(); + + match hyper::header::HeaderValue::from_str(&hdr_values.join(", ")) { + std::result::Result::Ok(hdr_value) => std::result::Result::Ok(hdr_value), + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to convert {:?} into a header - {}", + hdr_values, e)) + } + } +} + +#[cfg(feature = "server")] +impl std::convert::TryFrom for header::IntoHeaderValue> { + type Error = String; + + fn try_from(hdr_values: hyper::header::HeaderValue) -> std::result::Result { + match hdr_values.to_str() { + std::result::Result::Ok(hdr_values) => { + let hdr_values : std::vec::Vec = hdr_values + .split(',') + .filter_map(|hdr_value| match hdr_value.trim() { + "" => std::option::Option::None, + hdr_value => std::option::Option::Some({ + match ::from_str(hdr_value) { + std::result::Result::Ok(value) => std::result::Result::Ok(value), + std::result::Result::Err(err) => std::result::Result::Err( + format!("Unable to convert header value '{}' into ObjectOfObjectsInner - {}", + hdr_value, err)) + } + }) + }).collect::, String>>()?; + + std::result::Result::Ok(header::IntoHeaderValue(hdr_values)) + }, + std::result::Result::Err(e) => std::result::Result::Err(format!("Unable to parse header: {:?} as a string - {}", + hdr_values, e)), + } + } +}