diff --git a/bin/configs/rust-reqwest-deep-object-free-form-query-param.yaml b/bin/configs/rust-reqwest-deep-object-free-form-query-param.yaml new file mode 100644 index 000000000000..c30fd0a8eb7b --- /dev/null +++ b/bin/configs/rust-reqwest-deep-object-free-form-query-param.yaml @@ -0,0 +1,8 @@ +generatorName: rust +outputDir: samples/client/others/rust/reqwest-deep-object-free-form-query-param +library: reqwest +inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/deep-object-free-form-query-param.yaml +templateDir: modules/openapi-generator/src/main/resources/rust +additionalProperties: + supportAsync: false + packageName: deep-object-free-form-query-param diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md index 015a6370b3e7..26bb22126a6b 100644 --- a/docs/generators/kotlin-spring.md +++ b/docs/generators/kotlin-spring.md @@ -74,6 +74,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useFlowForArrayReturnType|Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.| |true| |useJackson3|Use Jackson 3 dependencies (tools.jackson package). Only available with `useSpringBoot4`. Defaults to true when `useSpringBoot4` is enabled.| |false| |useResponseEntity|Whether (when false) to return actual type (e.g. List<Fruit>) and handle non-happy path responses via exceptions flow or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>). If disabled, method are annotated using a @ResponseStatus annotation, which has the status of the first response declared in the Api definition| |true| +|useSealedDiscriminatorInterfaces|Generate sealed interfaces instead of plain interfaces for allOf discriminator parent models. When true (default), discriminator parents rendered as `sealed interface`, enabling exhaustive `when` matching and preventing external implementors (which cannot know all subtypes). Set to false to restore the legacy plain `interface` behavior, e.g. when you implement the generated interface from a module outside the generated package.| |true| |useSealedResponseInterfaces|Generate sealed interfaces for endpoint responses that all possible response types implement. Allows controllers to return any valid response type in a type-safe manner (e.g., sealed interface CreateUserResponse implemented by User, ConflictResponse, ErrorResponse)| |false| |useSpringBoot3|Generate code and provide dependencies for use with Spring Boot ≥ 3 (use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| |useSpringBoot4|Generate code and provide dependencies for use with Spring Boot 4.x. Enabling this option will also enable `useJakartaEe`.| |false| @@ -325,7 +326,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |Composite|✓|OAS2,OAS3 |Polymorphism|✓|OAS2,OAS3 |Union|✗|OAS3 -|allOf|✗|OAS2,OAS3 +|allOf|✓|OAS2,OAS3 |anyOf|✗|OAS3 |oneOf|✓|OAS3 |not|✗|OAS3 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java index 1698503abe89..8fa353a906e8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRustCodegen.java @@ -201,16 +201,12 @@ public String sanitizeIdentifier(String name, CasingType casingType, String esca // Sanitize any other special characters that weren't replaced name = sanitizeName(name); - // Keep track of modifications prior to casing - boolean nameWasModified = !originalName.equals(name); - // Convert casing name = casingFunction.apply(name); // If word starts with number add a prefix // Note: this must be done after casing since CamelCase will strip leading underscores if (name.matches("^\\d.*")) { - nameWasModified = true; name = casingFunction.apply(escapePrefix + '_' + name); } @@ -218,7 +214,6 @@ public String sanitizeIdentifier(String name, CasingType casingType, String esca // There is currently a bug in Rust where this doesn't work for a few reserved words :( // https://internals.rust-lang.org/t/raw-identifiers-dont-work-for-all-identifiers/9094 if (isReservedWord(name)) { - nameWasModified = true; if (this.keywordsThatDoNotSupportRawIdentifiers.contains(name) || !allowRawIdentifiers) { name = casingFunction.apply(escapePrefix + '_' + name); } else { @@ -227,8 +222,9 @@ public String sanitizeIdentifier(String name, CasingType casingType, String esca } // If the name had to be modified (not just because of casing), log the change - if (nameWasModified) { - LOGGER.warn("{} cannot be used as a {} name. Renamed to {}", casingFunction.apply(originalName), type, name); + String casedOriginalName = casingFunction.apply(originalName); + if (!casedOriginalName.equals(name)) { + LOGGER.warn("{} cannot be used as a {} name. Renamed to {}", casedOriginalName, type, name); } return name; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java index 90b3c8ad9bcf..8db7c83669b2 100755 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java @@ -1157,6 +1157,14 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List>() .apply { {{#queryParams}} + {{^vendorExtensions.x-kotlin-explode-form-object}} {{^required}} if ({{{paramName}}} != null) { {{#isModel}} @@ -251,6 +252,23 @@ import {{packageName}}.infrastructure.Serializer {{/isModel}} {{/isNullable}} {{/required}} + {{/vendorExtensions.x-kotlin-explode-form-object}} + {{/queryParams}} + {{#queryParams}} + {{#vendorExtensions.x-kotlin-explode-form-object}} + // form style, explode: one query parameter per entry, keyed by the property name, appended after the declared ones; null is left out, a collection repeats the key + ({{{paramName}}} as? kotlin.collections.Map<*, *>)?.forEach { (key, value) -> + val values = when (value) { + is kotlin.collections.Iterable<*> -> value.toList() + is kotlin.Array<*> -> value.toList() + else -> listOf(value) + }.filterNotNull().map { parameterToString(it) } + if (key != null && values.isNotEmpty()) { + val name = key.toString() + put(name, getOrElse(name) { emptyList() } + values) + } + } + {{/vendorExtensions.x-kotlin-explode-form-object}} {{/queryParams}} } {{/hasQueryParams}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/dataClass.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/dataClass.mustache index 45f39c691392..b57036ba3af3 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/dataClass.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/dataClass.mustache @@ -1,10 +1,10 @@ /** * {{{description}}} {{#requiredVars}} - * @param {{name}} {{{description}}} + * @param {{{name}}} {{{description}}} {{/requiredVars}} {{#optionalVars}} - * @param {{name}} {{{description}}} + * @param {{{name}}} {{{description}}} {{/optionalVars}} */{{#discriminator}} {{>typeInfoAnnotation}}{{/discriminator}} @@ -14,7 +14,7 @@ {{#vendorExtensions.x-class-extra-annotation}} {{{.}}} {{/vendorExtensions.x-class-extra-annotation}} -{{#discriminator}}interface {{classname}}{{/discriminator}}{{^discriminator}}{{#vendorExtensions.x-is-open-class}}open {{/vendorExtensions.x-is-open-class}}{{^vendorExtensions.x-is-open-class}}{{#hasVars}}data {{/hasVars}}{{/vendorExtensions.x-is-open-class}}class {{classname}}( +{{#discriminator}}{{#useSealedDiscriminatorInterfaces}}sealed {{/useSealedDiscriminatorInterfaces}}interface {{classname}}{{/discriminator}}{{^discriminator}}{{#vendorExtensions.x-is-open-class}}open {{/vendorExtensions.x-is-open-class}}{{^vendorExtensions.x-is-open-class}}{{#hasVars}}data {{/hasVars}}{{/vendorExtensions.x-is-open-class}}class {{classname}}( {{#requiredVars}} {{>dataClassReqVar}}{{^-last}}, {{/-last}}{{/requiredVars}}{{#hasRequired}}{{#hasOptional}}, diff --git a/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class.mustache b/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class.mustache index 338856586b27..c676209311da 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-vertx-server/data_class.mustache @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonInclude /** * {{{description}}} {{#vars}} - * @param {{name}} {{{description}}} + * @param {{{name}}} {{{description}}} {{/vars}} */ {{#parcelizeModels}} diff --git a/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache index 780ac7e05c03..425bcdde9a7a 100644 --- a/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache @@ -485,6 +485,12 @@ class ObjectSerializer if (method_exists($class, 'getAllowableEnumValues')) { if (!in_array($data, $class::getAllowableEnumValues(), true)) { + {{#enumUnknownDefaultCase}} + if (defined("$class::UNKNOWN_DEFAULT_OPEN_API")) { + return constant("$class::UNKNOWN_DEFAULT_OPEN_API"); + } + + {{/enumUnknownDefaultCase}} $imploded = implode("', '", $class::getAllowableEnumValues()); throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'"); } diff --git a/modules/openapi-generator/src/main/resources/python/api.mustache b/modules/openapi-generator/src/main/resources/python/api.mustache index 514be3b69a85..3cee5c88c1b8 100644 --- a/modules/openapi-generator/src/main/resources/python/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/api.mustache @@ -347,7 +347,37 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb _query_params.append(('{{baseName}}', {{paramName}})) {{/isDate}} {{^isDateTime}}{{^isDate}} + {{#isMap}} + {{#isExplode}} + {{#isDeepObject}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{^isDeepObject}} + _query_params.extend(self.api_client.explode_query_object('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{/isExplode}} + {{^isExplode}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isExplode}} + {{/isMap}} + {{#isModel}} + {{#isExplode}} + {{#isDeepObject}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{^isDeepObject}} + _query_params.extend(self.api_client.explode_query_object('{{baseName}}', {{paramName}})) + {{/isDeepObject}} + {{/isExplode}} + {{^isExplode}} + _query_params.append(('{{baseName}}', {{paramName}})) + {{/isExplode}} + {{/isModel}} + {{^isMap}} + {{^isModel}} _query_params.append(('{{baseName}}', {{paramName}}{{#isEnumRef}}.value{{/isEnumRef}})) + {{/isModel}} + {{/isMap}} {{/isDate}}{{/isDateTime}} {{/queryParams}} # process the header parameters diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index 874d9cd3efef..973a8de03b2b 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -671,6 +671,13 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb new_params.append((k, v)) return new_params + def explode_query_object(self, name, obj): + """form style, explode: one query parameter per entry, keyed by the property name; a list repeats the name, None is left out""" + obj = self.sanitize_for_serialization(obj) + if not isinstance(obj, dict): + obj = {name: obj} + return [(k, item) for k, v in obj.items() for item in (v if isinstance(v, (list, tuple)) else [v]) if item is not None] + def parameters_to_url_query(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -689,11 +696,12 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb if isinstance(v, dict): v = json.dumps(v) - if k in collection_formats: + # a collection format applies only to a list; an exploded entry may share a declared array parameter's name + if k in collection_formats and isinstance(v, (list, tuple)): collection_format = collection_formats[k] if collection_format == 'multi': new_params.extend( - (k, quote(str(value).lower() if isinstance(value, bool) else str(value))) + (quote(str(k)), quote(str(value).lower() if isinstance(value, bool) else str(value))) for value in v ) else: @@ -706,12 +714,13 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb else: # csv is the default delimiter = ',' new_params.append( - (k, delimiter.join( + (quote(str(k)), delimiter.join( quote(str(value).lower() if isinstance(value, bool) else str(value)) for value in v)) ) else: - new_params.append((k, quote(str(v)))) + # names are quoted too: an exploded object's names are runtime data + new_params.append((quote(str(k)), quote(str(v)))) return "&".join(["=".join(map(str, item)) for item in new_params]) diff --git a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache index d2ddbff19777..1c3276ec1254 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/partial_model_enum_class.mustache @@ -18,6 +18,11 @@ # @return [String] The enum value def build_from_hash(value) return value if {{classname}}.all_vars.include?(value) + {{#enumUnknownDefaultCase}} + {{#allowableValues}}{{#enumVars}}{{#-last}}{{{name}}}{{/-last}}{{/enumVars}}{{/allowableValues}} + {{/enumUnknownDefaultCase}} + {{^enumUnknownDefaultCase}} raise "Invalid ENUM value #{value} for class #{{{classname}}}" + {{/enumUnknownDefaultCase}} end end \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest-trait/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest-trait/api.mustache index ff3d54ddcc2d..c11fed0ac474 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest-trait/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest-trait/api.mustache @@ -206,11 +206,8 @@ impl {{classname}} for {{classname}}Client { {{/isModel}} {{#isMap}} if let Some(ref param_value) = {{{paramName}}} { - let mut query_params = Vec::with_capacity(param_value.len()); - for (key, value) in param_value.iter() { - query_params.push((key.to_string(), serde_json::to_string(value)?)); - } - local_var_req_builder = local_var_req_builder.query(&query_params); + let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?); + local_var_req_builder = local_var_req_builder.query(¶ms); } {{/isMap}} {{/isExplode}} @@ -256,11 +253,8 @@ impl {{classname}} for {{classname}}Client { local_var_req_builder = local_var_req_builder.query(¶m_value); {{/isModel}} {{#isMap}} - let mut query_params = Vec::with_capacity(param_value.len()); - for (key, value) in param_value.iter() { - query_params.push((key.to_string(), serde_json::to_string(value)?)); - } - local_var_req_builder = local_var_req_builder.query(&query_params); + let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?); + local_var_req_builder = local_var_req_builder.query(¶ms); {{/isMap}} {{/isExplode}} {{/isDeepObject}} diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest-trait/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest-trait/configuration.mustache index 9a8fa5481ec7..c7f5bd854cc8 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest-trait/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest-trait/configuration.mustache @@ -13,7 +13,7 @@ use async_trait::async_trait; {{/supportTokenSource}} pub use {{#supportMiddleware}}reqwest_middleware::ClientWithMiddleware{{/supportMiddleware}}{{^supportMiddleware}}reqwest::Client{{/supportMiddleware}}; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -35,11 +35,20 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } + +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} {{/supportTokenSource}} {{#withAWSV4Signature}} @@ -81,6 +90,30 @@ impl AWSv4Key { } {{/withAWSV4Signature}} +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + {{^supportTokenSource}} + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + {{/supportTokenSource}} + {{#withAWSV4Signature}} + debug.field("aws_v4_key", &self.aws_v4_key); + {{/withAWSV4Signature}} + {{#supportTokenSource}} + debug.field("token_source", &"[REDACTED]"); + {{/supportTokenSource}} + debug.finish() + } +} + impl Configuration { pub fn new() -> Configuration { Configuration::default() diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache index 5224b0c4d9b5..14e99143c12b 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -180,11 +180,8 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: req_builder = req_builder.query(¶m_value); {{/isModel}} {{#isMap}} - let mut query_params = Vec::with_capacity(param_value.len()); - for (key, value) in param_value.iter() { - query_params.push((key.to_string(), serde_json::to_string(value)?)); - } - req_builder = req_builder.query(&query_params); + let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?); + req_builder = req_builder.query(¶ms); {{/isMap}} {{/isExplode}} }; @@ -251,11 +248,8 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: req_builder = req_builder.query(¶m_value); {{/isModel}} {{#isMap}} - let mut query_params = Vec::with_capacity(param_value.len()); - for (key, value) in param_value.iter() { - query_params.push((key.to_string(), serde_json::to_string(value)?)); - } - req_builder = req_builder.query(&query_params); + let params = crate::apis::parse_deep_object("{{{baseName}}}", &serde_json::to_value(param_value)?); + req_builder = req_builder.query(¶ms); {{/isMap}} {{/isExplode}} {{/isDeepObject}} diff --git a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache index 4ff5b5caad98..4dc403de23aa 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache @@ -13,7 +13,7 @@ use async_trait::async_trait; {{/supportTokenSource}} pub use {{#supportMiddleware}}reqwest_middleware::ClientWithMiddleware{{/supportMiddleware}}{{^supportMiddleware}}reqwest{{^supportAsync}}::blocking{{/supportAsync}}::Client{{/supportMiddleware}}; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -37,11 +37,20 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } + +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} {{/supportTokenSource}} {{#withAWSV4Signature}} @@ -83,6 +92,32 @@ impl AWSv4Key { } {{/withAWSV4Signature}} +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + {{^supportTokenSource}} + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + {{/supportTokenSource}} + {{#withAWSV4Signature}} + debug.field("aws_v4_key", &self.aws_v4_key); + {{/withAWSV4Signature}} + {{#supportAsync}} + {{#supportTokenSource}} + debug.field("token_source", &"[REDACTED]"); + {{/supportTokenSource}} + {{/supportAsync}} + debug.finish() + } +} + impl Configuration { pub fn new() -> Configuration { Configuration::default() diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/csharpnetcore/CSharpClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/csharpnetcore/CSharpClientCodegenTest.java index f457707d1336..55e7cb4d720f 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/csharpnetcore/CSharpClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/csharpnetcore/CSharpClientCodegenTest.java @@ -605,6 +605,78 @@ public void testMapResponse() throws Exception { Assert.assertTrue(cr1.isMap); } + @Test(description = "conditionalSerialization: an all-optional model's public constructor must not raise the serialization flag for value-typed properties the caller never passed") + public void testConditionalSerializationValueTypeConstructorFlags() throws IOException { + Map files = generateConditionalSerializationValueTypeModels(true); + + File updateCommand = files.get("UpdateThingCommand.cs"); + assertNotNull(updateCommand); + // value-typed parameters become nullable so "not passed" is representable ... + assertFileContains(updateCommand.toPath(), + "public UpdateThingCommand(bool? autoRenew = default, int? period = default, int? graceDays = default, StatusEnum? status = default, RenewalModeEnum? renewalMode = default, string note = default)"); + // ... and the flag is only raised for arguments that were actually provided + assertFileContains(updateCommand.toPath(), + "if (autoRenew != null)\n" + + " {\n" + + " this._AutoRenew = autoRenew.Value;\n" + + " this._flagAutoRenew = true;\n" + + " }"); + // optional enums take the same guarded path + assertFileContains(updateCommand.toPath(), + "if (status != null)\n" + + " {\n" + + " this._Status = status.Value;\n" + + " this._flagStatus = true;\n" + + " }"); + // a nullable value type already had a meaningful null check and keeps it + assertFileContains(updateCommand.toPath(), + "this._GraceDays = graceDays;\n" + + " if (this.GraceDays != null)\n" + + " {\n" + + " this._flagGraceDays = true;\n" + + " }"); + // the public property surface is untouched: plain value types, flag-raising setters + assertFileContains(updateCommand.toPath(), "public bool AutoRenew", "public int Period"); + assertFileNotContains(updateCommand.toPath(), "public bool? AutoRenew", "public int? Period"); + + // required value-typed properties keep their non-nullable parameter and unconditional assignment + File createCommand = files.get("CreateThingCommand.cs"); + assertNotNull(createCommand); + assertFileContains(createCommand.toPath(), + "public CreateThingCommand(string name = default, bool autoRenew = default, string note = default)"); + assertFileContains(createCommand.toPath(), "this._AutoRenew = autoRenew;"); + assertFileNotContains(createCommand.toPath(), "autoRenew.Value"); + } + + @Test(description = "without conditionalSerialization the constructor keeps plain value-typed parameters") + public void testValueTypeConstructorUnchangedWithoutConditionalSerialization() throws IOException { + Map files = generateConditionalSerializationValueTypeModels(false); + + File updateCommand = files.get("UpdateThingCommand.cs"); + assertNotNull(updateCommand); + assertFileContains(updateCommand.toPath(), + "public UpdateThingCommand(bool autoRenew = default, int period = default, int? graceDays = default, StatusEnum? status = default, RenewalModeEnum? renewalMode = default, string note = default)"); + assertFileNotContains(updateCommand.toPath(), "_flagAutoRenew"); + } + + private Map generateConditionalSerializationValueTypeModels(boolean conditionalSerialization) throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/csharp/conditional-serialization-value-types.yaml"); + final DefaultGenerator defaultGenerator = new DefaultGenerator(); + final ClientOptInput clientOptInput = new ClientOptInput(); + clientOptInput.openAPI(openAPI); + CSharpClientCodegen cSharpClientCodegen = new CSharpClientCodegen(); + cSharpClientCodegen.setLibrary("httpclient"); + cSharpClientCodegen.setOutputDir(output.getAbsolutePath()); + cSharpClientCodegen.additionalProperties().put(CodegenConstants.OPTIONAL_CONDITIONAL_SERIALIZATION, String.valueOf(conditionalSerialization)); + clientOptInput.config(cSharpClientCodegen); + defaultGenerator.opts(clientOptInput); + + return defaultGenerator.generate().stream() + .collect(Collectors.toMap(File::getName, Function.identity(), (first, second) -> first)); + } + private Map generateIssue23046Models(boolean nonPublicApi) throws IOException { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); output.deleteOnExit(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java index 6b04bf8e8703..0abf0a052ec7 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/go/GoClientCodegenTest.java @@ -141,6 +141,35 @@ public void testPrimitiveTypeInOneOf() throws IOException { TestUtils.assertFileNotContains(modelFile, "dst.int32"); } + @Test(description = "Verify form style query parameters explode an object instead of bracketing it") + public void testExplodedObjectQueryParameter() throws IOException { + File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("go") + .setInputSpec("src/test/resources/3_0/exploded-object-query-param.yaml") + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); + + DefaultGenerator generator = new DefaultGenerator(); + List files = generator.opts(configurator.toClientOptInput()).generate(); + files.forEach(File::deleteOnExit); + + TestUtils.assertFileContains(Paths.get(output + "/client.go"), + "keyPrefixForMapEntry = k.String()", + "if !ok { continue } if entry.Kind() == reflect.Slice {", + "case reflect.Ptr: if v.IsNil() { return }", + "styleForElement = \"\""); + + // the api passes the declared style through + Path api = Paths.get(output + "/api_default.go"); + TestUtils.assertFileContains(api, + "parameterAddToHeaderOrQuery(localVarQueryParams, \"filter\", r.filter, \"form\", \"\")", + "parameterAddToHeaderOrQuery(localVarQueryParams, \"typedFilter\", r.typedFilter, \"form\", \"\")", + "parameterAddToHeaderOrQuery(localVarQueryParams, \"deepFilter\", r.deepFilter, \"deepObject\", \"\")", + "parameterAddToHeaderOrQuery(localVarQueryParams, \"flatFilter\", r.flatFilter, \"form\", \"\")"); + } + @Test public void testNullableComposition() throws IOException { File output = Files.createTempDirectory("test").toFile(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenApiTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenApiTest.java index 1bad07e5acf0..da4faa356004 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenApiTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenApiTest.java @@ -15,6 +15,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; @@ -253,6 +254,47 @@ public void testJvmKtorQueryParamWithTypeObject() throws IOException { assertFileNotContains(defaultApi.toPath(), "mapDeep?.apply {"); } + @Test(description = "Verify a form style, exploded map query parameter goes on the wire one entry per parameter") + public void testExplodedObjectQueryParameterJvmOkhttp() throws IOException { + OpenAPI openAPI = readOpenAPI("src/test/resources/3_0/exploded-object-query-param.yaml"); + + KotlinClientCodegen codegen = createCodegen(ClientLibrary.JVM_OKHTTP4); + DefaultGenerator generator = new DefaultGenerator(); + enableOnlyApiGeneration(generator); + + List files = generator.opts(createClientOptInput(openAPI, codegen)).generate(); + File defaultApi = files.stream().filter(file -> file.getName().equals("DefaultApi.kt")).findAny().orElseThrow(); + + String content = new String(Files.readAllBytes(defaultApi.toPath()), StandardCharsets.UTF_8); + + // form style with explode - the default - puts every entry on the wire under its own + // property name. Serializing the whole map with toString() is what used to happen. + assertFileContains(defaultApi.toPath(), "(filter as? kotlin.collections.Map<*, *>)?.forEach { (key, value) ->"); + assertFileNotContains(defaultApi.toPath(), "put(\"filter\", listOf(filter.toString()))"); + + // a declared map behaves the same way + assertFileContains(defaultApi.toPath(), "(typedFilter as? kotlin.collections.Map<*, *>)?.forEach { (key, value) ->"); + assertFileNotContains(defaultApi.toPath(), "put(\"typedFilter\""); + + // a null entry is left out rather than sent as "null", a collection repeats the key + // once per element rather than going out as its toString(), and an entry is appended + // rather than replacing a query parameter of the same name + assertFileContains(defaultApi.toPath(), + "is kotlin.collections.Iterable<*> -> value.toList()", + "}.filterNotNull().map { parameterToString(it) }", + "put(name, getOrElse(name) { emptyList() } + values)"); + + // deepObject and form without explode both keep a single parameter + assertFileContains(defaultApi.toPath(), + "put(\"deepFilter\", listOf(deepFilter.toString()))", + "put(\"flatFilter\", listOf(flatFilter.toString()))"); + + // the exploded entries are added after every declared parameter, so a declared + // parameter's put cannot overwrite an entry that happens to share its name + Assert.assertTrue(content.indexOf("(filter as? kotlin.collections.Map") > content.indexOf("put(\"flatFilter\""), + "exploded entries must be added after the declared query parameters"); + } + private static void assertFileContainsLine(List lines, String line) { Assert.assertListContains(lines, s -> s.equals(line), line); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java index dad52b7ae72b..353754b2bc00 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java @@ -990,6 +990,33 @@ public void testJacksonEnumsExposeDecodeOrNullHelper() throws IOException { "Expected exactly one @JsonCreator annotation in the generated enum, found " + jsonCreatorCount); } + @Test + public void testMoshiEnumUnknownDefaultCaseAdaptersAreNullSafe() throws IOException { + File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName(KOTLIN_GENERATOR) + .setLibrary("jvm-okhttp4") + .setAdditionalProperties(new HashMap<>() {{ + put(CodegenConstants.SERIALIZATION_LIBRARY, "moshi"); + put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, "true"); + }}) + .setInputSpec("src/test/resources/3_0/enum.yaml") + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + DefaultGenerator generator = new DefaultGenerator(); + + generator.opts(clientOptInput).generate(); + + final Path helperKt = Paths.get(output + "/src/main/kotlin/org/openapitools/client/infrastructure/SerializerHelper.kt"); + + // EnumJsonAdapter is not null-safe, so every registered fallback adapter must be wrapped + TestUtils.assertFileContains(helperKt, ".nullSafe())"); + TestUtils.assertFileNotContains(helperKt, "unknown_default_open_api))"); + } + @Test public void testJacksonEnumsWithUnknownDefaultCase() throws IOException { File output = Files.createTempDirectory("test").toFile(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java index 74a72e8680a3..9386932bab2f 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java @@ -7797,6 +7797,20 @@ public void paramJsonPropertyAnnotationWithDigitStartingPropertyName() throws IO ); } + @Test(description = "KDoc @param must name the property literally, without HTML-escaping its back-ticks") + public void kdocParamNameIsNotHtmlEscaped() throws IOException { + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/param-json-property.yaml" + ); + + File itemFile = files.get("Item.kt"); + assertThat(itemFile).isNotNull(); + // "2nd_field" is not a valid Kotlin identifier, so the property is declared as `2ndField`. + // The KDoc must carry those back-ticks as written rather than as HTML entities. + assertFileNotContains(itemFile.toPath(), "`"); + assertFileContains(itemFile.toPath(), "@param `2ndField` "); + } + /** * Regression test for https://github.com/OpenAPITools/openapi-generator/issues/24139 @@ -8091,4 +8105,92 @@ public void testMultiLevelAllOfWithEscapedPropertyNames() throws IOException { assertFileContains(mid, "\"2ndField=\" + `2ndField`"); assertFileNotContains(mid, "$`2ndField`"); } + + // ==================== allOf sealed interface tests ==================== + + @Test(description = "allOf discriminator parent generates sealed interface by default") + public void testAllOfDiscriminatorParentIsSealedInterfaceByDefault() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + new DefaultGenerator().opts(new ClientOptInput() + .openAPI(new OpenAPIParser().readLocation("src/test/resources/3_1/polymorphism-allof-and-discriminator.yaml", null, new ParseOptions()).getOpenAPI()) + .config(new KotlinSpringServerCodegen() {{ + setOutputDir(output.getAbsolutePath()); + }})) + .generate(); + + String outputPath = output.getAbsolutePath() + "/src/main/kotlin/org/openapitools/model"; + + // Pet should be a sealed interface with Jackson annotations + assertFileContains(Paths.get(outputPath + "/Pet.kt"), + "sealed interface Pet", + "@JsonTypeInfo", "property = \"petType\"", "visible = true", + "@JsonSubTypes" + ); + // Children must remain data classes — sealing only applies to the discriminator parent + assertFileContains(Paths.get(outputPath + "/Dog.kt"), "data class Dog"); + assertFileContains(Paths.get(outputPath + "/Cat.kt"), "data class Cat"); + assertFileNotContains(Paths.get(outputPath + "/Dog.kt"), "sealed"); + assertFileNotContains(Paths.get(outputPath + "/Cat.kt"), "sealed"); + } + + @Test(description = "allOf discriminator parent generates plain interface when useSealedDiscriminatorInterfaces=false") + public void testAllOfDiscriminatorOptOutPlainInterface() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + new DefaultGenerator().opts(new ClientOptInput() + .openAPI(new OpenAPIParser().readLocation("src/test/resources/3_1/polymorphism-allof-and-discriminator.yaml", null, new ParseOptions()).getOpenAPI()) + .config(new KotlinSpringServerCodegen() {{ + setOutputDir(output.getAbsolutePath()); + additionalProperties().put(USE_SEALED_DISCRIMINATOR_INTERFACES, "false"); + }})) + .generate(); + + String outputPath = output.getAbsolutePath() + "/src/main/kotlin/org/openapitools/model"; + + // Opt-out: plain interface, not sealed + assertFileContains(Paths.get(outputPath + "/Pet.kt"), "interface Pet"); + assertFileNotContains(Paths.get(outputPath + "/Pet.kt"), "sealed interface Pet"); + } + + @Test(description = "allOf sealed interface correctly composes external x-kotlin-implements supertypes") + public void testSealedInterfaceWithExternalSupertypes() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + new DefaultGenerator().opts(new ClientOptInput() + .openAPI(new OpenAPIParser().readLocation("src/test/resources/3_0/kotlin/petstore-with-x-kotlin-implements.yaml", null, new ParseOptions()).getOpenAPI()) + .config(new KotlinSpringServerCodegen() {{ + setOutputDir(output.getAbsolutePath()); + }})) + .generate(); + + String outputPath = output.getAbsolutePath() + "/src/main/kotlin/org/openapitools/model"; + + // Pet has x-kotlin-implements external supertypes; sealed should come before those + assertFileContains(Paths.get(outputPath + "/Pet.kt"), + "sealed interface Pet : com.some.pack.Named" + ); + } + + @Test(description = "oneOf sealed interface stays sealed when useSealedDiscriminatorInterfaces=false (different template path)") + public void testOneOfInterfaceStillSealedWhenAllOfFlagOff() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + new DefaultGenerator().opts(new ClientOptInput() + .openAPI(new OpenAPIParser().readLocation("src/test/resources/3_0/kotlin/polymorphism-oneof-discriminator.yaml", null, new ParseOptions()).getOpenAPI()) + .config(new KotlinSpringServerCodegen() {{ + setOutputDir(output.getAbsolutePath()); + additionalProperties().put(USE_SEALED_DISCRIMINATOR_INTERFACES, "false"); + }})) + .generate(); + + String outputPath = output.getAbsolutePath() + "/src/main/kotlin/org/openapitools/model"; + + // oneOf parent uses oneof_interface.mustache, not dataClass.mustache — flag has no effect on it + assertFileContains(Paths.get(outputPath + "/Animal.kt"), "sealed interface Animal"); + } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java index 7ffd48a1fd09..803a460aea0a 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/PhpClientCodegenTest.java @@ -136,6 +136,15 @@ public void testEnumUnknownDefaultCaseDeserializationEnabled() throws Exception Assert.assertListContains(modelContent, a -> a.equals("$color = self::COLOR_UNKNOWN_DEFAULT_OPEN_API;"), ""); Assert.assertListNotContains(modelContent, a -> a.equals("\"Invalid value '%s' for 'color', must be one of '%s'\","), ""); + + List serializerContent = Files + .readAllLines(files.get("ObjectSerializer.php").toPath()) + .stream() + .map(String::trim) + .collect(Collectors.toList()); + + Assert.assertListContains(serializerContent, a -> a.equals("if (defined(\"$class::UNKNOWN_DEFAULT_OPEN_API\")) {"), ""); + Assert.assertListContains(serializerContent, a -> a.equals("return constant(\"$class::UNKNOWN_DEFAULT_OPEN_API\");"), ""); } @Test @@ -164,6 +173,14 @@ public void testEnumUnknownDefaultCaseDeserializationDisabled() throws Exception Assert.assertListNotContains(modelContent, a -> a.equals("$color = self::COLOR_UNKNOWN_DEFAULT_OPEN_API;"), ""); Assert.assertListContains(modelContent, a -> a.equalsIgnoreCase("\"Invalid value '%s' for 'color', must be one of '%s'\","), ""); + + List serializerContent = Files + .readAllLines(files.get("ObjectSerializer.php").toPath()) + .stream() + .map(String::trim) + .collect(Collectors.toList()); + + Assert.assertListNotContains(serializerContent, a -> a.equals("return constant(\"$class::UNKNOWN_DEFAULT_OPEN_API\");"), ""); } @Test public void testDateTimeLengthValidationIsNotGenerated() throws Exception { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java index 5f6272a7a11b..5b7f8c33b8c6 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java @@ -803,6 +803,74 @@ public void testInitFileImportsExportsWithCustomApiPackage() throws IOException assertFileContains(apiInitFile.toPath(), "from my_pkg.my_api.pet_api import PetApi"); } + @Test(description = "Verify a form style, exploded map query parameter goes on the wire one entry per parameter") + public void testExplodedObjectQueryParameter() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("python") + .setInputSpec("src/test/resources/3_0/exploded-object-query-param.yaml") + .setOutputDir(output.getAbsolutePath()); + + DefaultGenerator generator = new DefaultGenerator(); + List files = generator.opts(configurator.toClientOptInput()).generate(); + files.forEach(File::deleteOnExit); + + Path api = Paths.get(output.getAbsolutePath(), "openapi_client", "api", "default_api.py"); + + TestUtils.assertFileContains(api, + "_query_params.extend(self.api_client.explode_query_object('filter', filter))", + "_query_params.extend(self.api_client.explode_query_object('typedFilter', typed_filter))"); + TestUtils.assertFileNotContains(api, "_query_params.append(('filter', filter))"); + + // deepObject and form without explode both keep a single parameter + TestUtils.assertFileContains(api, + "_query_params.append(('deepFilter', deep_filter))", + "_query_params.append(('flatFilter', flat_filter))"); + TestUtils.assertFileNotContains(api, + "explode_query_object('deepFilter', deep_filter)", + "explode_query_object('flatFilter', flat_filter)"); + + // a collection format applies only to a list, so an exploded "context": "en" next to a context: multi array stays context=en + Path apiClient = Paths.get(output.getAbsolutePath(), "openapi_client", "api_client.py"); + TestUtils.assertFileContains(apiClient, + "def explode_query_object(self, name, obj):", + "if k in collection_formats and isinstance(v, (list, tuple)):"); + } + + @Test + public void testExplodedModelQueryParameter() throws IOException { + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); + output.deleteOnExit(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("python") + .setInputSpec("src/test/resources/3_0/python/exploded-model-query-param.yaml") + .setOutputDir(output.getAbsolutePath()); + + DefaultGenerator generator = new DefaultGenerator(); + List files = generator.opts(configurator.toClientOptInput()).generate(); + files.forEach(File::deleteOnExit); + + Path api = Paths.get(output.getAbsolutePath(), "openapi_client", "api", "default_api.py"); + + // a model is serialized first (wire names), then exploded; a oneOf holding a primitive stays one parameter, one holding a list repeats the name + TestUtils.assertFileContains(api, + "_query_params.extend(self.api_client.explode_query_object('refFilter', ref_filter))", + "_query_params.extend(self.api_client.explode_query_object('inlineFilter', inline_filter))", + "_query_params.extend(self.api_client.explode_query_object('oneOfFilter', one_of_filter))"); + TestUtils.assertFileNotContains(api, "_query_params.append(('oneOfFilter', one_of_filter))"); + + // deepObject and form without explode both keep a single parameter + TestUtils.assertFileContains(api, + "_query_params.append(('deepFilter', deep_filter))", + "_query_params.append(('flatFilter', flat_filter))"); + TestUtils.assertFileNotContains(api, + "explode_query_object('deepFilter', deep_filter)", + "explode_query_object('flatFilter', flat_filter)"); + } + @Test(description = "Verify default license format uses object notation when poetry1 is false") public void testLicenseFormatInPyprojectToml() throws IOException { File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java index a9914a9b8acf..c688b531eec8 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ruby/RubyClientCodegenTest.java @@ -858,4 +858,58 @@ public void testAliasModelDoesNotDelegateToItsBuiltInSuperclass() throws Excepti "def self.acceptable_openapi_nullable\n openapi_nullable\n end"); TestUtils.assertFileNotContains(arrayAlias, "superclass.", "super(attributes)"); } + + @Test(description = "enumUnknownDefaultCase=true makes build_from_hash fall back to the unknown default member") + public void testEnumUnknownDefaultCaseBuildFromHashFallback() throws Exception { + final File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/enum.yaml"); + CodegenConfig codegenConfig = new RubyClientCodegen(); + codegenConfig.additionalProperties().put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, "true"); + codegenConfig.setOutputDir(output.getAbsolutePath()); + + ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(codegenConfig); + new DefaultGenerator().opts(clientOptInput).generate(); + + Path stringEnum = new File(output, "lib/openapi_client/models/type.rb").toPath(); + TestUtils.assertFileContains(stringEnum, "UNKNOWN_DEFAULT_OPEN_API = \"unknown_default_open_api\".freeze"); + TestUtils.assertFileContains(stringEnum, + "def build_from_hash(value)\n" + + " return value if Type.all_vars.include?(value)\n" + + " UNKNOWN_DEFAULT_OPEN_API\n" + + " end"); + TestUtils.assertFileNotContains(stringEnum, "raise \"Invalid ENUM value"); + + // the integer enum's unknown-default member keeps its (pre-existing) numeric-prefixed name + Path integerEnum = new File(output, "lib/openapi_client/models/integer_enum.rb").toPath(); + TestUtils.assertFileContains(integerEnum, "Nunknown_default_open_api = 11184809.freeze"); + TestUtils.assertFileContains(integerEnum, + "def build_from_hash(value)\n" + + " return value if IntegerEnum.all_vars.include?(value)\n" + + " Nunknown_default_open_api\n" + + " end"); + TestUtils.assertFileNotContains(integerEnum, "raise \"Invalid ENUM value"); + } + + @Test(description = "without enumUnknownDefaultCase build_from_hash still raises on unknown values") + public void testEnumBuildFromHashRaisesByDefault() throws Exception { + final File output = Files.createTempDirectory("test").toFile(); + output.deleteOnExit(); + + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/enum.yaml"); + CodegenConfig codegenConfig = new RubyClientCodegen(); + codegenConfig.setOutputDir(output.getAbsolutePath()); + + ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(codegenConfig); + new DefaultGenerator().opts(clientOptInput).generate(); + + Path stringEnum = new File(output, "lib/openapi_client/models/type.rb").toPath(); + TestUtils.assertFileNotContains(stringEnum, "UNKNOWN_DEFAULT_OPEN_API"); + TestUtils.assertFileContains(stringEnum, + "def build_from_hash(value)\n" + + " return value if Type.all_vars.include?(value)\n" + + " raise \"Invalid ENUM value #{value} for class #Type\"\n" + + " end"); + } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/AbstractRustCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/AbstractRustCodegenTest.java index 300e0b9566c3..a03659a9dd16 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/AbstractRustCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/AbstractRustCodegenTest.java @@ -1,7 +1,13 @@ package org.openapitools.codegen.rust; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.read.ListAppender; +import ch.qos.logback.core.spi.FilterReply; import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.languages.AbstractRustCodegen; +import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.annotations.Test; @@ -74,6 +80,32 @@ public void testSanitizeIdentifier() { Assert.assertEquals(sanitizeSnakeCase.apply(""), ""); } + @Test + public void testSanitizeIdentifierWarnsOnlyOnRename() { + Logger logger = (Logger) LoggerFactory.getLogger(AbstractRustCodegen.class); + ListAppender listAppender = new ListAppender<>(); + // Other test classes run in parallel and log on the same logger, so keep only this test's names + listAppender.addFilter(new Filter() { + @Override + public FilterReply decide(ILoggingEvent event) { + return event.getFormattedMessage().contains("SanitizeWarningProbe") ? FilterReply.NEUTRAL : FilterReply.DENY; + } + }); + listAppender.start(); + logger.addAppender(listAppender); + try { + codegen.sanitizeIdentifier("sanitize-warning-probe", AbstractRustCodegen.CasingType.CAMEL_CASE, "p", "model", true); + Assert.assertTrue(listAppender.list.isEmpty()); + + codegen.sanitizeIdentifier("sanitize/warning/probe", AbstractRustCodegen.CasingType.CAMEL_CASE, "p", "model", true); + Assert.assertEquals(listAppender.list.size(), 1); + Assert.assertEquals(listAppender.list.get(0).getFormattedMessage(), + "SanitizeWarningProbe cannot be used as a model name. Renamed to SanitizeSlashWarningSlashProbe"); + } finally { + logger.detachAppender(listAppender); + } + } + @Test public void testToVarName() { // Should be converted to snake case diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java index 4ca3f4c70c91..9397d3f9e4a9 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/rust/RustClientCodegenTest.java @@ -350,6 +350,31 @@ public void testFreeFormObjectParams() throws IOException { } } + @Test + public void testExplodedDeepObjectMapQueryParams() throws IOException { + // exploded deepObject maps (typed or free-form) go through parse_deep_object like the non-explode branch + for (String library : new String[] {"reqwest", "reqwest-trait"}) { + Path target = Files.createTempDirectory("test"); + target.toFile().deleteOnExit(); + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("rust") + .setLibrary(library) + .setInputSpec("src/test/resources/3_0/rust/deep-object-free-form-query-param.yaml") + .setSkipOverwrite(false) + .setOutputDir(target.toAbsolutePath().toString().replace("\\", "/")); + List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); + files.forEach(File::deleteOnExit); + Path outputPath = Path.of(target.toString(), "/src/apis/default_api.rs"); + TestUtils.assertFileExists(outputPath); + // optional typed map, optional free-form object, required-nullable typed map + TestUtils.assertFileContains(outputPath, "crate::apis::parse_deep_object(\"filter\""); + TestUtils.assertFileContains(outputPath, "crate::apis::parse_deep_object(\"extra\""); + TestUtils.assertFileContains(outputPath, "crate::apis::parse_deep_object(\"scope\""); + TestUtils.assertFileNotContains(outputPath, "param_value.len()"); + TestUtils.assertFileNotContains(outputPath, "param_value.iter()"); + } + } + @Test public void testArrayWithObjectEnumValues() throws IOException { Path target = Files.createTempDirectory("test"); @@ -388,4 +413,40 @@ public void testReqwestTraitUuidParamsUseNamedLifetimes() throws IOException { "async fn list_widget_items<'id, 'run_id>(&self, id: &'id str, run_id: Option<&'run_id str>)"); TestUtils.assertFileNotContains(outputPath, "Option<&str>"); } + + @Test + public void testReqwestConfigurationDebugRedactsCredentials() throws IOException { + for (String library : new String[]{"reqwest", "reqwest-trait"}) { + Path outputPath = generateReqwestConfiguration(library, false); + TestUtils.assertFileNotContains(outputPath, "#[derive(Debug, Clone)]"); + TestUtils.assertFileContains(outputPath, + ".field(\"basic_auth\", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| \"[REDACTED]\"))))", + ".field(\"oauth_access_token\", &self.oauth_access_token.as_ref().map(|_| \"[REDACTED]\"))", + ".field(\"bearer_access_token\", &self.bearer_access_token.as_ref().map(|_| \"[REDACTED]\"))", + ".field(\"api_key\", &self.api_key)", + ".field(\"key\", &\"[REDACTED]\")"); + + Path tokenSourcePath = generateReqwestConfiguration(library, true); + TestUtils.assertFileNotContains(tokenSourcePath, "#[derive(Debug, Clone)]", "&self.token_source"); + TestUtils.assertFileContains(tokenSourcePath, ".field(\"token_source\", &\"[REDACTED]\")"); + } + } + + private Path generateReqwestConfiguration(String library, boolean supportTokenSource) throws IOException { + Path target = Files.createTempDirectory("test"); + target.toFile().deleteOnExit(); + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("rust") + .setLibrary(library) + .addAdditionalProperty("supportAsync", true) + .addAdditionalProperty("supportTokenSource", supportTokenSource) + .setInputSpec("src/test/resources/3_0/rust/petstore.yaml") + .setSkipOverwrite(false) + .setOutputDir(target.toAbsolutePath().toString().replace("\\", "/")); + List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); + files.forEach(File::deleteOnExit); + Path outputPath = Path.of(target.toString(), "/src/apis/configuration.rs"); + TestUtils.assertFileExists(outputPath); + return outputPath; + } } diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/conditional-serialization-value-types.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/conditional-serialization-value-types.yaml new file mode 100644 index 000000000000..e5c83202fb31 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/conditional-serialization-value-types.yaml @@ -0,0 +1,63 @@ +openapi: 3.0.3 +info: + title: conditional serialization value-type flags + version: 1.0.0 +paths: + /things: + post: + operationId: createThing + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateThingCommand' + responses: + '200': + description: created + patch: + operationId: updateThing + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateThingCommand' + responses: + '200': + description: updated +components: + schemas: + UpdateThingCommand: + type: object + description: an all-optional partial-update command; its only constructor is the public one + properties: + autoRenew: + type: boolean + period: + type: integer + graceDays: + type: integer + nullable: true + status: + type: string + enum: [active, suspended] + renewalMode: + type: string + enum: [manual, automatic] + nullable: true + note: + type: string + CreateThingCommand: + type: object + description: required value type keeps its non-nullable constructor parameter + required: + - name + - autoRenew + properties: + name: + type: string + autoRenew: + type: boolean + note: + type: string diff --git a/modules/openapi-generator/src/test/resources/3_0/python/exploded-model-query-param.yaml b/modules/openapi-generator/src/test/resources/3_0/python/exploded-model-query-param.yaml new file mode 100644 index 000000000000..e7a68518b4a0 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/python/exploded-model-query-param.yaml @@ -0,0 +1,66 @@ +openapi: 3.0.3 +info: + title: Exploded model query parameters + description: > + Query parameters whose schema is an object with declared properties, so the python + generator turns them into models rather than dicts. With the form/true defaults a model + must be exploded like a map, keyed by the names its properties carry on the wire. + version: 1.0.0 +servers: + - url: localhost:8080 +paths: + /items: + get: + operationId: listItems + parameters: + # a $ref to a component schema, with style and explode left at their defaults + - in: query + name: refFilter + schema: + $ref: '#/components/schemas/Filter' + # an inline object with declared properties, which becomes a model of its own + - in: query + name: inlineFilter + schema: + type: object + properties: + category: + type: string + # a oneOf model may hold a primitive or a list, neither of which has properties to explode + - in: query + name: oneOfFilter + schema: + $ref: '#/components/schemas/FilterOrTerm' + # deepObject and form without explode both keep a single parameter + - in: query + name: deepFilter + style: deepObject + explode: true + schema: + $ref: '#/components/schemas/Filter' + - in: query + name: flatFilter + style: form + explode: false + schema: + $ref: '#/components/schemas/Filter' + responses: + '200': + description: a list of items +components: + schemas: + Filter: + type: object + properties: + category: + type: string + # the wire name is not a python identifier, so the model attribute is renamed + createdDate:gte: + type: string + FilterOrTerm: + oneOf: + - $ref: '#/components/schemas/Filter' + - type: string + - type: array + items: + type: string diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/deep-object-free-form-query-param.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/deep-object-free-form-query-param.yaml new file mode 100644 index 000000000000..0a2c992091a4 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/rust/deep-object-free-form-query-param.yaml @@ -0,0 +1,36 @@ +openapi: 3.0.3 +info: + title: deep object params + version: 1.0.0 +paths: + /items: + get: + operationId: listItems + parameters: + - name: filter + in: query + style: deepObject + explode: true + schema: + type: object + additionalProperties: + type: string + - name: extra + in: query + style: deepObject + explode: true + schema: + type: object + - name: scope + in: query + required: true + style: deepObject + explode: true + schema: + type: object + nullable: true + additionalProperties: + type: string + responses: + '200': + description: ok diff --git a/samples/client/echo_api/go-external-refs/client.go b/samples/client/echo_api/go-external-refs/client.go index 83d93205607b..b4f4979079a5 100644 --- a/samples/client/echo_api/go-external-refs/client.go +++ b/samples/client/echo_api/go-external-refs/client.go @@ -195,10 +195,14 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri for i:=0;i list_items(scope, filter, extra) + + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**scope** | Option<[**std::collections::HashMap**](String.md)> | | [required] | +**filter** | Option<[**std::collections::HashMap**](String.md)> | | | +**extra** | Option<**serde_json::Value**> | | | + +### Return type + + (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/others/rust/reqwest-deep-object-free-form-query-param/git_push.sh b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/git_push.sh new file mode 100644 index 000000000000..a35991cd51a1 --- /dev/null +++ b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/git_push.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ -z "${git_host}" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \${git_host} to ${git_host}" +fi + +if [ -z "${git_user_id}" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \${git_user_id} to ${git_user_id}" +fi + +if [ -z "${git_repo_id}" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \${git_repo_id} to ${git_repo_id}" +fi + +if [ -z "${release_note}" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \${release_note} to ${release_note}" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "${release_note}" + +# Sets the new remote +if [ -z "$(git remote)" ]; then # git remote not defined + if [ -z "${GIT_TOKEN:-}" ]; then + echo "[INFO] \${GIT_TOKEN} (environment variable) is not set. Using the git credential in your environment." + git remote add origin "https://${git_host}/${git_user_id}/${git_repo_id}.git" + else + git remote add origin "https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git" + fi +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/configuration.rs b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/configuration.rs new file mode 100644 index 000000000000..d9be07bb2c4d --- /dev/null +++ b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/configuration.rs @@ -0,0 +1,52 @@ +/* + * deep object params + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +pub use reqwest::blocking::Client; + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::blocking::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "http://localhost".to_owned(), + user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), + client: reqwest::blocking::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/default_api.rs b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/default_api.rs new file mode 100644 index 000000000000..f9d4bf1e9e23 --- /dev/null +++ b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/default_api.rs @@ -0,0 +1,67 @@ +/* + * deep object params + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize, de::Error as _}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration, ContentType}; + + +/// struct for typed errors of method [`list_items`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListItemsError { + UnknownValue(serde_json::Value), +} + + +pub fn list_items(configuration: &configuration::Configuration, scope: Option>, filter: Option>, extra: Option) -> Result<(), Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_scope = scope; + let p_query_filter = filter; + let p_query_extra = extra; + + let uri_str = format!("{}/items", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_filter { + let params = crate::apis::parse_deep_object("filter", &serde_json::to_value(param_value)?); + req_builder = req_builder.query(¶ms); + } + if let Some(ref param_value) = p_query_extra { + let params = crate::apis::parse_deep_object("extra", &serde_json::to_value(param_value)?); + req_builder = req_builder.query(¶ms); + } + if let Some(ref param_value) = p_query_scope { + let params = crate::apis::parse_deep_object("scope", &serde_json::to_value(param_value)?); + req_builder = req_builder.query(¶ms); + }; + if let Some(ref param_value) = p_query_scope { + req_builder = req_builder.query(&[("scope", &serde_json::to_string(param_value)?)]); + }; + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + Ok(()) + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/mod.rs b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/mod.rs new file mode 100644 index 000000000000..fdcc89b36066 --- /dev/null +++ b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/apis/mod.rs @@ -0,0 +1,116 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + }, + serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +/// Internal use only +/// A content type supported by this client. +#[allow(dead_code)] +enum ContentType { + Json, + Text, + Unsupported(String) +} + +impl From<&str> for ContentType { + fn from(content_type: &str) -> Self { + if content_type.starts_with("application") && content_type.contains("json") { + return Self::Json; + } else if content_type.starts_with("text/plain") { + return Self::Text; + } else { + return Self::Unsupported(content_type.to_string()); + } + } +} + +pub mod default_api; + +pub mod configuration; diff --git a/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/lib.rs b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/lib.rs new file mode 100644 index 000000000000..e1520628d762 --- /dev/null +++ b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde_repr; +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/models/mod.rs b/samples/client/others/rust/reqwest-deep-object-free-form-query-param/src/models/mod.rs new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs b/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs index e5420eed77b0..c9dad4bfd4fa 100644 --- a/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest-regression-16119/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs b/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs index 77e3439ee0f0..a135aa2dc0da 100644 --- a/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/api-with-ref-param/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs b/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs index 70d170f44fd9..1ce1e81941ed 100644 --- a/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/composed-oneof/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs b/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs index 674a68aa4a04..6038efb3ab67 100644 --- a/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/emptyObject/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/enum-query-params/src/apis/configuration.rs b/samples/client/others/rust/reqwest/enum-query-params/src/apis/configuration.rs index 1659ab96afdd..ec4430bfdf5a 100644 --- a/samples/client/others/rust/reqwest/enum-query-params/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/enum-query-params/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/multipart-async/src/apis/configuration.rs b/samples/client/others/rust/reqwest/multipart-async/src/apis/configuration.rs index ffc218c8f93f..aa01a227bdf9 100644 --- a/samples/client/others/rust/reqwest/multipart-async/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/multipart-async/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/nullable-enum-query-params/src/apis/configuration.rs b/samples/client/others/rust/reqwest/nullable-enum-query-params/src/apis/configuration.rs index f5989abeab40..16e1e3922eeb 100644 --- a/samples/client/others/rust/reqwest/nullable-enum-query-params/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/nullable-enum-query-params/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs b/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs index 9d11dd3c97a1..ced995ba8b95 100644 --- a/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/oneOf-array-map/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs b/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs index 68d2697c86ea..bd180b77c105 100644 --- a/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/oneOf-reuseRef/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs b/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs index 20441dda2e9a..ff1a19eac9d6 100644 --- a/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs +++ b/samples/client/others/rust/reqwest/oneOf/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ApiResponse.cs index 616d4f5a451c..4e4ea7a29af6 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ApiResponse.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ApiResponse.cs @@ -38,11 +38,11 @@ public partial class ApiResponse : IEquatable, IValidatableObject /// code. /// type. /// message. - public ApiResponse(int code = default, string type = default, string message = default) + public ApiResponse(int? code = default, string type = default, string message = default) { - this._Code = code; - if (this.Code != null) + if (code != null) { + this._Code = code.Value; this._flagCode = true; } this._Type = type; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/AppleReq.cs index 071709bc6254..3c6e86b9dd16 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/AppleReq.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/AppleReq.cs @@ -42,7 +42,7 @@ protected AppleReq() { } /// /// cultivar (required). /// mealy. - public AppleReq(string cultivar = default, bool mealy = default) + public AppleReq(string cultivar = default, bool? mealy = default) { // to ensure "cultivar" is required (not null) if (cultivar == null) @@ -50,9 +50,9 @@ public AppleReq(string cultivar = default, bool mealy = default) throw new ArgumentNullException("cultivar is a required property for AppleReq and cannot be null"); } this._Cultivar = cultivar; - this._Mealy = mealy; - if (this.Mealy != null) + if (mealy != null) { + this._Mealy = mealy.Value; this._flagMealy = true; } } diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Banana.cs index 40effe24e769..8fa191bb07d9 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Banana.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Banana.cs @@ -36,11 +36,11 @@ public partial class Banana : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// lengthCm. - public Banana(decimal lengthCm = default) + public Banana(decimal? lengthCm = default) { - this._LengthCm = lengthCm; - if (this.LengthCm != null) + if (lengthCm != null) { + this._LengthCm = lengthCm.Value; this._flagLengthCm = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/BananaReq.cs index ef540c9d2a5b..c77084eec25a 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/BananaReq.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/BananaReq.cs @@ -42,12 +42,12 @@ protected BananaReq() { } /// /// lengthCm (required). /// sweet. - public BananaReq(decimal lengthCm = default, bool sweet = default) + public BananaReq(decimal lengthCm = default, bool? sweet = default) { this._LengthCm = lengthCm; - this._Sweet = sweet; - if (this.Sweet != null) + if (sweet != null) { + this._Sweet = sweet.Value; this._flagSweet = true; } } diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Cat.cs index 6b5189557252..eda5df130c9a 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Cat.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Cat.cs @@ -47,11 +47,11 @@ protected Cat() /// declawed. /// className (required) (default to "Cat"). /// color (default to "red"). - public Cat(bool declawed = default, string className = @"Cat", string color = @"red") : base(className, color) + public Cat(bool? declawed = default, string className = @"Cat", string color = @"red") : base(className, color) { - this._Declawed = declawed; - if (this.Declawed != null) + if (declawed != null) { + this._Declawed = declawed.Value; this._flagDeclawed = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Category.cs index c15741a47c8f..4a38856efa12 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Category.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Category.cs @@ -45,7 +45,7 @@ protected Category() /// /// id. /// name (required) (default to "default-name"). - public Category(long id = default, string name = @"default-name") + public Category(long? id = default, string name = @"default-name") { // to ensure "name" is required (not null) if (name == null) @@ -53,9 +53,9 @@ public Category(long id = default, string name = @"default-name") throw new ArgumentNullException("name is a required property for Category and cannot be null"); } this._Name = name; - this._Id = id; - if (this.Id != null) + if (id != null) { + this._Id = id.Value; this._flagId = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs index cbf300737196..3923331b6697 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -36,11 +36,11 @@ public partial class DateOnlyClass : IEquatable, IValidatableObje /// Initializes a new instance of the class. /// /// dateOnlyProperty. - public DateOnlyClass(DateTime dateOnlyProperty = default) + public DateOnlyClass(DateTime? dateOnlyProperty = default) { - this._DateOnlyProperty = dateOnlyProperty; - if (this.DateOnlyProperty != null) + if (dateOnlyProperty != null) { + this._DateOnlyProperty = dateOnlyProperty.Value; this._flagDateOnlyProperty = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumArrays.cs index 774f416dcaec..aa75b5a918b7 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumArrays.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumArrays.cs @@ -103,9 +103,9 @@ public enum ArrayEnumEnum /// arrayEnum. public EnumArrays(JustSymbolEnum? justSymbol = default, List arrayEnum = default) { - this._JustSymbol = justSymbol; - if (this.JustSymbol != null) + if (justSymbol != null) { + this._JustSymbol = justSymbol.Value; this._flagJustSymbol = true; } this._ArrayEnum = arrayEnum; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs index e3fd5593c813..6158d41ee7cc 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EnumTest.cs @@ -450,44 +450,44 @@ protected EnumTest() public EnumTest(EnumStringEnum? enumString = default, EnumStringRequiredEnum enumStringRequired = default, EnumIntegerEnum? enumInteger = default, EnumIntegerOnlyEnum? enumIntegerOnly = default, EnumNumberEnum? enumNumber = default, OuterEnum? outerEnum = default, OuterEnumInteger? outerEnumInteger = default, OuterEnumDefaultValue? outerEnumDefaultValue = default, OuterEnumIntegerDefaultValue? outerEnumIntegerDefaultValue = default) { this._EnumStringRequired = enumStringRequired; - this._EnumString = enumString; - if (this.EnumString != null) + if (enumString != null) { + this._EnumString = enumString.Value; this._flagEnumString = true; } - this._EnumInteger = enumInteger; - if (this.EnumInteger != null) + if (enumInteger != null) { + this._EnumInteger = enumInteger.Value; this._flagEnumInteger = true; } - this._EnumIntegerOnly = enumIntegerOnly; - if (this.EnumIntegerOnly != null) + if (enumIntegerOnly != null) { + this._EnumIntegerOnly = enumIntegerOnly.Value; this._flagEnumIntegerOnly = true; } - this._EnumNumber = enumNumber; - if (this.EnumNumber != null) + if (enumNumber != null) { + this._EnumNumber = enumNumber.Value; this._flagEnumNumber = true; } - this._OuterEnum = outerEnum; - if (this.OuterEnum != null) + if (outerEnum != null) { + this._OuterEnum = outerEnum.Value; this._flagOuterEnum = true; } - this._OuterEnumInteger = outerEnumInteger; - if (this.OuterEnumInteger != null) + if (outerEnumInteger != null) { + this._OuterEnumInteger = outerEnumInteger.Value; this._flagOuterEnumInteger = true; } - this._OuterEnumDefaultValue = outerEnumDefaultValue; - if (this.OuterEnumDefaultValue != null) + if (outerEnumDefaultValue != null) { + this._OuterEnumDefaultValue = outerEnumDefaultValue.Value; this._flagOuterEnumDefaultValue = true; } - this._OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue; - if (this.OuterEnumIntegerDefaultValue != null) + if (outerEnumIntegerDefaultValue != null) { + this._OuterEnumIntegerDefaultValue = outerEnumIntegerDefaultValue.Value; this._flagOuterEnumIntegerDefaultValue = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/FormatTest.cs index cb78ccd5bd53..09fae29f3c7e 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/FormatTest.cs @@ -71,7 +71,7 @@ protected FormatTest() /// stringFormattedAsDecimalRequired (required). /// duplicatePropertyName2. /// duplicatePropertyName. - public FormatTest(int integer = default, int int32 = default, int int32Range = default, int int64Positive = default, int int64Negative = default, int int64PositiveExclusive = default, int int64NegativeExclusive = default, uint unsignedInteger = default, long int64 = default, ulong unsignedLong = default, decimal number = default, float varFloat = default, double varDouble = default, decimal varDecimal = default, string varString = default, byte[] varByte = default, System.IO.Stream binary = default, DateTime date = default, DateTime dateTime = default, Guid uuid = default, string password = default, string patternWithDigits = default, string patternWithDigitsAndDelimiter = default, string patternWithBackslash = default, decimal stringFormattedAsDecimal = default, decimal stringFormattedAsDecimalRequired = default, string duplicatePropertyName2 = default, string duplicatePropertyName = default) + public FormatTest(int? integer = default, int? int32 = default, int? int32Range = default, int? int64Positive = default, int? int64Negative = default, int? int64PositiveExclusive = default, int? int64NegativeExclusive = default, uint? unsignedInteger = default, long? int64 = default, ulong? unsignedLong = default, decimal number = default, float? varFloat = default, double? varDouble = default, decimal? varDecimal = default, string varString = default, byte[] varByte = default, System.IO.Stream binary = default, DateTime date = default, DateTime? dateTime = default, Guid? uuid = default, string password = default, string patternWithDigits = default, string patternWithDigitsAndDelimiter = default, string patternWithBackslash = default, decimal? stringFormattedAsDecimal = default, decimal stringFormattedAsDecimalRequired = default, string duplicatePropertyName2 = default, string duplicatePropertyName = default) { this._Number = number; // to ensure "varByte" is required (not null) @@ -88,69 +88,69 @@ public FormatTest(int integer = default, int int32 = default, int int32Range = d } this._Password = password; this._StringFormattedAsDecimalRequired = stringFormattedAsDecimalRequired; - this._Integer = integer; - if (this.Integer != null) + if (integer != null) { + this._Integer = integer.Value; this._flagInteger = true; } - this._Int32 = int32; - if (this.Int32 != null) + if (int32 != null) { + this._Int32 = int32.Value; this._flagInt32 = true; } - this._Int32Range = int32Range; - if (this.Int32Range != null) + if (int32Range != null) { + this._Int32Range = int32Range.Value; this._flagInt32Range = true; } - this._Int64Positive = int64Positive; - if (this.Int64Positive != null) + if (int64Positive != null) { + this._Int64Positive = int64Positive.Value; this._flagInt64Positive = true; } - this._Int64Negative = int64Negative; - if (this.Int64Negative != null) + if (int64Negative != null) { + this._Int64Negative = int64Negative.Value; this._flagInt64Negative = true; } - this._Int64PositiveExclusive = int64PositiveExclusive; - if (this.Int64PositiveExclusive != null) + if (int64PositiveExclusive != null) { + this._Int64PositiveExclusive = int64PositiveExclusive.Value; this._flagInt64PositiveExclusive = true; } - this._Int64NegativeExclusive = int64NegativeExclusive; - if (this.Int64NegativeExclusive != null) + if (int64NegativeExclusive != null) { + this._Int64NegativeExclusive = int64NegativeExclusive.Value; this._flagInt64NegativeExclusive = true; } - this._UnsignedInteger = unsignedInteger; - if (this.UnsignedInteger != null) + if (unsignedInteger != null) { + this._UnsignedInteger = unsignedInteger.Value; this._flagUnsignedInteger = true; } - this._Int64 = int64; - if (this.Int64 != null) + if (int64 != null) { + this._Int64 = int64.Value; this._flagInt64 = true; } - this._UnsignedLong = unsignedLong; - if (this.UnsignedLong != null) + if (unsignedLong != null) { + this._UnsignedLong = unsignedLong.Value; this._flagUnsignedLong = true; } - this._Float = varFloat; - if (this.Float != null) + if (varFloat != null) { + this._Float = varFloat.Value; this._flagFloat = true; } - this._Double = varDouble; - if (this.Double != null) + if (varDouble != null) { + this._Double = varDouble.Value; this._flagDouble = true; } - this._Decimal = varDecimal; - if (this.Decimal != null) + if (varDecimal != null) { + this._Decimal = varDecimal.Value; this._flagDecimal = true; } this._String = varString; @@ -163,14 +163,14 @@ public FormatTest(int integer = default, int int32 = default, int int32Range = d { this._flagBinary = true; } - this._DateTime = dateTime; - if (this.DateTime != null) + if (dateTime != null) { + this._DateTime = dateTime.Value; this._flagDateTime = true; } - this._Uuid = uuid; - if (this.Uuid != null) + if (uuid != null) { + this._Uuid = uuid.Value; this._flagUuid = true; } this._PatternWithDigits = patternWithDigits; @@ -188,9 +188,9 @@ public FormatTest(int integer = default, int int32 = default, int int32Range = d { this._flagPatternWithBackslash = true; } - this._StringFormattedAsDecimal = stringFormattedAsDecimal; - if (this.StringFormattedAsDecimal != null) + if (stringFormattedAsDecimal != null) { + this._StringFormattedAsDecimal = stringFormattedAsDecimal.Value; this._flagStringFormattedAsDecimal = true; } this._DuplicatePropertyName2 = duplicatePropertyName2; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs index 6da43bec2431..187bca7b07fb 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs @@ -39,21 +39,21 @@ public partial class MixedPropertiesAndAdditionalPropertiesClass : IEquatableuuid. /// dateTime. /// map. - public MixedPropertiesAndAdditionalPropertiesClass(Guid uuidWithPattern = default, Guid uuid = default, DateTime dateTime = default, Dictionary map = default) + public MixedPropertiesAndAdditionalPropertiesClass(Guid? uuidWithPattern = default, Guid? uuid = default, DateTime? dateTime = default, Dictionary map = default) { - this._UuidWithPattern = uuidWithPattern; - if (this.UuidWithPattern != null) + if (uuidWithPattern != null) { + this._UuidWithPattern = uuidWithPattern.Value; this._flagUuidWithPattern = true; } - this._Uuid = uuid; - if (this.Uuid != null) + if (uuid != null) { + this._Uuid = uuid.Value; this._flagUuid = true; } - this._DateTime = dateTime; - if (this.DateTime != null) + if (dateTime != null) { + this._DateTime = dateTime.Value; this._flagDateTime = true; } this._Map = map; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Model200Response.cs index a04ab5a4b683..482a70ef3e78 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Model200Response.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Model200Response.cs @@ -37,11 +37,11 @@ public partial class Model200Response : IEquatable, IValidatab /// /// name. /// varClass. - public Model200Response(int name = default, string varClass = default) + public Model200Response(int? name = default, string varClass = default) { - this._Name = name; - if (this.Name != null) + if (name != null) { + this._Name = name.Value; this._flagName = true; } this._Class = varClass; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/NumberOnly.cs index d5eeb4624871..c5143c1a5a62 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/NumberOnly.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/NumberOnly.cs @@ -39,11 +39,11 @@ public partial class NumberOnly : IEquatable, IValidatableObject /// Initializes a new instance of the class. /// /// justNumber. - public NumberOnly(decimal justNumber = default) + public NumberOnly(decimal? justNumber = default) { - this._JustNumber = justNumber; - if (this.JustNumber != null) + if (justNumber != null) { + this._JustNumber = justNumber.Value; this._flagJustNumber = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs index 411cdf8a15af..2fe23672496a 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs @@ -39,16 +39,16 @@ public partial class ObjectWithDeprecatedFields : IEquatableid. /// deprecatedRef. /// bars. - public ObjectWithDeprecatedFields(string uuid = default, decimal id = default, DeprecatedObject deprecatedRef = default, List bars = default) + public ObjectWithDeprecatedFields(string uuid = default, decimal? id = default, DeprecatedObject deprecatedRef = default, List bars = default) { this._Uuid = uuid; if (this.Uuid != null) { this._flagUuid = true; } - this._Id = id; - if (this.Id != null) + if (id != null) { + this._Id = id.Value; this._flagId = true; } this._DeprecatedRef = deprecatedRef; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Order.cs index c660fee22884..ff5a01987383 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Order.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Order.cs @@ -94,31 +94,31 @@ public bool ShouldSerializeStatus() /// shipDate. /// Order Status. /// complete (default to false). - public Order(long id = default, long petId = default, int quantity = default, DateTime shipDate = default, StatusEnum? status = default, bool complete = false) + public Order(long? id = default, long? petId = default, int? quantity = default, DateTime? shipDate = default, StatusEnum? status = default, bool complete = false) { - this._Id = id; - if (this.Id != null) + if (id != null) { + this._Id = id.Value; this._flagId = true; } - this._PetId = petId; - if (this.PetId != null) + if (petId != null) { + this._PetId = petId.Value; this._flagPetId = true; } - this._Quantity = quantity; - if (this.Quantity != null) + if (quantity != null) { + this._Quantity = quantity.Value; this._flagQuantity = true; } - this._ShipDate = shipDate; - if (this.ShipDate != null) + if (shipDate != null) { + this._ShipDate = shipDate.Value; this._flagShipDate = true; } - this._Status = status; - if (this.Status != null) + if (status != null) { + this._Status = status.Value; this._flagStatus = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/OuterComposite.cs index a73853ef32ec..406c8c52f0e8 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/OuterComposite.cs @@ -38,11 +38,11 @@ public partial class OuterComposite : IEquatable, IValidatableOb /// myNumber. /// myString. /// myBoolean. - public OuterComposite(decimal myNumber = default, string myString = default, bool myBoolean = default) + public OuterComposite(decimal? myNumber = default, string myString = default, bool? myBoolean = default) { - this._MyNumber = myNumber; - if (this.MyNumber != null) + if (myNumber != null) { + this._MyNumber = myNumber.Value; this._flagMyNumber = true; } this._MyString = myString; @@ -50,9 +50,9 @@ public OuterComposite(decimal myNumber = default, string myString = default, boo { this._flagMyString = true; } - this._MyBoolean = myBoolean; - if (this.MyBoolean != null) + if (myBoolean != null) { + this._MyBoolean = myBoolean.Value; this._flagMyBoolean = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Pet.cs index beff340cf26e..8b1bd25ba47d 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Pet.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Pet.cs @@ -102,7 +102,7 @@ protected Pet() /// photoUrls (required). /// tags. /// pet status in the store. - public Pet(long id = default, Category category = default, string name = default, List photoUrls = default, List tags = default, StatusEnum? status = default) + public Pet(long? id = default, Category category = default, string name = default, List photoUrls = default, List tags = default, StatusEnum? status = default) { // to ensure "name" is required (not null) if (name == null) @@ -116,9 +116,9 @@ public Pet(long id = default, Category category = default, string name = default throw new ArgumentNullException("photoUrls is a required property for Pet and cannot be null"); } this._PhotoUrls = photoUrls; - this._Id = id; - if (this.Id != null) + if (id != null) { + this._Id = id.Value; this._flagId = true; } this._Category = category; @@ -131,9 +131,9 @@ public Pet(long id = default, Category category = default, string name = default { this._flagTags = true; } - this._Status = status; - if (this.Status != null) + if (status != null) { + this._Status = status.Value; this._flagStatus = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RequiredClass.cs index eafc6ff0b6cd..db4dbf576bcc 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RequiredClass.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RequiredClass.cs @@ -853,7 +853,7 @@ protected RequiredClass() /// requiredNotnullableArrayOfString (required). /// notrequiredNullableArrayOfString. /// notrequiredNotnullableArrayOfString. - public RequiredClass(int? requiredNullableIntegerProp = default, int requiredNotnullableintegerProp = default, int? notRequiredNullableIntegerProp = default, int notRequiredNotnullableintegerProp = default, string requiredNullableStringProp = default, string requiredNotnullableStringProp = default, string notrequiredNullableStringProp = default, string notrequiredNotnullableStringProp = default, bool? requiredNullableBooleanProp = default, bool requiredNotnullableBooleanProp = default, bool? notrequiredNullableBooleanProp = default, bool notrequiredNotnullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime requiredNotNullableDateProp = default, DateTime? notRequiredNullableDateProp = default, DateTime notRequiredNotnullableDateProp = default, DateTime requiredNotnullableDatetimeProp = default, DateTime? requiredNullableDatetimeProp = default, DateTime? notrequiredNullableDatetimeProp = default, DateTime notrequiredNotnullableDatetimeProp = default, RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default, RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default, NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default, NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default, RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default, RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default, NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default, NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default, RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default, RequiredNullableEnumStringEnum requiredNullableEnumString = default, NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default, NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default, OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default, OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default, OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default, Guid? requiredNullableUuid = default, Guid requiredNotnullableUuid = default, Guid? notrequiredNullableUuid = default, Guid notrequiredNotnullableUuid = default, List requiredNullableArrayOfString = default, List requiredNotnullableArrayOfString = default, List notrequiredNullableArrayOfString = default, List notrequiredNotnullableArrayOfString = default) + public RequiredClass(int? requiredNullableIntegerProp = default, int requiredNotnullableintegerProp = default, int? notRequiredNullableIntegerProp = default, int? notRequiredNotnullableintegerProp = default, string requiredNullableStringProp = default, string requiredNotnullableStringProp = default, string notrequiredNullableStringProp = default, string notrequiredNotnullableStringProp = default, bool? requiredNullableBooleanProp = default, bool requiredNotnullableBooleanProp = default, bool? notrequiredNullableBooleanProp = default, bool? notrequiredNotnullableBooleanProp = default, DateTime? requiredNullableDateProp = default, DateTime requiredNotNullableDateProp = default, DateTime? notRequiredNullableDateProp = default, DateTime? notRequiredNotnullableDateProp = default, DateTime requiredNotnullableDatetimeProp = default, DateTime? requiredNullableDatetimeProp = default, DateTime? notrequiredNullableDatetimeProp = default, DateTime? notrequiredNotnullableDatetimeProp = default, RequiredNullableEnumIntegerEnum requiredNullableEnumInteger = default, RequiredNotnullableEnumIntegerEnum requiredNotnullableEnumInteger = default, NotrequiredNullableEnumIntegerEnum? notrequiredNullableEnumInteger = default, NotrequiredNotnullableEnumIntegerEnum? notrequiredNotnullableEnumInteger = default, RequiredNullableEnumIntegerOnlyEnum requiredNullableEnumIntegerOnly = default, RequiredNotnullableEnumIntegerOnlyEnum requiredNotnullableEnumIntegerOnly = default, NotrequiredNullableEnumIntegerOnlyEnum? notrequiredNullableEnumIntegerOnly = default, NotrequiredNotnullableEnumIntegerOnlyEnum? notrequiredNotnullableEnumIntegerOnly = default, RequiredNotnullableEnumStringEnum requiredNotnullableEnumString = default, RequiredNullableEnumStringEnum requiredNullableEnumString = default, NotrequiredNullableEnumStringEnum? notrequiredNullableEnumString = default, NotrequiredNotnullableEnumStringEnum? notrequiredNotnullableEnumString = default, OuterEnumDefaultValue requiredNullableOuterEnumDefaultValue = default, OuterEnumDefaultValue requiredNotnullableOuterEnumDefaultValue = default, OuterEnumDefaultValue? notrequiredNullableOuterEnumDefaultValue = default, OuterEnumDefaultValue? notrequiredNotnullableOuterEnumDefaultValue = default, Guid? requiredNullableUuid = default, Guid requiredNotnullableUuid = default, Guid? notrequiredNullableUuid = default, Guid? notrequiredNotnullableUuid = default, List requiredNullableArrayOfString = default, List requiredNotnullableArrayOfString = default, List notrequiredNullableArrayOfString = default, List notrequiredNotnullableArrayOfString = default) { // to ensure "requiredNullableIntegerProp" is required (not null) if (requiredNullableIntegerProp == null) @@ -927,9 +927,9 @@ public RequiredClass(int? requiredNullableIntegerProp = default, int requiredNot { this._flagNotRequiredNullableIntegerProp = true; } - this._NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp; - if (this.NotRequiredNotnullableintegerProp != null) + if (notRequiredNotnullableintegerProp != null) { + this._NotRequiredNotnullableintegerProp = notRequiredNotnullableintegerProp.Value; this._flagNotRequiredNotnullableintegerProp = true; } this._NotrequiredNullableStringProp = notrequiredNullableStringProp; @@ -947,9 +947,9 @@ public RequiredClass(int? requiredNullableIntegerProp = default, int requiredNot { this._flagNotrequiredNullableBooleanProp = true; } - this._NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp; - if (this.NotrequiredNotnullableBooleanProp != null) + if (notrequiredNotnullableBooleanProp != null) { + this._NotrequiredNotnullableBooleanProp = notrequiredNotnullableBooleanProp.Value; this._flagNotrequiredNotnullableBooleanProp = true; } this._NotRequiredNullableDateProp = notRequiredNullableDateProp; @@ -957,9 +957,9 @@ public RequiredClass(int? requiredNullableIntegerProp = default, int requiredNot { this._flagNotRequiredNullableDateProp = true; } - this._NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp; - if (this.NotRequiredNotnullableDateProp != null) + if (notRequiredNotnullableDateProp != null) { + this._NotRequiredNotnullableDateProp = notRequiredNotnullableDateProp.Value; this._flagNotRequiredNotnullableDateProp = true; } this._NotrequiredNullableDatetimeProp = notrequiredNullableDatetimeProp; @@ -967,49 +967,49 @@ public RequiredClass(int? requiredNullableIntegerProp = default, int requiredNot { this._flagNotrequiredNullableDatetimeProp = true; } - this._NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp; - if (this.NotrequiredNotnullableDatetimeProp != null) + if (notrequiredNotnullableDatetimeProp != null) { + this._NotrequiredNotnullableDatetimeProp = notrequiredNotnullableDatetimeProp.Value; this._flagNotrequiredNotnullableDatetimeProp = true; } - this._NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger; - if (this.NotrequiredNullableEnumInteger != null) + if (notrequiredNullableEnumInteger != null) { + this._NotrequiredNullableEnumInteger = notrequiredNullableEnumInteger.Value; this._flagNotrequiredNullableEnumInteger = true; } - this._NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger; - if (this.NotrequiredNotnullableEnumInteger != null) + if (notrequiredNotnullableEnumInteger != null) { + this._NotrequiredNotnullableEnumInteger = notrequiredNotnullableEnumInteger.Value; this._flagNotrequiredNotnullableEnumInteger = true; } - this._NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly; - if (this.NotrequiredNullableEnumIntegerOnly != null) + if (notrequiredNullableEnumIntegerOnly != null) { + this._NotrequiredNullableEnumIntegerOnly = notrequiredNullableEnumIntegerOnly.Value; this._flagNotrequiredNullableEnumIntegerOnly = true; } - this._NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly; - if (this.NotrequiredNotnullableEnumIntegerOnly != null) + if (notrequiredNotnullableEnumIntegerOnly != null) { + this._NotrequiredNotnullableEnumIntegerOnly = notrequiredNotnullableEnumIntegerOnly.Value; this._flagNotrequiredNotnullableEnumIntegerOnly = true; } - this._NotrequiredNullableEnumString = notrequiredNullableEnumString; - if (this.NotrequiredNullableEnumString != null) + if (notrequiredNullableEnumString != null) { + this._NotrequiredNullableEnumString = notrequiredNullableEnumString.Value; this._flagNotrequiredNullableEnumString = true; } - this._NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString; - if (this.NotrequiredNotnullableEnumString != null) + if (notrequiredNotnullableEnumString != null) { + this._NotrequiredNotnullableEnumString = notrequiredNotnullableEnumString.Value; this._flagNotrequiredNotnullableEnumString = true; } - this._NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue; - if (this.NotrequiredNullableOuterEnumDefaultValue != null) + if (notrequiredNullableOuterEnumDefaultValue != null) { + this._NotrequiredNullableOuterEnumDefaultValue = notrequiredNullableOuterEnumDefaultValue.Value; this._flagNotrequiredNullableOuterEnumDefaultValue = true; } - this._NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue; - if (this.NotrequiredNotnullableOuterEnumDefaultValue != null) + if (notrequiredNotnullableOuterEnumDefaultValue != null) { + this._NotrequiredNotnullableOuterEnumDefaultValue = notrequiredNotnullableOuterEnumDefaultValue.Value; this._flagNotrequiredNotnullableOuterEnumDefaultValue = true; } this._NotrequiredNullableUuid = notrequiredNullableUuid; @@ -1017,9 +1017,9 @@ public RequiredClass(int? requiredNullableIntegerProp = default, int requiredNot { this._flagNotrequiredNullableUuid = true; } - this._NotrequiredNotnullableUuid = notrequiredNotnullableUuid; - if (this.NotrequiredNotnullableUuid != null) + if (notrequiredNotnullableUuid != null) { + this._NotrequiredNotnullableUuid = notrequiredNotnullableUuid.Value; this._flagNotrequiredNotnullableUuid = true; } this._NotrequiredNullableArrayOfString = notrequiredNullableArrayOfString; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Return.cs index b14f39f9b6ba..997837d01848 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Return.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Return.cs @@ -47,7 +47,7 @@ protected Return() /// varLock (required). /// varAbstract (required). /// varUnsafe. - public Return(int varReturn = default, string varLock = default, string varAbstract = default, string varUnsafe = default) + public Return(int? varReturn = default, string varLock = default, string varAbstract = default, string varUnsafe = default) { // to ensure "varLock" is required (not null) if (varLock == null) @@ -61,9 +61,9 @@ public Return(int varReturn = default, string varLock = default, string varAbstr throw new ArgumentNullException("varAbstract is a required property for Return and cannot be null"); } this._Abstract = varAbstract; - this._VarReturn = varReturn; - if (this.VarReturn != null) + if (varReturn != null) { + this._VarReturn = varReturn.Value; this._flagVarReturn = true; } this._Unsafe = varUnsafe; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RolesReportsHash.cs index f63539ea26e2..0077a271cc21 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RolesReportsHash.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/RolesReportsHash.cs @@ -37,11 +37,11 @@ public partial class RolesReportsHash : IEquatable, IValidatab /// /// roleUuid. /// role. - public RolesReportsHash(Guid roleUuid = default, RolesReportsHashRole role = default) + public RolesReportsHash(Guid? roleUuid = default, RolesReportsHashRole role = default) { - this._RoleUuid = roleUuid; - if (this.RoleUuid != null) + if (roleUuid != null) { + this._RoleUuid = roleUuid.Value; this._flagRoleUuid = true; } this._Role = role; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/SpecialModelName.cs index bfb952dcd355..e0408e63a083 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/SpecialModelName.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/SpecialModelName.cs @@ -37,11 +37,11 @@ public partial class SpecialModelName : IEquatable, IValidatab /// /// specialPropertyName. /// varSpecialModelName. - public SpecialModelName(long specialPropertyName = default, string varSpecialModelName = default) + public SpecialModelName(long? specialPropertyName = default, string varSpecialModelName = default) { - this._SpecialPropertyName = specialPropertyName; - if (this.SpecialPropertyName != null) + if (specialPropertyName != null) { + this._SpecialPropertyName = specialPropertyName.Value; this._flagSpecialPropertyName = true; } this._VarSpecialModelName = varSpecialModelName; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Tag.cs index 71370874b768..877c8249222f 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Tag.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Tag.cs @@ -37,11 +37,11 @@ public partial class Tag : IEquatable, IValidatableObject /// /// id. /// name. - public Tag(long id = default, string name = default) + public Tag(long? id = default, string name = default) { - this._Id = id; - if (this.Id != null) + if (id != null) { + this._Id = id.Value; this._flagId = true; } this._Name = name; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResult.cs index a91f85d19849..b8ebba133514 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResult.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResult.cs @@ -66,9 +66,9 @@ public bool ShouldSerializeCode() /// list of named parameters for current message. public TestResult(TestResultCode? code = default, string uuid = default, Dictionary data = default) { - this._Code = code; - if (this.Code != null) + if (code != null) { + this._Code = code.Value; this._flagCode = true; } this._Uuid = uuid; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/User.cs index 0d5b93e58ffa..203166eeeec3 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/User.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/User.cs @@ -47,11 +47,11 @@ public partial class User : IEquatable, IValidatableObject /// test code generation for nullable objects. Value must be a map of strings to values or the 'null' value.. /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. See https://github.com/OAI/OpenAPI-Specification/issues/1389. /// test code generation for any type Here the 'type' attribute is not specified, which means the value can be anything, including the null value, string, number, boolean, array or object. The 'nullable' attribute does not change the allowed values.. - public User(long id = default, string username = default, string firstName = default, string lastName = default, string email = default, string password = default, string phone = default, int userStatus = default, Object objectWithNoDeclaredProps = default, Object objectWithNoDeclaredPropsNullable = default, Object anyTypeProp = default, Object anyTypePropNullable = default) + public User(long? id = default, string username = default, string firstName = default, string lastName = default, string email = default, string password = default, string phone = default, int? userStatus = default, Object objectWithNoDeclaredProps = default, Object objectWithNoDeclaredPropsNullable = default, Object anyTypeProp = default, Object anyTypePropNullable = default) { - this._Id = id; - if (this.Id != null) + if (id != null) { + this._Id = id.Value; this._flagId = true; } this._Username = username; @@ -84,9 +84,9 @@ public User(long id = default, string username = default, string firstName = def { this._flagPhone = true; } - this._UserStatus = userStatus; - if (this.UserStatus != null) + if (userStatus != null) { + this._UserStatus = userStatus.Value; this._flagUserStatus = true; } this._ObjectWithNoDeclaredProps = objectWithNoDeclaredProps; diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Whale.cs index 1455bffc70d3..f5e732af315a 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Whale.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Whale.cs @@ -46,7 +46,7 @@ protected Whale() /// hasBaleen. /// hasTeeth. /// className (required). - public Whale(bool hasBaleen = default, bool hasTeeth = default, string className = default) + public Whale(bool? hasBaleen = default, bool? hasTeeth = default, string className = default) { // to ensure "className" is required (not null) if (className == null) @@ -54,14 +54,14 @@ public Whale(bool hasBaleen = default, bool hasTeeth = default, string className throw new ArgumentNullException("className is a required property for Whale and cannot be null"); } this._ClassName = className; - this._HasBaleen = hasBaleen; - if (this.HasBaleen != null) + if (hasBaleen != null) { + this._HasBaleen = hasBaleen.Value; this._flagHasBaleen = true; } - this._HasTeeth = hasTeeth; - if (this.HasTeeth != null) + if (hasTeeth != null) { + this._HasTeeth = hasTeeth.Value; this._flagHasTeeth = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Zebra.cs index 9717a1ace7d4..de06d726d8f7 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Zebra.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Zebra.cs @@ -104,9 +104,9 @@ public Zebra(TypeEnum? type = default, string className = default) throw new ArgumentNullException("className is a required property for Zebra and cannot be null"); } this._ClassName = className; - this._Type = type; - if (this.Type != null) + if (type != null) { + this._Type = type.Value; this._flagType = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs index 262a2a49c3f9..9804d01afe37 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs @@ -83,9 +83,9 @@ public bool ShouldSerializeZeroBasedEnum() /// zeroBasedEnum. public ZeroBasedEnumClass(ZeroBasedEnumEnum? zeroBasedEnum = default) { - this._ZeroBasedEnum = zeroBasedEnum; - if (this.ZeroBasedEnum != null) + if (zeroBasedEnum != null) { + this._ZeroBasedEnum = zeroBasedEnum.Value; this._flagZeroBasedEnum = true; } this.AdditionalProperties = new Dictionary(); diff --git a/samples/client/petstore/go/go-petstore/client.go b/samples/client/petstore/go/go-petstore/client.go index 85036942f54b..6489ad3c5a3d 100644 --- a/samples/client/petstore/go/go-petstore/client.go +++ b/samples/client/petstore/go/go-petstore/client.go @@ -195,10 +195,14 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri for i:=0;i, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs index 3ae7dbe56254..9b5e4d72387a 100644 --- a/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/name-mapping/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs index fb9eb258b86c..4ac874f55deb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest_middleware::ClientWithMiddleware; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/configuration.rs index c66c3d1c8ecb..e34cb8016bf2 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/configuration.rs @@ -14,7 +14,7 @@ use google_cloud_token::TokenSource; use async_trait::async_trait; pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -23,6 +23,18 @@ pub struct Configuration { } +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug.field("token_source", &"[REDACTED]"); + debug.finish() + } +} + impl Configuration { pub fn new() -> Configuration { Configuration::default() diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs index d96450ab233f..f2047ccc5a1a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs index d96450ab233f..f2047ccc5a1a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs index af280539b12f..c4fba6dce168 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/configuration.rs @@ -15,7 +15,7 @@ use http; use secrecy::{SecretString, ExposeSecret}; pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -29,12 +29,21 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + #[derive(Debug, Clone)] pub struct AWSv4Key { pub access_key: String, @@ -72,6 +81,23 @@ impl AWSv4Key { } } +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.field("aws_v4_key", &self.aws_v4_key); + debug.finish() + } +} + impl Configuration { pub fn new() -> Configuration { Configuration::default() diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/configuration.rs index e9f6c13cc86b..2df2fb4df8ef 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs index e9f6c13cc86b..2df2fb4df8ef 100644 --- a/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-no-chrono/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/configuration.rs index d96450ab233f..f2047ccc5a1a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs index e9f6c13cc86b..2df2fb4df8ef 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/client/petstore/rust/reqwest/test-duplicates/src/apis/configuration.rs b/samples/client/petstore/rust/reqwest/test-duplicates/src/apis/configuration.rs index 316cf7e0ce6d..05bd588eddca 100644 --- a/samples/client/petstore/rust/reqwest/test-duplicates/src/apis/configuration.rs +++ b/samples/client/petstore/rust/reqwest/test-duplicates/src/apis/configuration.rs @@ -11,7 +11,7 @@ pub use reqwest::blocking::Client; -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Configuration { pub base_path: String, pub user_agent: Option, @@ -24,12 +24,37 @@ pub struct Configuration { pub type BasicAuth = (String, Option); -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct ApiKey { pub prefix: Option, pub key: String, } +impl std::fmt::Debug for ApiKey { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("ApiKey") + .field("prefix", &self.prefix) + .field("key", &"[REDACTED]") + .finish() + } +} + + +impl std::fmt::Debug for Configuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut debug = f.debug_struct("Configuration"); + debug + .field("base_path", &self.base_path) + .field("user_agent", &self.user_agent) + .field("client", &self.client); + debug + .field("basic_auth", &self.basic_auth.as_ref().map(|(username, password)| (username, password.as_ref().map(|_| "[REDACTED]")))) + .field("oauth_access_token", &self.oauth_access_token.as_ref().map(|_| "[REDACTED]")) + .field("bearer_access_token", &self.bearer_access_token.as_ref().map(|_| "[REDACTED]")) + .field("api_key", &self.api_key); + debug.finish() + } +} impl Configuration { pub fn new() -> Configuration { diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go index 58b26ebc1573..58b459a864b1 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go +++ b/samples/openapi3/client/extensions/x-auth-id-alias/go-experimental/client.go @@ -179,10 +179,14 @@ func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix stri for i:=0;i