diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 022d420e73c..d75476aa29a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -5300,6 +5300,83 @@ public class DefaultCodegen implements CodegenConfig { return codegenParameter; } + private void addBodyModelSchema(CodegenParameter codegenParameter, String name, Schema schema, Set imports, String bodyParameterName, boolean forceSimpleRef) { + CodegenModel codegenModel = null; + if (StringUtils.isNotBlank(name)) { + schema.setName(name); + codegenModel = fromModel(name, schema); + } + if (codegenModel != null) { + codegenParameter.isModel = true; + } + + if (codegenModel != null && (codegenModel.hasVars || forceSimpleRef)) { + if (StringUtils.isEmpty(bodyParameterName)) { + codegenParameter.baseName = codegenModel.classname; + } else { + codegenParameter.baseName = bodyParameterName; + } + codegenParameter.paramName = toParamName(codegenParameter.baseName); + codegenParameter.baseType = codegenModel.classname; + codegenParameter.dataType = getTypeDeclaration(codegenModel.classname); + codegenParameter.description = codegenModel.description; + imports.add(codegenParameter.baseType); + } else { + CodegenProperty codegenProperty = fromProperty("property", schema); + + if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) { + List parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| ")); + imports.addAll(parts); + String codegenModelName = codegenProperty.getComplexType(); + codegenParameter.baseName = codegenModelName; + codegenParameter.paramName = toParamName(codegenParameter.baseName); + codegenParameter.baseType = codegenParameter.baseName; + codegenParameter.dataType = getTypeDeclaration(codegenModelName); + codegenParameter.description = codegenProperty.getDescription(); + } else { + if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map + LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue."); + } else if (codegenProperty != null) { + String codegenModelName, codegenModelDescription; + + if (codegenModel != null) { + codegenModelName = codegenModel.classname; + codegenModelDescription = codegenModel.description; + } else { + LOGGER.warn("The following schema has undefined (null) baseType. " + + "It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " + + "A correct 'consumes' for form parameters should be " + + "'application/x-www-form-urlencoded' or 'multipart/?'"); + LOGGER.warn("schema: " + schema); + LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE"); + codegenModelName = "UNKNOWN_BASE_TYPE"; + codegenModelDescription = "UNKNOWN_DESCRIPTION"; + } + + if (StringUtils.isEmpty(bodyParameterName)) { + codegenParameter.baseName = codegenModelName; + } else { + codegenParameter.baseName = bodyParameterName; + } + + codegenParameter.paramName = toParamName(codegenParameter.baseName); + codegenParameter.baseType = codegenModelName; + codegenParameter.dataType = getTypeDeclaration(codegenModelName); + codegenParameter.description = codegenModelDescription; + imports.add(codegenParameter.baseType); + + if (codegenProperty.complexType != null) { + imports.add(codegenProperty.complexType); + } + } + } + + setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty); + // set nullable + setParameterNullable(codegenParameter, codegenProperty); + } + } + public CodegenParameter fromRequestBody(RequestBody body, Set imports, String bodyParameterName) { if (body == null) { LOGGER.error("body in fromRequestBody cannot be null!"); @@ -5328,84 +5405,91 @@ public class DefaultCodegen implements CodegenConfig { if (ModelUtils.isMapSchema(schema)) { // Schema with additionalproperties: true (including composed schemas with additionalproperties: true) - Schema inner = ModelUtils.getAdditionalProperties(schema); - if (inner == null) { - LOGGER.error("No inner type supplied for map parameter `{}`. Default to type:string", schema.getName()); - inner = new StringSchema().description("//TODO automatically added by openapi-generator"); - schema.setAdditionalProperties(inner); - } - CodegenProperty codegenProperty = fromProperty("property", schema); - - imports.add(codegenProperty.baseType); - - CodegenProperty innerCp = codegenProperty; - while (innerCp != null) { - if (innerCp.complexType != null) { - imports.add(innerCp.complexType); - } - innerCp = innerCp.items; - } - - if (StringUtils.isEmpty(bodyParameterName)) { - codegenParameter.baseName = "request_body"; + if (ModelUtils.isGenerateAliasAsModel() && StringUtils.isNotBlank(name)) { + this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true); } else { - codegenParameter.baseName = bodyParameterName; - } - codegenParameter.paramName = toParamName(codegenParameter.baseName); - codegenParameter.items = codegenProperty.items; - codegenParameter.mostInnerItems = codegenProperty.mostInnerItems; - codegenParameter.dataType = getTypeDeclaration(schema); - codegenParameter.baseType = getSchemaType(inner); - codegenParameter.isContainer = Boolean.TRUE; - codegenParameter.isMapContainer = Boolean.TRUE; - - setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty); - - // set nullable - setParameterNullable(codegenParameter, codegenProperty); - } else if (ModelUtils.isArraySchema(schema)) { - final ArraySchema arraySchema = (ArraySchema) schema; - Schema inner = getSchemaItems(arraySchema); - CodegenProperty codegenProperty = fromProperty("property", arraySchema); - imports.add(codegenProperty.baseType); - CodegenProperty innerCp = codegenProperty; - CodegenProperty mostInnerItem = innerCp; - // loop through multidimensional array to add proper import - // also find the most inner item - while (innerCp != null) { - if (innerCp.complexType != null) { - imports.add(innerCp.complexType); + Schema inner = ModelUtils.getAdditionalProperties(schema); + if (inner == null) { + LOGGER.error("No inner type supplied for map parameter `{}`. Default to type:string", schema.getName()); + inner = new StringSchema().description("//TODO automatically added by openapi-generator"); + schema.setAdditionalProperties(inner); } - mostInnerItem = innerCp; - innerCp = innerCp.items; - } + CodegenProperty codegenProperty = fromProperty("property", schema); - if (StringUtils.isEmpty(bodyParameterName)) { - if (StringUtils.isEmpty(mostInnerItem.complexType)) { + imports.add(codegenProperty.baseType); + + CodegenProperty innerCp = codegenProperty; + while (innerCp != null) { + if (innerCp.complexType != null) { + imports.add(innerCp.complexType); + } + innerCp = innerCp.items; + } + + if (StringUtils.isEmpty(bodyParameterName)) { codegenParameter.baseName = "request_body"; } else { - codegenParameter.baseName = mostInnerItem.complexType; + codegenParameter.baseName = bodyParameterName; } + codegenParameter.paramName = toParamName(codegenParameter.baseName); + codegenParameter.items = codegenProperty.items; + codegenParameter.mostInnerItems = codegenProperty.mostInnerItems; + codegenParameter.dataType = getTypeDeclaration(schema); + codegenParameter.baseType = getSchemaType(inner); + codegenParameter.isContainer = Boolean.TRUE; + codegenParameter.isMapContainer = Boolean.TRUE; + + setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty); + + // set nullable + setParameterNullable(codegenParameter, codegenProperty); + } + } else if (ModelUtils.isArraySchema(schema)) { + if (ModelUtils.isGenerateAliasAsModel() && StringUtils.isNotBlank(name)) { + this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, true); } else { - codegenParameter.baseName = bodyParameterName; - } - codegenParameter.paramName = toArrayModelParamName(codegenParameter.baseName); - codegenParameter.items = codegenProperty.items; - codegenParameter.mostInnerItems = codegenProperty.mostInnerItems; - codegenParameter.dataType = getTypeDeclaration(arraySchema); - codegenParameter.baseType = getSchemaType(inner); - codegenParameter.isContainer = Boolean.TRUE; - codegenParameter.isListContainer = Boolean.TRUE; - - setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty); - // set nullable - setParameterNullable(codegenParameter, codegenProperty); - - while (codegenProperty != null) { + final ArraySchema arraySchema = (ArraySchema) schema; + Schema inner = getSchemaItems(arraySchema); + CodegenProperty codegenProperty = fromProperty("property", arraySchema); imports.add(codegenProperty.baseType); - codegenProperty = codegenProperty.items; - } + CodegenProperty innerCp = codegenProperty; + CodegenProperty mostInnerItem = innerCp; + // loop through multidimensional array to add proper import + // also find the most inner item + while (innerCp != null) { + if (innerCp.complexType != null) { + imports.add(innerCp.complexType); + } + mostInnerItem = innerCp; + innerCp = innerCp.items; + } + if (StringUtils.isEmpty(bodyParameterName)) { + if (StringUtils.isEmpty(mostInnerItem.complexType)) { + codegenParameter.baseName = "request_body"; + } else { + codegenParameter.baseName = mostInnerItem.complexType; + } + } else { + codegenParameter.baseName = bodyParameterName; + } + codegenParameter.paramName = toArrayModelParamName(codegenParameter.baseName); + codegenParameter.items = codegenProperty.items; + codegenParameter.mostInnerItems = codegenProperty.mostInnerItems; + codegenParameter.dataType = getTypeDeclaration(arraySchema); + codegenParameter.baseType = getSchemaType(inner); + codegenParameter.isContainer = Boolean.TRUE; + codegenParameter.isListContainer = Boolean.TRUE; + + setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty); + // set nullable + setParameterNullable(codegenParameter, codegenProperty); + + while (codegenProperty != null) { + imports.add(codegenProperty.baseType); + codegenProperty = codegenProperty.items; + } + } } else if (ModelUtils.isFreeFormObject(schema)) { // HTTP request body is free form object CodegenProperty codegenProperty = fromProperty("FREE_FORM_REQUEST_BODY", schema); @@ -5426,81 +5510,7 @@ public class DefaultCodegen implements CodegenConfig { setParameterNullable(codegenParameter, codegenProperty); } else if (ModelUtils.isObjectSchema(schema) || ModelUtils.isComposedSchema(schema)) { - CodegenModel codegenModel = null; - if (StringUtils.isNotBlank(name)) { - schema.setName(name); - codegenModel = fromModel(name, schema); - } - if (codegenModel != null) { - codegenParameter.isModel = true; - } - - if (codegenModel != null && !codegenModel.emptyVars) { - if (StringUtils.isEmpty(bodyParameterName)) { - codegenParameter.baseName = codegenModel.classname; - } else { - codegenParameter.baseName = bodyParameterName; - } - codegenParameter.paramName = toParamName(codegenParameter.baseName); - codegenParameter.baseType = codegenModel.classname; - codegenParameter.dataType = getTypeDeclaration(codegenModel.classname); - codegenParameter.description = codegenModel.description; - imports.add(codegenParameter.baseType); - } else { - CodegenProperty codegenProperty = fromProperty("property", schema); - - if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) { - List parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| ")); - imports.addAll(parts); - String codegenModelName = codegenProperty.getComplexType(); - codegenParameter.baseName = codegenModelName; - codegenParameter.paramName = toParamName(codegenParameter.baseName); - codegenParameter.baseType = codegenParameter.baseName; - codegenParameter.dataType = getTypeDeclaration(codegenModelName); - codegenParameter.description = codegenProperty.getDescription(); - } else { - if (ModelUtils.getAdditionalProperties(schema) != null) {// http body is map - LOGGER.error("Map should be supported. Please report to openapi-generator github repo about the issue."); - } else if (codegenProperty != null) { - String codegenModelName, codegenModelDescription; - - if (codegenModel != null) { - codegenModelName = codegenModel.classname; - codegenModelDescription = codegenModel.description; - } else { - LOGGER.warn("The following schema has undefined (null) baseType. " + - "It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. " + - "A correct 'consumes' for form parameters should be " + - "'application/x-www-form-urlencoded' or 'multipart/?'"); - LOGGER.warn("schema: " + schema); - LOGGER.warn("codegenModel is null. Default to UNKNOWN_BASE_TYPE"); - codegenModelName = "UNKNOWN_BASE_TYPE"; - codegenModelDescription = "UNKNOWN_DESCRIPTION"; - } - - if (StringUtils.isEmpty(bodyParameterName)) { - codegenParameter.baseName = codegenModelName; - } else { - codegenParameter.baseName = bodyParameterName; - } - - codegenParameter.paramName = toParamName(codegenParameter.baseName); - codegenParameter.baseType = codegenModelName; - codegenParameter.dataType = getTypeDeclaration(codegenModelName); - codegenParameter.description = codegenModelDescription; - imports.add(codegenParameter.baseType); - - if (codegenProperty.complexType != null) { - imports.add(codegenProperty.complexType); - } - } - } - - setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty); - // set nullable - setParameterNullable(codegenParameter, codegenProperty); - } - + this.addBodyModelSchema(codegenParameter, name, schema, imports, bodyParameterName, false); } else { // HTTP request body is primitive type (e.g. integer, string, etc) CodegenProperty codegenProperty = fromProperty("PRIMITIVE_REQUEST_BODY", schema); diff --git a/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION b/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION index 9e9d3e448fb..b5d898602c2 100644 --- a/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION +++ b/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION @@ -1 +1 @@ -4.3.1-SNAPSHOT +4.3.1-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart2/openapi/lib/api.dart b/samples/client/petstore/dart2/openapi/lib/api.dart index 69c3ecd2e15..e73e8722381 100644 --- a/samples/client/petstore/dart2/openapi/lib/api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api.dart @@ -11,6 +11,7 @@ part 'auth/authentication.dart'; part 'auth/api_key_auth.dart'; part 'auth/oauth.dart'; part 'auth/http_basic_auth.dart'; +part 'auth/http_bearer_auth.dart'; part 'api/pet_api.dart'; part 'api/store_api.dart'; diff --git a/samples/client/petstore/dart2/openapi/lib/auth/http_bearer_auth.dart b/samples/client/petstore/dart2/openapi/lib/auth/http_bearer_auth.dart new file mode 100644 index 00000000000..19a348c965e --- /dev/null +++ b/samples/client/petstore/dart2/openapi/lib/auth/http_bearer_auth.dart @@ -0,0 +1,25 @@ +part of openapi.api; + +class HttpBearerAuth implements Authentication { + dynamic _accessToken; + + HttpBearerAuth() { } + + @override + void applyToParams(List queryParams, Map headerParams) { + if (_accessToken is String) { + headerParams["Authorization"] = "Bearer " + _accessToken; + } else if (_accessToken is String Function()){ + headerParams["Authorization"] = "Bearer " + _accessToken(); + } else { + throw ArgumentError('Type of Bearer accessToken should be String or String Function().'); + } + } + + void setAccessToken(dynamic accessToken) { + if (!((accessToken is String) | (accessToken is String Function()))){ + throw ArgumentError('Type of Bearer accessToken should be String or String Function().'); + } + this._accessToken = accessToken; + } +} diff --git a/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md b/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md index 5565939f04f..36ba294f433 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md +++ b/samples/server/petstore/rust-server/output/openapi-v3/docs/default_api.md @@ -231,7 +231,7 @@ Optional parameters are passed through a map[string]interface{}. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **string** | [**string**](string.md)| | + **another_xml_array** | [**AnotherXmlArray**](AnotherXmlArray.md)| | ### Return type @@ -263,7 +263,7 @@ Optional parameters are passed through a map[string]interface{}. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **string** | [**string**](string.md)| | + **xml_array** | [**XmlArray**](XmlArray.md)| | ### Return type diff --git a/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs b/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs index c2a10af6c24..f9283c12517 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/examples/server_lib/server.rs @@ -95,16 +95,16 @@ impl Api for Server where C: Has{ } - fn xml_other_put(&self, string: Option, context: &C) -> Box> { + fn xml_other_put(&self, another_xml_array: Option, context: &C) -> Box> { let context = context.clone(); - println!("xml_other_put({:?}) - X-Span-ID: {:?}", string, context.get().0.clone()); + println!("xml_other_put({:?}) - X-Span-ID: {:?}", another_xml_array, context.get().0.clone()); Box::new(futures::failed("Generic failure".into())) } /// Post an array - fn xml_post(&self, string: Option, context: &C) -> Box> { + fn xml_post(&self, xml_array: Option, context: &C) -> Box> { let context = context.clone(); - println!("xml_post({:?}) - X-Span-ID: {:?}", string, context.get().0.clone()); + println!("xml_post({:?}) - X-Span-ID: {:?}", xml_array, context.get().0.clone()); Box::new(futures::failed("Generic failure".into())) } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs index 668b3083779..9617bc5808b 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/mod.rs @@ -987,7 +987,7 @@ impl Api for Client where } - fn xml_other_put(&self, param_string: Option, context: &C) -> Box> { + fn xml_other_put(&self, param_another_xml_array: Option, context: &C) -> Box> { let mut uri = format!( "{}/xml_other", self.base_path @@ -1009,7 +1009,7 @@ impl Api for Client where let mut request = hyper::Request::new(hyper::Method::Put, uri); - let body = param_string.map(|ref body| { + let body = param_another_xml_array.map(|ref body| { body.to_xml() }); @@ -1066,7 +1066,7 @@ impl Api for Client where } - fn xml_post(&self, param_string: Option, context: &C) -> Box> { + fn xml_post(&self, param_xml_array: Option, context: &C) -> Box> { let mut uri = format!( "{}/xml", self.base_path @@ -1088,7 +1088,7 @@ impl Api for Client where let mut request = hyper::Request::new(hyper::Method::Post, uri); - let body = param_string.map(|ref body| { + let body = param_xml_array.map(|ref body| { body.to_xml() }); diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs index 040a9308d60..bdf99fb2eca 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/lib.rs @@ -199,10 +199,10 @@ pub trait Api { fn xml_other_post(&self, another_xml_object: Option, context: &C) -> Box>; - fn xml_other_put(&self, string: Option, context: &C) -> Box>; + fn xml_other_put(&self, another_xml_array: Option, context: &C) -> Box>; /// Post an array - fn xml_post(&self, string: Option, context: &C) -> Box>; + fn xml_post(&self, xml_array: Option, context: &C) -> Box>; fn xml_put(&self, xml_object: Option, context: &C) -> Box>; @@ -237,10 +237,10 @@ pub trait ApiNoContext { fn xml_other_post(&self, another_xml_object: Option) -> Box>; - fn xml_other_put(&self, string: Option) -> Box>; + fn xml_other_put(&self, another_xml_array: Option) -> Box>; /// Post an array - fn xml_post(&self, string: Option) -> Box>; + fn xml_post(&self, xml_array: Option) -> Box>; fn xml_put(&self, xml_object: Option) -> Box>; @@ -302,13 +302,13 @@ impl<'a, T: Api, C> ApiNoContext for ContextWrapper<'a, T, C> { } - fn xml_other_put(&self, string: Option) -> Box> { - self.api().xml_other_put(string, &self.context()) + fn xml_other_put(&self, another_xml_array: Option) -> Box> { + self.api().xml_other_put(another_xml_array, &self.context()) } /// Post an array - fn xml_post(&self, string: Option) -> Box> { - self.api().xml_post(string, &self.context()) + fn xml_post(&self, xml_array: Option) -> Box> { + self.api().xml_post(xml_array, &self.context()) } diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs index 834eece27b1..f0afe3cc941 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/server/mod.rs @@ -687,19 +687,19 @@ where match result { Ok(body) => { let mut unused_elements = Vec::new(); - let param_string: Option = if !body.is_empty() { + let param_another_xml_array: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); match serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); }) { - Ok(param_string) => param_string, + Ok(param_another_xml_array) => param_another_xml_array, Err(_) => None, } } else { None }; - Box::new(api_impl.xml_other_put(param_string, &context) + Box::new(api_impl.xml_other_put(param_another_xml_array, &context) .then(move |result| { let mut response = Response::new(); response.headers_mut().set(XSpanId((&context as &dyn Has).get().0.to_string())); @@ -737,7 +737,7 @@ where } )) }, - Err(e) => Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't read body parameter string: {}", e)))), + Err(e) => Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't read body parameter AnotherXmlArray: {}", e)))), } }) ) as Box> @@ -753,19 +753,19 @@ where match result { Ok(body) => { let mut unused_elements = Vec::new(); - let param_string: Option = if !body.is_empty() { + let param_xml_array: Option = if !body.is_empty() { let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); match serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); }) { - Ok(param_string) => param_string, + Ok(param_xml_array) => param_xml_array, Err(_) => None, } } else { None }; - Box::new(api_impl.xml_post(param_string, &context) + Box::new(api_impl.xml_post(param_xml_array, &context) .then(move |result| { let mut response = Response::new(); response.headers_mut().set(XSpanId((&context as &dyn Has).get().0.to_string())); @@ -803,7 +803,7 @@ where } )) }, - Err(e) => Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't read body parameter string: {}", e)))), + Err(e) => Box::new(future::ok(Response::new().with_status(StatusCode::BadRequest).with_body(format!("Couldn't read body parameter XmlArray: {}", e)))), } }) ) as Box>