diff --git a/bin/configs/rust-reqwest-multipart-async.yaml b/bin/configs/rust-reqwest-multipart-async.yaml new file mode 100644 index 000000000000..5f4c950a35cf --- /dev/null +++ b/bin/configs/rust-reqwest-multipart-async.yaml @@ -0,0 +1,9 @@ +generatorName: rust +outputDir: samples/client/others/rust/reqwest/multipart-async +library: reqwest +inputSpec: modules/openapi-generator/src/test/resources/3_0/rust/multipart-file-upload.yaml +templateDir: modules/openapi-generator/src/main/resources/rust +additionalProperties: + supportAsync: true + useSingleRequestParameter: true + packageName: multipart-upload-reqwest-async diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index d31bac3f77bb..98d5def4a85d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -368,6 +368,45 @@ public ModelsMap postProcessModels(ModelsMap objs) { break; } } + + // Compute documentation type for each property + // This matches the actual generated code type, including HashSet for uniqueItems + for (CodegenProperty cp : cm.vars) { + String docType; + + if (cp.datatypeWithEnum != null && !cp.datatypeWithEnum.isEmpty()) { + // Use enum type if available (e.g., Vec instead of Vec) + docType = cp.datatypeWithEnum; + } else { + // Use regular dataType + docType = cp.dataType; + } + + // Apply uniqueItems logic (matching model.mustache lines 139, 161) + // Arrays with uniqueItems=true use HashSet instead of Vec in the generated code + if (Boolean.TRUE.equals(cp.getUniqueItems()) && docType.startsWith("Vec<")) { + docType = docType.replace("Vec<", "HashSet<"); + } + + cp.vendorExtensions.put("x-doc-type", docType); + + // Determine if this type should have a doc link + // Only local models should link, not external types from std lib or crates + boolean shouldLink = false; + if (cp.complexType != null && !cp.complexType.isEmpty()) { + // Check if it's an external type by looking for known prefixes + String[] externalPrefixes = {"std::", "serde_json::", "uuid::", "chrono::", "url::"}; + boolean isExternal = false; + for (String prefix : externalPrefixes) { + if (cp.complexType.startsWith(prefix)) { + isExternal = true; + break; + } + } + shouldLink = !isExternal; + } + cp.vendorExtensions.put("x-should-link", shouldLink); + } } // process enum in models return postProcessModelsEnum(objs); @@ -741,7 +780,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List Put, Reqwest: PUT => put) if (HYPER_LIBRARY.equals(getLibrary())) { operation.httpMethod = StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT)); diff --git a/modules/openapi-generator/src/main/resources/rust/api_doc.mustache b/modules/openapi-generator/src/main/resources/rust/api_doc.mustache index f8ea52038b01..c36081755400 100644 --- a/modules/openapi-generator/src/main/resources/rust/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/rust/api_doc.mustache @@ -25,7 +25,7 @@ Method | HTTP request | Description Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} {{#allParams}} -**{{{paramName}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{baseType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{#required}}[required]{{/required}} |{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +**{{{paramName}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#complexType}}[**{{{dataType}}}**]({{#lambda.pascalcase}}{{{complexType}}}{{/lambda.pascalcase}}.md){{/complexType}}{{^complexType}}[**{{{dataType}}}**]({{#lambda.pascalcase}}{{{dataType}}}{{/lambda.pascalcase}}.md){{/complexType}}{{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}}{{#isInnerEnum}} (enum: {{#allowableValues}}{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}){{/isInnerEnum}} | {{#required}}[required]{{/required}} |{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} {{/allParams}} ### Return type diff --git a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache index 9c0f7fd314b9..7a810e109c55 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper/api.mustache @@ -78,10 +78,25 @@ impl{{{classname}}} for {{{classname}}}Client let query_value = s.iter().map(|s| s.to_string()).collect::>().join(","); {{/isArray}} {{^isArray}} + {{#isPrimitiveType}} + let query_value = s.to_string(); + {{/isPrimitiveType}} + {{^isPrimitiveType}} + {{#isEnum}} + let query_value = s.to_string(); + {{/isEnum}} + {{^isEnum}} + {{#isEnumRef}} + let query_value = s.to_string(); + {{/isEnumRef}} + {{^isEnumRef}} let query_value = match serde_json::to_string(s) { Ok(value) => value, Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), }; + {{/isEnumRef}} + {{/isEnum}} + {{/isPrimitiveType}} {{/isArray}} req = req.with_query_param("{{{baseName}}}".to_string(), query_value); } diff --git a/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache b/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache index fe1a65c7920e..7d59394cdd07 100644 --- a/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/hyper0x/api.mustache @@ -77,10 +77,25 @@ impl{{{classname}}} for {{{classname}}}Clien let query_value = s.iter().map(|s| s.to_string()).collect::>().join(","); {{/isArray}} {{^isArray}} + {{#isPrimitiveType}} + let query_value = s.to_string(); + {{/isPrimitiveType}} + {{^isPrimitiveType}} + {{#isEnum}} + let query_value = s.to_string(); + {{/isEnum}} + {{^isEnum}} + {{#isEnumRef}} + let query_value = s.to_string(); + {{/isEnumRef}} + {{^isEnumRef}} let query_value = match serde_json::to_string(s) { Ok(value) => value, Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), }; + {{/isEnumRef}} + {{/isEnum}} + {{/isPrimitiveType}} {{/isArray}} req = req.with_query_param("{{{baseName}}}".to_string(), query_value); } diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index a4970abf4299..42e9f2efe1cc 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -167,7 +167,7 @@ impl {{{classname}}} { }}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{{classname}}} { {{{classname}}} { {{#vars}} - {{{name}}}{{^required}}: None{{/required}}{{#required}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/required}}, + {{{name}}}{{^required}}: None{{/required}}{{#required}}{{^isEnum}}{{#isModel}}{{^avoidBoxedModels}}: {{^isNullable}}Box::new({{{name}}}){{/isNullable}}{{#isNullable}}if let Some(x) = {{{name}}} {Some(Box::new(x))} else {None}{{/isNullable}}{{/avoidBoxedModels}}{{/isModel}}{{/isEnum}}{{/required}}, {{/vars}} } } diff --git a/modules/openapi-generator/src/main/resources/rust/model_doc.mustache b/modules/openapi-generator/src/main/resources/rust/model_doc.mustache index 2aba75968498..9c64e5951e07 100644 --- a/modules/openapi-generator/src/main/resources/rust/model_doc.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model_doc.mustache @@ -22,7 +22,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#vendorExtensions.x-should-link}}[**{{{vendorExtensions.x-doc-type}}}**]({{#lambda.pascalcase}}{{{complexType}}}{{/lambda.pascalcase}}.md){{/vendorExtensions.x-should-link}}{{^vendorExtensions.x-should-link}}**{{{vendorExtensions.x-doc-type}}}**{{/vendorExtensions.x-should-link}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}}{{#isInnerEnum}} (enum: {{#allowableValues}}{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}){{/isInnerEnum}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} {{/vars}} {{/x-mapped-models}} {{/vendorExtensions}} @@ -35,7 +35,7 @@ Name | Type | Description | Notes Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{{dataType}}}**]({{{complexType}}}.md){{/isPrimitiveType}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{#vars}}**{{{name}}}** | {{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{#vendorExtensions.x-should-link}}[**{{{vendorExtensions.x-doc-type}}}**]({{#lambda.pascalcase}}{{{complexType}}}{{/lambda.pascalcase}}.md){{/vendorExtensions.x-should-link}}{{^vendorExtensions.x-should-link}}**{{{vendorExtensions.x-doc-type}}}**{{/vendorExtensions.x-should-link}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}} | {{{description}}}{{#isInnerEnum}} (enum: {{#allowableValues}}{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}){{/isInnerEnum}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} {{/vars}} {{/oneOf.isEmpty}} {{^oneOf.isEmpty}} 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 11357a3752a6..1fda2948cc4b 100644 --- a/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache +++ b/modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache @@ -204,6 +204,7 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{^isObject}} {{^isModel}} {{^isEnum}} + {{^isEnumRef}} {{#isPrimitiveType}} if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); @@ -214,7 +215,18 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); }; {{/isPrimitiveType}} + {{/isEnumRef}} {{/isEnum}} + {{#isEnum}} + if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { + req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); + }; + {{/isEnum}} + {{#isEnumRef}} + if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { + req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); + }; + {{/isEnumRef}} {{/isModel}} {{/isObject}} {{/isNullable}} @@ -255,17 +267,22 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); {{/isModel}} {{#isEnum}} - req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); + req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); {{/isEnum}} + {{#isEnumRef}} + req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); + {{/isEnumRef}} {{^isObject}} {{^isModel}} {{^isEnum}} + {{^isEnumRef}} {{#isPrimitiveType}} req_builder = req_builder.query(&[("{{{baseName}}}", ¶m_value.to_string())]); {{/isPrimitiveType}} {{^isPrimitiveType}} req_builder = req_builder.query(&[("{{{baseName}}}", &serde_json::to_string(param_value)?)]); {{/isPrimitiveType}} + {{/isEnumRef}} {{/isEnum}} {{/isModel}} {{/isObject}} @@ -405,11 +422,19 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}(configuration: {{#supportAsync}} {{^required}} if let Some(ref param_value) = {{{vendorExtensions.x-rust-param-identifier}}} { - multipart_form = multipart_form.file("{{{baseName}}}", param_value.as_os_str()).await?; + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("{{{baseName}}}", file_part); } {{/required}} {{#required}} - multipart_form = multipart_form.file("{{{baseName}}}", {{{vendorExtensions.x-rust-param-identifier}}}.as_os_str()).await?; + let file = TokioFile::open(&{{{vendorExtensions.x-rust-param-identifier}}}).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = {{{vendorExtensions.x-rust-param-identifier}}}.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("{{{baseName}}}", file_part); {{/required}} {{/supportAsync}} {{/isFile}} diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/multipart-file-upload.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/multipart-file-upload.yaml new file mode 100644 index 000000000000..b8bd6517afc8 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/rust/multipart-file-upload.yaml @@ -0,0 +1,123 @@ +openapi: 3.0.3 +info: + title: Multipart File Upload Test + description: Regression test for async multipart file uploads with tokio::fs + version: 1.0.0 +servers: + - url: http://localhost:8080 +paths: + /upload/single: + post: + operationId: uploadSingleFile + summary: Upload a single file (required parameter) + description: Tests async multipart file upload with required file parameter + requestBody: + required: true + content: + multipart/form-data: + schema: + type: object + required: + - file + - description + properties: + description: + type: string + description: File description metadata + file: + type: string + format: binary + description: File to upload + responses: + '200': + description: Upload successful + content: + application/json: + schema: + $ref: '#/components/schemas/UploadResponse' + '400': + description: Bad request + + /upload/optional: + post: + operationId: uploadOptionalFile + summary: Upload an optional file + description: Tests async multipart file upload with optional file parameter + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + metadata: + type: string + description: Optional metadata string + file: + type: string + format: binary + description: Optional file to upload + responses: + '200': + description: Upload successful + content: + application/json: + schema: + $ref: '#/components/schemas/UploadResponse' + + /upload/multiple-fields: + post: + operationId: uploadMultipleFields + summary: Upload with multiple form fields + description: Tests async multipart with multiple files and text fields + requestBody: + content: + multipart/form-data: + schema: + type: object + required: + - primaryFile + properties: + title: + type: string + description: Upload title + tags: + type: array + items: + type: string + description: Tags for the upload + primaryFile: + type: string + format: binary + description: Primary file (required) + thumbnail: + type: string + format: binary + description: Optional thumbnail file + responses: + '200': + description: Upload successful + content: + application/json: + schema: + $ref: '#/components/schemas/UploadResponse' + '400': + description: Bad request + +components: + schemas: + UploadResponse: + type: object + required: + - success + - fileCount + properties: + success: + type: boolean + description: Whether the upload was successful + fileCount: + type: integer + format: int32 + description: Number of files uploaded + message: + type: string + description: Optional message about the upload diff --git a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml index d0b515e7cef0..984954994b4a 100644 --- a/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/rust/petstore.yaml @@ -719,6 +719,50 @@ paths: application/json: schema: type: string + '/tests/inlineEnumBoxing': + post: + tags: + - testing + summary: 'Test for inline enum fields not being boxed in model constructors' + description: 'Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors' + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ModelWithInlineEnum' + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/ModelWithInlineEnum' + get: + tags: + - testing + summary: 'Get model with inline enums' + description: 'Tests inline enum query parameters' + parameters: + - name: status + in: query + description: Filter by status (inline enum) + required: false + schema: + type: string + enum: + - draft + - published + - archived + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ModelWithInlineEnum' externalDocs: description: Find out more about Swagger url: 'http://swagger.io' @@ -1128,6 +1172,38 @@ components: oneOf: - $ref: '#/components/schemas/Order' - $ref: '#/components/schemas/Order' + ModelWithInlineEnum: + type: object + required: + - status + properties: + id: + type: integer + format: int64 + description: Model ID + status: + type: string + description: Status with inline enum (tests inline enum not being boxed in constructor) + enum: + - draft + - published + - archived + priority: + type: string + description: Priority level (optional inline enum) + enum: + - low + - medium + - high + - critical + metadata: + type: object + description: Optional metadata object + properties: + tags: + type: array + items: + type: string Page: type: object properties: diff --git a/samples/client/others/rust/Cargo.lock b/samples/client/others/rust/Cargo.lock index 5c3649805991..63e9edb715a5 100644 --- a/samples/client/others/rust/Cargo.lock +++ b/samples/client/others/rust/Cargo.lock @@ -17,6 +17,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + [[package]] name = "api-ref-param-hyper" version = "0.0.0" @@ -44,6 +53,27 @@ dependencies = [ "url", ] +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atomic-waker" version = "1.1.2" @@ -166,6 +196,24 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "deadpool" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb84100978c1c7b37f09ed3ce3e5f843af02c2a2c431bae5b19230dad2c1b490" +dependencies = [ + "async-trait", + "deadpool-runtime", + "num_cpus", + "tokio", +] + +[[package]] +name = "deadpool-runtime" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" + [[package]] name = "empty-object-hyper" version = "1.0.0" @@ -201,7 +249,9 @@ dependencies = [ "serde", "serde_json", "serde_repr", + "tokio", "url", + "wiremock", ] [[package]] @@ -217,7 +267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.61.0", ] [[package]] @@ -403,6 +453,12 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + [[package]] name = "http" version = "0.2.11" @@ -653,6 +709,20 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "multipart-upload-reqwest-async" +version = "1.0.0" +dependencies = [ + "reqwest", + "serde", + "serde_json", + "serde_repr", + "tokio", + "tokio-util", + "url", + "wiremock", +] + [[package]] name = "native-tls" version = "0.2.14" @@ -670,6 +740,16 @@ dependencies = [ "tempfile", ] +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.31.1" @@ -898,7 +978,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls", - "socket2 0.5.4", + "socket2 0.6.0", "thiserror", "tokio", "tracing", @@ -935,7 +1015,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.5.4", + "socket2 0.6.0", "tracing", "windows-sys 0.59.0", ] @@ -984,6 +1064,35 @@ dependencies = [ "getrandom 0.3.3", ] +[[package]] +name = "regex" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "regression-16119-reqwest" version = "0.1.0" @@ -1080,7 +1189,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.61.0", ] [[package]] @@ -1296,7 +1405,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.61.0", ] [[package]] @@ -1348,9 +1457,21 @@ dependencies = [ "pin-project-lite", "slab", "socket2 0.6.0", + "tokio-macros", "windows-sys 0.59.0", ] +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tokio-native-tls" version = "0.3.1" @@ -1815,6 +1936,30 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "wiremock" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2b8b99d4cdbf36b239a9532e31fe4fb8acc38d1897c1761e161550a7dc78e6a" +dependencies = [ + "assert-json-diff", + "async-trait", + "base64 0.22.1", + "deadpool", + "futures", + "http 1.1.0", + "http-body-util", + "hyper", + "hyper-util", + "log", + "once_cell", + "regex", + "serde", + "serde_json", + "tokio", + "url", +] + [[package]] name = "wit-bindgen" version = "0.45.1" diff --git a/samples/client/others/rust/hyper/api-with-ref-param/docs/DefaultApi.md b/samples/client/others/rust/hyper/api-with-ref-param/docs/DefaultApi.md index f7b030d1a133..aa681af10f36 100644 --- a/samples/client/others/rust/hyper/api-with-ref-param/docs/DefaultApi.md +++ b/samples/client/others/rust/hyper/api-with-ref-param/docs/DefaultApi.md @@ -18,7 +18,7 @@ Method | HTTP request | Description Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**color** | [**Color**](.md) | | [required] | +**color** | [**Color**](Color.md) | | [required] | ### Return type diff --git a/samples/client/others/rust/hyper/emptyObject/docs/EmptyObject.md b/samples/client/others/rust/hyper/emptyObject/docs/EmptyObject.md index 70778101882d..ec13dde71a20 100644 --- a/samples/client/others/rust/hyper/emptyObject/docs/EmptyObject.md +++ b/samples/client/others/rust/hyper/emptyObject/docs/EmptyObject.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**empty_object** | Option<[**serde_json::Value**](.md)> | | [optional] +**empty_object** | Option<**serde_json::Value**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/others/rust/reqwest-regression-16119/docs/Parent.md b/samples/client/others/rust/reqwest-regression-16119/docs/Parent.md index a0c675cd43cd..2edf2fd340f2 100644 --- a/samples/client/others/rust/reqwest-regression-16119/docs/Parent.md +++ b/samples/client/others/rust/reqwest-regression-16119/docs/Parent.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**child** | Option<[**std::collections::HashMap**](serde_json::Value.md)> | | [optional] +**child** | Option<**std::collections::HashMap**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/others/rust/reqwest/api-with-ref-param/docs/DefaultApi.md b/samples/client/others/rust/reqwest/api-with-ref-param/docs/DefaultApi.md index 69628902a3e4..168112b3f91d 100644 --- a/samples/client/others/rust/reqwest/api-with-ref-param/docs/DefaultApi.md +++ b/samples/client/others/rust/reqwest/api-with-ref-param/docs/DefaultApi.md @@ -18,7 +18,7 @@ Method | HTTP request | Description Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**color** | [**Color**](.md) | | [required] | +**color** | [**Color**](Color.md) | | [required] | ### Return type diff --git a/samples/client/others/rust/reqwest/emptyObject/docs/EmptyObject.md b/samples/client/others/rust/reqwest/emptyObject/docs/EmptyObject.md index 70778101882d..ec13dde71a20 100644 --- a/samples/client/others/rust/reqwest/emptyObject/docs/EmptyObject.md +++ b/samples/client/others/rust/reqwest/emptyObject/docs/EmptyObject.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**empty_object** | Option<[**serde_json::Value**](.md)> | | [optional] +**empty_object** | Option<**serde_json::Value**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator-ignore b/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator-ignore index 7484ee590a38..1c6be68a15d1 100644 --- a/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator-ignore +++ b/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator-ignore @@ -12,6 +12,10 @@ #foo/*/qux # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux +# Preserve test dependencies +Cargo.toml +tests/ + # You can recursively match patterns against a directory, file or extension with a double asterisk (**): #foo/**/qux # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux diff --git a/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator/FILES b/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator/FILES index 1d2a707dcb81..f735152ee61f 100644 --- a/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator/FILES +++ b/samples/client/others/rust/reqwest/enum-query-params/.openapi-generator/FILES @@ -1,6 +1,5 @@ .gitignore .travis.yml -Cargo.toml README.md docs/AggregateResponse.md docs/DefaultApi.md diff --git a/samples/client/others/rust/reqwest/enum-query-params/Cargo.toml b/samples/client/others/rust/reqwest/enum-query-params/Cargo.toml index 208987355122..9b025fe71ddd 100644 --- a/samples/client/others/rust/reqwest/enum-query-params/Cargo.toml +++ b/samples/client/others/rust/reqwest/enum-query-params/Cargo.toml @@ -14,6 +14,10 @@ serde_repr = "^0.1" url = "^2.5" reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart"] } +[dev-dependencies] +wiremock = "0.6" +tokio = { version = "^1.46.0", features = ["macros", "rt-multi-thread"] } + [features] default = ["native-tls"] native-tls = ["reqwest/native-tls"] diff --git a/samples/client/others/rust/reqwest/enum-query-params/docs/AggregateResponse.md b/samples/client/others/rust/reqwest/enum-query-params/docs/AggregateResponse.md index 16e7ca603059..aa8ee0ab9e11 100644 --- a/samples/client/others/rust/reqwest/enum-query-params/docs/AggregateResponse.md +++ b/samples/client/others/rust/reqwest/enum-query-params/docs/AggregateResponse.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **count** | Option<**i64**> | | [optional] -**data** | Option<[**Vec>**](std::collections::HashMap.md)> | | [optional] +**data** | Option<**Vec>**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/others/rust/reqwest/enum-query-params/docs/DefaultApi.md b/samples/client/others/rust/reqwest/enum-query-params/docs/DefaultApi.md index 22b7e090107a..1201a5a4e974 100644 --- a/samples/client/others/rust/reqwest/enum-query-params/docs/DefaultApi.md +++ b/samples/client/others/rust/reqwest/enum-query-params/docs/DefaultApi.md @@ -21,9 +21,9 @@ Test endpoint with enum query parameters referenced via $ref Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**status** | [**Status**](.md) | Status filter | [required] | -**time_bucket** | Option<[**TimeBucket**](.md)> | Time aggregation bucket | | -**sort_direction** | Option<[**SortDirection**](.md)> | Sort direction | | +**status** | [**Status**](Status.md) | Status filter | [required] | +**time_bucket** | Option<[**TimeBucket**](TimeBucket.md)> | Time aggregation bucket | | +**sort_direction** | Option<[**SortDirection**](SortDirection.md)> | Sort direction | | ### Return type @@ -52,7 +52,7 @@ Get items with filters Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- **category** | Option<**String**> | Item category (inline enum) | | -**priority** | Option<[**Priority**](.md)> | Priority level (enum via ref) | | +**priority** | Option<[**Priority**](Priority.md)> | Priority level (enum via ref) | | ### Return type diff --git a/samples/client/others/rust/reqwest/enum-query-params/src/apis/default_api.rs b/samples/client/others/rust/reqwest/enum-query-params/src/apis/default_api.rs index a342b2503e8e..8426a5c7bf99 100644 --- a/samples/client/others/rust/reqwest/enum-query-params/src/apis/default_api.rs +++ b/samples/client/others/rust/reqwest/enum-query-params/src/apis/default_api.rs @@ -42,10 +42,10 @@ pub async fn get_aggregate_data(configuration: &configuration::Configuration, st let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref param_value) = p_query_time_bucket { - req_builder = req_builder.query(&[("timeBucket", &serde_json::to_string(param_value)?)]); + req_builder = req_builder.query(&[("timeBucket", ¶m_value.to_string())]); } if let Some(ref param_value) = p_query_sort_direction { - req_builder = req_builder.query(&[("sortDirection", &serde_json::to_string(param_value)?)]); + req_builder = req_builder.query(&[("sortDirection", ¶m_value.to_string())]); } req_builder = req_builder.query(&[("status", &p_query_status.to_string())]); if let Some(ref user_agent) = configuration.user_agent { @@ -86,10 +86,10 @@ pub async fn get_items(configuration: &configuration::Configuration, category: O let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); if let Some(ref param_value) = p_query_category { - req_builder = req_builder.query(&[("category", &serde_json::to_string(param_value)?)]); + req_builder = req_builder.query(&[("category", ¶m_value.to_string())]); } if let Some(ref param_value) = p_query_priority { - req_builder = req_builder.query(&[("priority", &serde_json::to_string(param_value)?)]); + req_builder = req_builder.query(&[("priority", ¶m_value.to_string())]); } if let Some(ref user_agent) = configuration.user_agent { req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); diff --git a/samples/client/others/rust/reqwest/enum-query-params/tests/query_param_integration_test.rs b/samples/client/others/rust/reqwest/enum-query-params/tests/query_param_integration_test.rs new file mode 100644 index 000000000000..d8944e1bed3f --- /dev/null +++ b/samples/client/others/rust/reqwest/enum-query-params/tests/query_param_integration_test.rs @@ -0,0 +1,203 @@ +use wiremock::{Mock, MockServer, ResponseTemplate}; +use wiremock::matchers::{method, path, query_param}; +use enum_query_params_reqwest::apis::{configuration::Configuration, default_api}; +use enum_query_params_reqwest::models::{Status, TimeBucket, SortDirection, Priority, AggregateResponse, Item}; + +/// Test single required enum parameter by actually calling the generated SDK +/// and inspecting the HTTP request that was made. +/// +/// Regression test for: https://github.com/OpenAPITools/openapi-generator/issues/XXXXX +#[tokio::test] +async fn test_required_enum_param() { + let mock_server = MockServer::start().await; + + // wiremock will only match if query param is exactly "active" (not "%22active%22") + Mock::given(method("GET")) + .and(path("/aggregate")) + .and(query_param("status", "active")) + .respond_with(ResponseTemplate::new(200).set_body_json( + AggregateResponse { count: Some(10), data: None } + )) + .expect(1) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + // ACTUALLY CALL THE GENERATED SDK FUNCTION + let result = default_api::get_aggregate_data(&config, Status::Active, None, None).await; + assert!(result.is_ok(), "API call should succeed"); +} + +/// Test multiple optional enum parameters +#[tokio::test] +async fn test_multiple_optional_enum_params() { + let mock_server = MockServer::start().await; + + Mock::given(method("GET")) + .and(path("/aggregate")) + .and(query_param("status", "pending")) + .and(query_param("timeBucket", "week")) + .and(query_param("sortDirection", "asc")) + .respond_with(ResponseTemplate::new(200).set_body_json( + AggregateResponse { count: Some(5), data: None } + )) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + let result = default_api::get_aggregate_data( + &config, + Status::Pending, + Some(TimeBucket::Week), + Some(SortDirection::Asc) + ).await; + + assert!(result.is_ok(), "API call with multiple enums should succeed"); +} + +/// Test with optional params as None +#[tokio::test] +async fn test_optional_enum_params_none() { + let mock_server = MockServer::start().await; + + Mock::given(method("GET")) + .and(path("/aggregate")) + .and(query_param("status", "completed")) + .respond_with(ResponseTemplate::new(200).set_body_json( + AggregateResponse { count: Some(0), data: None } + )) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + let result = default_api::get_aggregate_data(&config, Status::Completed, None, None).await; + assert!(result.is_ok(), "API call with None optional params should succeed"); +} + +/// Test inline string enum (category parameter) +#[tokio::test] +async fn test_inline_string_enum() { + let mock_server = MockServer::start().await; + + Mock::given(method("GET")) + .and(path("/items")) + .and(query_param("category", "electronics")) + .respond_with(ResponseTemplate::new(200).set_body_json(Vec::::new())) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + let result = default_api::get_items(&config, Some("electronics"), None).await; + assert!(result.is_ok(), "API call with inline enum should succeed"); +} + +/// Test enum ref parameter (Priority) +#[tokio::test] +async fn test_enum_ref_param() { + let mock_server = MockServer::start().await; + + Mock::given(method("GET")) + .and(path("/items")) + .and(query_param("priority", "critical")) + .respond_with(ResponseTemplate::new(200).set_body_json(Vec::::new())) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + let result = default_api::get_items(&config, None, Some(Priority::Critical)).await; + assert!(result.is_ok(), "API call with enum ref should succeed"); +} + +/// Comprehensive regression test - inspect exact URL format +/// This is the KEY test that would catch the bug if it returned +#[tokio::test] +async fn test_regression_no_percent_22() { + let mock_server = MockServer::start().await; + + Mock::given(method("GET")) + .respond_with(ResponseTemplate::new(200).set_body_json( + AggregateResponse { count: Some(0), data: None } + )) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + // Test all enum types by calling the actual generated SDK function + let _ = default_api::get_aggregate_data( + &config, + Status::Inactive, + Some(TimeBucket::Month), + Some(SortDirection::Desc) + ).await; + + // Inspect the intercepted HTTP request + let requests = mock_server.received_requests().await.unwrap(); + let url = requests[0].url.as_str(); + + // Main assertion: NO %22 anywhere in URL + assert!( + !url.contains("%22"), + "REGRESSION: URL contains %22 (double-encoded quotes): {}", + url + ); + + // Verify correct enum values are present + assert!(url.contains("status=inactive"), "URL should contain status=inactive: {}", url); + assert!(url.contains("timeBucket=month"), "URL should contain timeBucket=month: {}", url); + assert!(url.contains("sortDirection=desc"), "URL should contain sortDirection=desc: {}", url); +} + +/// Test all enum variants systematically +#[tokio::test] +async fn test_all_enum_variants() { + let mock_server = MockServer::start().await; + + Mock::given(method("GET")) + .respond_with(ResponseTemplate::new(200).set_body_json( + AggregateResponse { count: Some(0), data: None } + )) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + // Test each Status variant by calling the generated SDK + for status in [Status::Active, Status::Inactive, Status::Pending, Status::Completed] { + let _ = default_api::get_aggregate_data(&config, status, None, None).await; + } + + let requests = mock_server.received_requests().await.unwrap(); + assert_eq!(requests.len(), 4, "Should have received 4 requests"); + + // Verify none have %22 + for request in requests { + let url = request.url.as_str(); + assert!(!url.contains("%22"), "URL contains %22: {}", url); + assert!(!url.contains("\\\""), "URL contains escaped quotes: {}", url); + } +} + +/// Test combination of inline enum and enum ref +#[tokio::test] +async fn test_inline_and_ref_enums() { + let mock_server = MockServer::start().await; + + Mock::given(method("GET")) + .and(path("/items")) + .and(query_param("category", "food")) + .and(query_param("priority", "high")) + .respond_with(ResponseTemplate::new(200).set_body_json(Vec::::new())) + .mount(&mock_server).await; + + let mut config = Configuration::new(); + config.base_path = mock_server.uri(); + + let result = default_api::get_items(&config, Some("food"), Some(Priority::High)).await; + assert!(result.is_ok(), "API call with both inline and ref enums should succeed"); +} diff --git a/samples/client/others/rust/reqwest/multipart-async/.gitignore b/samples/client/others/rust/reqwest/multipart-async/.gitignore new file mode 100644 index 000000000000..6aa106405a4b --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/samples/client/others/rust/reqwest/multipart-async/.openapi-generator-ignore b/samples/client/others/rust/reqwest/multipart-async/.openapi-generator-ignore new file mode 100644 index 000000000000..903d8ac6ddbb --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/.openapi-generator-ignore @@ -0,0 +1,27 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md + +# Preserve test dependencies +Cargo.toml +tests/ diff --git a/samples/client/others/rust/reqwest/multipart-async/.openapi-generator/FILES b/samples/client/others/rust/reqwest/multipart-async/.openapi-generator/FILES new file mode 100644 index 000000000000..59f22967fccb --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/.openapi-generator/FILES @@ -0,0 +1,12 @@ +.gitignore +.travis.yml +README.md +docs/DefaultApi.md +docs/UploadResponse.md +git_push.sh +src/apis/configuration.rs +src/apis/default_api.rs +src/apis/mod.rs +src/lib.rs +src/models/mod.rs +src/models/upload_response.rs diff --git a/samples/client/others/rust/reqwest/multipart-async/.openapi-generator/VERSION b/samples/client/others/rust/reqwest/multipart-async/.openapi-generator/VERSION new file mode 100644 index 000000000000..909dcd0eca63 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.19.0-SNAPSHOT diff --git a/samples/client/others/rust/reqwest/multipart-async/.travis.yml b/samples/client/others/rust/reqwest/multipart-async/.travis.yml new file mode 100644 index 000000000000..22761ba7ee19 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/samples/client/others/rust/reqwest/multipart-async/Cargo.toml b/samples/client/others/rust/reqwest/multipart-async/Cargo.toml new file mode 100644 index 000000000000..6c4dc6002e92 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "multipart-upload-reqwest-async" +version = "1.0.0" +authors = ["OpenAPI Generator team and contributors"] +description = "Regression test for async multipart file uploads with tokio::fs" +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2021" + +[dependencies] +serde = { version = "^1.0", features = ["derive"] } +serde_json = "^1.0" +serde_repr = "^0.1" +url = "^2.5" +tokio = { version = "^1.46.0", features = ["fs"] } +tokio-util = { version = "^0.7", features = ["codec"] } +reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart", "stream"] } + +[dev-dependencies] +wiremock = "0.6" +tokio = { version = "^1.46.0", features = ["macros", "rt-multi-thread"] } + +[features] +default = ["native-tls"] +native-tls = ["reqwest/native-tls"] +rustls-tls = ["reqwest/rustls-tls"] diff --git a/samples/client/others/rust/reqwest/multipart-async/README.md b/samples/client/others/rust/reqwest/multipart-async/README.md new file mode 100644 index 000000000000..e82b89a2c929 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/README.md @@ -0,0 +1,48 @@ +# Rust API client for multipart-upload-reqwest-async + +Regression test for async multipart file uploads with tokio::fs + + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.19.0-SNAPSHOT +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `multipart-upload-reqwest-async` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +multipart-upload-reqwest-async = { path = "./multipart-upload-reqwest-async" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost:8080* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DefaultApi* | [**upload_multiple_fields**](docs/DefaultApi.md#upload_multiple_fields) | **POST** /upload/multiple-fields | Upload with multiple form fields +*DefaultApi* | [**upload_optional_file**](docs/DefaultApi.md#upload_optional_file) | **POST** /upload/optional | Upload an optional file +*DefaultApi* | [**upload_single_file**](docs/DefaultApi.md#upload_single_file) | **POST** /upload/single | Upload a single file (required parameter) + + +## Documentation For Models + + - [UploadResponse](docs/UploadResponse.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/samples/client/others/rust/reqwest/multipart-async/docs/DefaultApi.md b/samples/client/others/rust/reqwest/multipart-async/docs/DefaultApi.md new file mode 100644 index 000000000000..30632fddfc21 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/docs/DefaultApi.md @@ -0,0 +1,106 @@ +# \DefaultApi + +All URIs are relative to *http://localhost:8080* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**upload_multiple_fields**](DefaultApi.md#upload_multiple_fields) | **POST** /upload/multiple-fields | Upload with multiple form fields +[**upload_optional_file**](DefaultApi.md#upload_optional_file) | **POST** /upload/optional | Upload an optional file +[**upload_single_file**](DefaultApi.md#upload_single_file) | **POST** /upload/single | Upload a single file (required parameter) + + + +## upload_multiple_fields + +> models::UploadResponse upload_multiple_fields(primary_file, title, tags, thumbnail) +Upload with multiple form fields + +Tests async multipart with multiple files and text fields + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**primary_file** | **std::path::PathBuf** | Primary file (required) | [required] | +**title** | Option<**String**> | Upload title | | +**tags** | Option<[**Vec**](String.md)> | Tags for the upload | | +**thumbnail** | Option<**std::path::PathBuf**> | Optional thumbnail file | | + +### Return type + +[**models::UploadResponse**](UploadResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + +[[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) + + +## upload_optional_file + +> models::UploadResponse upload_optional_file(metadata, file) +Upload an optional file + +Tests async multipart file upload with optional file parameter + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**metadata** | Option<**String**> | Optional metadata string | | +**file** | Option<**std::path::PathBuf**> | Optional file to upload | | + +### Return type + +[**models::UploadResponse**](UploadResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + +[[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) + + +## upload_single_file + +> models::UploadResponse upload_single_file(description, file) +Upload a single file (required parameter) + +Tests async multipart file upload with required file parameter + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**description** | **String** | File description metadata | [required] | +**file** | **std::path::PathBuf** | File to upload | [required] | + +### Return type + +[**models::UploadResponse**](UploadResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + +[[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/multipart-async/docs/UploadResponse.md b/samples/client/others/rust/reqwest/multipart-async/docs/UploadResponse.md new file mode 100644 index 000000000000..64910fe8e445 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/docs/UploadResponse.md @@ -0,0 +1,13 @@ +# UploadResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **bool** | Whether the upload was successful | +**file_count** | **i32** | Number of files uploaded | +**message** | Option<**String**> | Optional message about the upload | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/others/rust/reqwest/multipart-async/git_push.sh b/samples/client/others/rust/reqwest/multipart-async/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/git_push.sh @@ -0,0 +1,57 @@ +#!/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 [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$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 [ "$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 [ "$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 +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$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/multipart-async/src/apis/configuration.rs b/samples/client/others/rust/reqwest/multipart-async/src/apis/configuration.rs new file mode 100644 index 000000000000..07d7c160a658 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/src/apis/configuration.rs @@ -0,0 +1,51 @@ +/* + * Multipart File Upload Test + * + * Regression test for async multipart file uploads with tokio::fs + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + + + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, +} + +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:8080".to_owned(), + user_agent: Some("OpenAPI-Generator/1.0.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/samples/client/others/rust/reqwest/multipart-async/src/apis/default_api.rs b/samples/client/others/rust/reqwest/multipart-async/src/apis/default_api.rs new file mode 100644 index 000000000000..ecc8c0e6632c --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/src/apis/default_api.rs @@ -0,0 +1,219 @@ +/* + * Multipart File Upload Test + * + * Regression test for async multipart file uploads with tokio::fs + * + * 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}; +use tokio::fs::File as TokioFile; +use tokio_util::codec::{BytesCodec, FramedRead}; + +/// struct for passing parameters to the method [`upload_multiple_fields`] +#[derive(Clone, Debug)] +pub struct UploadMultipleFieldsParams { + /// Primary file (required) + pub primary_file: std::path::PathBuf, + /// Upload title + pub title: Option, + /// Tags for the upload + pub tags: Option>, + /// Optional thumbnail file + pub thumbnail: Option +} + +/// struct for passing parameters to the method [`upload_optional_file`] +#[derive(Clone, Debug)] +pub struct UploadOptionalFileParams { + /// Optional metadata string + pub metadata: Option, + /// Optional file to upload + pub file: Option +} + +/// struct for passing parameters to the method [`upload_single_file`] +#[derive(Clone, Debug)] +pub struct UploadSingleFileParams { + /// File description metadata + pub description: String, + /// File to upload + pub file: std::path::PathBuf +} + + +/// struct for typed errors of method [`upload_multiple_fields`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadMultipleFieldsError { + Status400(), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`upload_optional_file`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadOptionalFileError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`upload_single_file`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UploadSingleFileError { + Status400(), + UnknownValue(serde_json::Value), +} + + +/// Tests async multipart with multiple files and text fields +pub async fn upload_multiple_fields(configuration: &configuration::Configuration, params: UploadMultipleFieldsParams) -> Result> { + + let uri_str = format!("{}/upload/multiple-fields", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + let mut multipart_form = reqwest::multipart::Form::new(); + if let Some(param_value) = params.title { + multipart_form = multipart_form.text("title", param_value.to_string()); + } + if let Some(param_value) = params.tags { + multipart_form = multipart_form.text("tags", serde_json::to_string(¶m_value)?); + } + let file = TokioFile::open(¶ms.primary_file).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = params.primary_file.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("primaryFile", file_part); + if let Some(ref param_value) = params.thumbnail { + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("thumbnail", file_part); + } + req_builder = req_builder.multipart(multipart_form); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UploadResponse`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UploadResponse`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Tests async multipart file upload with optional file parameter +pub async fn upload_optional_file(configuration: &configuration::Configuration, params: UploadOptionalFileParams) -> Result> { + + let uri_str = format!("{}/upload/optional", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + let mut multipart_form = reqwest::multipart::Form::new(); + if let Some(param_value) = params.metadata { + multipart_form = multipart_form.text("metadata", param_value.to_string()); + } + if let Some(ref param_value) = params.file { + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("file", file_part); + } + req_builder = req_builder.multipart(multipart_form); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UploadResponse`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UploadResponse`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Tests async multipart file upload with required file parameter +pub async fn upload_single_file(configuration: &configuration::Configuration, params: UploadSingleFileParams) -> Result> { + + let uri_str = format!("{}/upload/single", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + let mut multipart_form = reqwest::multipart::Form::new(); + multipart_form = multipart_form.text("description", params.description.to_string()); + let file = TokioFile::open(¶ms.file).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = params.file.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("file", file_part); + req_builder = req_builder.multipart(multipart_form); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::UploadResponse`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::UploadResponse`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + diff --git a/samples/client/others/rust/reqwest/multipart-async/src/apis/mod.rs b/samples/client/others/rust/reqwest/multipart-async/src/apis/mod.rs new file mode 100644 index 000000000000..fdcc89b36066 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/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/multipart-async/src/lib.rs b/samples/client/others/rust/reqwest/multipart-async/src/lib.rs new file mode 100644 index 000000000000..e1520628d762 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/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/multipart-async/src/models/mod.rs b/samples/client/others/rust/reqwest/multipart-async/src/models/mod.rs new file mode 100644 index 000000000000..a4761a779fe2 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/src/models/mod.rs @@ -0,0 +1,2 @@ +pub mod upload_response; +pub use self::upload_response::UploadResponse; diff --git a/samples/client/others/rust/reqwest/multipart-async/src/models/upload_response.rs b/samples/client/others/rust/reqwest/multipart-async/src/models/upload_response.rs new file mode 100644 index 000000000000..6f5543ab51b8 --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/src/models/upload_response.rs @@ -0,0 +1,36 @@ +/* + * Multipart File Upload Test + * + * Regression test for async multipart file uploads with tokio::fs + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UploadResponse { + /// Whether the upload was successful + #[serde(rename = "success")] + pub success: bool, + /// Number of files uploaded + #[serde(rename = "fileCount")] + pub file_count: i32, + /// Optional message about the upload + #[serde(rename = "message", skip_serializing_if = "Option::is_none")] + pub message: Option, +} + +impl UploadResponse { + pub fn new(success: bool, file_count: i32) -> UploadResponse { + UploadResponse { + success, + file_count, + message: None, + } + } +} + diff --git a/samples/client/others/rust/reqwest/multipart-async/tests/multipart_test.rs b/samples/client/others/rust/reqwest/multipart-async/tests/multipart_test.rs new file mode 100644 index 000000000000..0ad354c00a8c --- /dev/null +++ b/samples/client/others/rust/reqwest/multipart-async/tests/multipart_test.rs @@ -0,0 +1,186 @@ +/// This test verifies that async multipart file uploads use streaming +/// (TokioFile + FramedRead + Part::stream) instead of buffering the entire file. +/// +/// This approach: +/// - Streams files instead of loading into memory (important for large files) +/// - Uses the same pattern as body file uploads +/// - Avoids the deprecated Form.file() method +/// +/// Regression test for: https://github.com/OpenAPITools/openapi-generator/issues/XXXXX + +#[tokio::test] +async fn test_multipart_file_streaming() { + use tokio::fs::File as TokioFile; + use tokio_util::codec::{BytesCodec, FramedRead}; + + // Create a temporary file + let temp_dir = std::env::temp_dir(); + let test_file = temp_dir.join("test_upload.txt"); + let test_content = b"Hello, multipart upload test!"; + + std::fs::write(&test_file, test_content).expect("Failed to create test file"); + + // Verify the streaming pattern works (what the generated code does) + let file = TokioFile::open(&test_file) + .await + .expect("Failed to open file with TokioFile"); + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = test_file + .file_name() + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_default(); + assert_eq!(file_name, "test_upload.txt"); + + // Create Part with streaming body + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)) + .file_name(file_name); + + // Verify we can create a form with the streaming part + let form = reqwest::multipart::Form::new().part("file", file_part); + + // If we got here, the streaming API calls work correctly + assert!(true, "Multipart form created successfully with streaming"); + + // Cleanup + std::fs::remove_file(test_file).ok(); +} + +/// Test that optional file parameters work correctly with streaming +#[tokio::test] +async fn test_optional_file_parameter() { + use tokio::fs::File as TokioFile; + use tokio_util::codec::{BytesCodec, FramedRead}; + + let temp_dir = std::env::temp_dir(); + let test_file = temp_dir.join("optional_test.txt"); + std::fs::write(&test_file, b"optional content").unwrap(); + + // Simulate what generated code does for optional files + let file_param: Option = Some(test_file.clone()); + + let mut form = reqwest::multipart::Form::new(); + + if let Some(ref param_value) = file_param { + let file = TokioFile::open(param_value).await.unwrap(); + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value + .file_name() + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)) + .file_name(file_name); + form = form.part("file", file_part); + } + + // If we got here, optional file handling works + std::fs::remove_file(test_file).ok(); +} + +/// Test form with multiple fields (file + metadata) using streaming +#[tokio::test] +async fn test_multipart_with_metadata() { + use tokio::fs::File as TokioFile; + use tokio_util::codec::{BytesCodec, FramedRead}; + + let temp_dir = std::env::temp_dir(); + let test_file = temp_dir.join("with_metadata.txt"); + std::fs::write(&test_file, b"file with metadata").unwrap(); + + // Build form like generated code does + let mut form = reqwest::multipart::Form::new(); + + // Add text field + form = form.text("description", "Test description"); + + // Add file field with streaming + let file = TokioFile::open(&test_file).await.unwrap(); + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = test_file + .file_name() + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)) + .file_name(file_name); + form = form.part("file", file_part); + + // Verify form was created successfully + std::fs::remove_file(test_file).ok(); +} + +/// Test multiple files in the same form with streaming +#[tokio::test] +async fn test_multiple_files() { + use tokio::fs::File as TokioFile; + use tokio_util::codec::{BytesCodec, FramedRead}; + + let temp_dir = std::env::temp_dir(); + let primary_file = temp_dir.join("primary.txt"); + let thumbnail_file = temp_dir.join("thumbnail.txt"); + + std::fs::write(&primary_file, b"primary content").unwrap(); + std::fs::write(&thumbnail_file, b"thumbnail content").unwrap(); + + // Build form with multiple files using streaming + let mut form = reqwest::multipart::Form::new(); + + // Add primary file (required) with streaming + let file = TokioFile::open(&primary_file).await.unwrap(); + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = primary_file + .file_name() + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)) + .file_name(file_name); + form = form.part("primaryFile", file_part); + + // Add thumbnail file (optional) with streaming + let file = TokioFile::open(&thumbnail_file).await.unwrap(); + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = thumbnail_file + .file_name() + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)) + .file_name(file_name); + form = form.part("thumbnail", file_part); + + // Cleanup + std::fs::remove_file(primary_file).ok(); + std::fs::remove_file(thumbnail_file).ok(); +} + +/// Test that the old approach (Form.file) doesn't work in async +#[test] +fn test_demonstrate_old_bug() { + // This is a compile-time demonstration + // The old code tried to use: + // multipart_form.file("name", path.as_os_str()).await? + // + // But Form::file() doesn't exist in async reqwest. + // This test just documents what the bug was. + // + // If someone reintroduces the bug, the generated code won't compile. + assert!( + true, + "The old Form.file() method doesn't exist in async reqwest - this is compile-time protection" + ); +} + +/// Verify the generated API uses correct async signatures +#[test] +fn test_generated_api_signatures() { + // This is a compile-time test - verifying the function signatures are correct + // If the APIs aren't properly async, this won't compile + + // Just ensure these functions exist and are async + // We can't easily express async function types, but we can verify they exist + use multipart_upload_reqwest_async::apis::default_api::{ + upload_multiple_fields, upload_optional_file, upload_single_file, + }; + + // The existence of these imports and the fact that we can reference them + // proves the APIs were generated correctly + let _: () = (); + assert!(true, "API signatures are correct and async"); +} diff --git a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES index 45d9997b4068..c051c597e273 100644 --- a/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/hyper/petstore/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -52,6 +54,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/hyper/petstore/README.md b/samples/client/petstore/rust/hyper/petstore/README.md index d6043a8a244e..59d2dcd800ba 100644 --- a/samples/client/petstore/rust/hyper/petstore/README.md +++ b/samples/client/petstore/rust/hyper/petstore/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **Post** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **Get** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **Get** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **Post** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **Get** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **Post** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **Post** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/AnyTypeTest.md b/samples/client/petstore/rust/hyper/petstore/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md b/samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/hyper/petstore/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper/petstore/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/hyper/petstore/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper/petstore/docs/Order.md b/samples/client/petstore/rust/hyper/petstore/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/Pet.md b/samples/client/petstore/rust/hyper/petstore/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/Pet.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/PetApi.md b/samples/client/petstore/rust/hyper/petstore/docs/PetApi.md index 40697be6fa7e..d8fb7e81e67d 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/PetApi.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md b/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md b/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md index ed3564412a78..4409e5141e7d 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **Get** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **Get** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **Get** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **Post** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **Get** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/hyper/petstore/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/hyper/petstore/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/hyper/petstore/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/hyper/petstore/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs index 8247b1b21def..8e422ef9d4bc 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/fake_api.rs @@ -47,10 +47,7 @@ implFakeApi for FakeApiClient let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string()) ; if let Some(ref s) = content { - let query_value = match serde_json::to_string(s) { - Ok(value) => value, - Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), - }; + let query_value = s.to_string(); req = req.with_query_param("content".to_string(), query_value); } req = req.with_query_param("anyType".to_string(), any_type.to_string()); diff --git a/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs index fee7996eb2d3..18e5de4ddfec 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/apis/testing_api.rs @@ -39,6 +39,8 @@ impl TestingApiClient pub trait TestingApi: Send + Sync { fn tests_all_of_with_one_model_get(&self, person: models::Person) -> Pin> + Send>>; fn tests_file_response_get(&self, ) -> Pin> + Send>>; + fn tests_inline_enum_boxing_get(&self, status: Option<&str>) -> Pin, Error>> + Send>>; + fn tests_inline_enum_boxing_post(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Pin> + Send>>; fn tests_type_testing_get(&self, ) -> Pin> + Send>>; } @@ -61,6 +63,27 @@ implTestingApi for TestingApiClient req.execute(self.configuration.borrow()) } + #[allow(unused_mut)] + fn tests_inline_enum_boxing_get(&self, status: Option<&str>) -> Pin, Error>> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/inlineEnumBoxing".to_string()) + ; + if let Some(ref s) = status { + let query_value = s.to_string(); + req = req.with_query_param("status".to_string(), query_value); + } + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn tests_inline_enum_boxing_post(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Pin> + Send>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/tests/inlineEnumBoxing".to_string()) + ; + req = req.with_body_param(model_with_inline_enum); + + req.execute(self.configuration.borrow()) + } + #[allow(unused_mut)] fn tests_type_testing_get(&self, ) -> Pin> + Send>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/typeTesting".to_string()) diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper/petstore/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/hyper/petstore/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/hyper/petstore/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/hyper/petstore/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/hyper/petstore/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES index 6f32de967eaa..47b8ff2042ca 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/hyper0x/petstore/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +52,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/hyper0x/petstore/README.md b/samples/client/petstore/rust/hyper0x/petstore/README.md index f80fb2ce9fc4..d7a3819b817b 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/README.md +++ b/samples/client/petstore/rust/hyper0x/petstore/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/AnyTypeTest.md b/samples/client/petstore/rust/hyper0x/petstore/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/hyper0x/petstore/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/hyper0x/petstore/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md b/samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md b/samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md b/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/hyper0x/petstore/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs index fb74cf88997f..099602bb22a7 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/fake_api.rs @@ -46,10 +46,7 @@ implFakeApi for FakeApiClient let mut req = __internal_request::Request::new(hyper::Method::GET, "/fake/user/{user_name}".to_string()) ; if let Some(ref s) = content { - let query_value = match serde_json::to_string(s) { - Ok(value) => value, - Err(e) => return Box::pin(futures::future::err(Error::Serde(e))), - }; + let query_value = s.to_string(); req = req.with_query_param("content".to_string(), query_value); } req = req.with_query_param("anyType".to_string(), any_type.to_string()); diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs index b4fae3a7e3a8..ff544bb10870 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/apis/testing_api.rs @@ -38,6 +38,8 @@ impl TestingApiClient pub trait TestingApi { fn tests_all_of_with_one_model_get(&self, person: models::Person) -> Pin>>>; fn tests_file_response_get(&self, ) -> Pin>>>; + fn tests_inline_enum_boxing_get(&self, status: Option<&str>) -> Pin, Error>>>>; + fn tests_inline_enum_boxing_post(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Pin>>>; fn tests_type_testing_get(&self, ) -> Pin>>>; } @@ -60,6 +62,27 @@ implTestingApi for TestingApiClient req.execute(self.configuration.borrow()) } + #[allow(unused_mut)] + fn tests_inline_enum_boxing_get(&self, status: Option<&str>) -> Pin, Error>>>> { + let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/inlineEnumBoxing".to_string()) + ; + if let Some(ref s) = status { + let query_value = s.to_string(); + req = req.with_query_param("status".to_string(), query_value); + } + + req.execute(self.configuration.borrow()) + } + + #[allow(unused_mut)] + fn tests_inline_enum_boxing_post(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Pin>>> { + let mut req = __internal_request::Request::new(hyper::Method::POST, "/tests/inlineEnumBoxing".to_string()) + ; + req = req.with_body_param(model_with_inline_enum); + + req.execute(self.configuration.borrow()) + } + #[allow(unused_mut)] fn tests_type_testing_get(&self, ) -> Pin>>> { let mut req = __internal_request::Request::new(hyper::Method::GET, "/tests/typeTesting".to_string()) diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/hyper0x/petstore/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/hyper0x/petstore/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES index 6f32de967eaa..47b8ff2042ca 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest-trait/petstore/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +52,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/README.md b/samples/client/petstore/rust/reqwest-trait/petstore/README.md index 9123432980a2..1a7e690d716b 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/README.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Pet.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/PetApi.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest-trait/petstore/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest-trait/petstore/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/apis/testing_api.rs index ad9077a003ce..7dc23023226d 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/apis/testing_api.rs @@ -33,6 +33,16 @@ pub trait TestingApi: Send + Sync { /// async fn tests_file_response_get<>(&self, ) -> Result>; + /// GET /tests/inlineEnumBoxing + /// + /// Tests inline enum query parameters + async fn tests_inline_enum_boxing_get<'status>(&self, status: Option<&'status str>) -> Result, Error>; + + /// POST /tests/inlineEnumBoxing + /// + /// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + async fn tests_inline_enum_boxing_post<'model_with_inline_enum>(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Result>; + /// GET /tests/typeTesting /// /// @@ -128,6 +138,86 @@ impl TestingApi for TestingApiClient { } } + /// Tests inline enum query parameters + async fn tests_inline_enum_boxing_get<'status>(&self, status: Option<&'status str>) -> Result, Error> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/inlineEnumBoxing", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref param_value) = status { + local_var_req_builder = local_var_req_builder.query(&[("status", ¶m_value.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`")))), + } + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } + } + + /// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + async fn tests_inline_enum_boxing_post<'model_with_inline_enum>(&self, model_with_inline_enum: models::ModelWithInlineEnum) -> Result> { + let local_var_configuration = &self.configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/tests/inlineEnumBoxing", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(&model_with_inline_enum); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content_type = local_var_resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let local_var_content_type = super::ContentType::from(local_var_content_type); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + match local_var_content_type { + ContentType::Json => serde_json::from_str(&local_var_content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModelWithInlineEnum`"))), + ContentType::Unsupported(local_var_unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{local_var_unknown_type}` content type response that cannot be converted to `models::ModelWithInlineEnum`")))), + } + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } + } + async fn tests_type_testing_get<>(&self, ) -> Result> { let local_var_configuration = &self.configuration; @@ -181,6 +271,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`TestingApi::tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`TestingApi::tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`TestingApi::tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest-trait/petstore/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest-trait/petstore/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES index 6f32de967eaa..47b8ff2042ca 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +52,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md index 783fc2f73f82..d7773d19dca2 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs index b6eb3e4a354d..a3ba46c92709 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/pet_api.rs @@ -13,6 +13,8 @@ use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +use tokio::fs::File as TokioFile; +use tokio_util::codec::{BytesCodec, FramedRead}; /// struct for passing parameters to the method [`add_pet`] #[derive(Clone, Debug)] @@ -568,7 +570,11 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } if let Some(ref param_value) = params.file { - multipart_form = multipart_form.file("file", param_value.as_os_str()).await?; + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("file", file_part); } req_builder = req_builder.multipart(multipart_form); diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs index 0a8e733d6cf7..20d2c519d4b6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/apis/testing_api.rs @@ -20,6 +20,19 @@ pub struct TestsAllOfWithOneModelGetParams { pub person: models::Person } +/// struct for passing parameters to the method [`tests_inline_enum_boxing_get`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingGetParams { + /// Filter by status (inline enum) + pub status: Option +} + +/// struct for passing parameters to the method [`tests_inline_enum_boxing_post`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingPostParams { + pub model_with_inline_enum: models::ModelWithInlineEnum +} + /// struct for typed successes of method [`tests_all_of_with_one_model_get`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -37,6 +50,22 @@ pub enum TestsFileResponseGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed successes of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostSuccess { + Status200(models::ModelWithInlineEnum), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -59,6 +88,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -116,6 +159,62 @@ pub async fn tests_file_response_get(configuration: &configuration::Configuratio } } +/// Tests inline enum query parameters +pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingGetParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = params.status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingPostParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(¶ms.model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-middleware/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES index 6f32de967eaa..47b8ff2042ca 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +52,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md index fe7c085fe8c1..09811e4a29b6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs index 1c241f620a90..1ceed076f06c 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/pet_api.rs @@ -13,6 +13,8 @@ use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +use tokio::fs::File as TokioFile; +use tokio_util::codec::{BytesCodec, FramedRead}; /// struct for passing parameters to the method [`add_pet`] #[derive(Clone, Debug)] @@ -579,7 +581,11 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } if let Some(ref param_value) = params.file { - multipart_form = multipart_form.file("file", param_value.as_os_str()).await?; + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("file", file_part); } req_builder = req_builder.multipart(multipart_form); diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs index 0a8e733d6cf7..20d2c519d4b6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/apis/testing_api.rs @@ -20,6 +20,19 @@ pub struct TestsAllOfWithOneModelGetParams { pub person: models::Person } +/// struct for passing parameters to the method [`tests_inline_enum_boxing_get`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingGetParams { + /// Filter by status (inline enum) + pub status: Option +} + +/// struct for passing parameters to the method [`tests_inline_enum_boxing_post`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingPostParams { + pub model_with_inline_enum: models::ModelWithInlineEnum +} + /// struct for typed successes of method [`tests_all_of_with_one_model_get`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -37,6 +50,22 @@ pub enum TestsFileResponseGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed successes of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostSuccess { + Status200(models::ModelWithInlineEnum), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -59,6 +88,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -116,6 +159,62 @@ pub async fn tests_file_response_get(configuration: &configuration::Configuratio } } +/// Tests inline enum query parameters +pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingGetParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = params.status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingPostParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(¶ms.model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async-tokensource/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator-ignore index 7484ee590a38..798c6f5eb975 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator-ignore +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator-ignore @@ -21,3 +21,7 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md + +# Preserve test files and dependencies +Cargo.toml +tests/inline_enum_boxing_test.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES index 6f32de967eaa..3732c5117e3b 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-async/.openapi-generator/FILES @@ -1,6 +1,5 @@ .gitignore .travis.yml -Cargo.toml README.md docs/ActionContainer.md docs/AnyTypeTest.md @@ -10,6 +9,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +51,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml index 63b4eb8acfd8..4b87528314bf 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore-async/Cargo.toml @@ -17,6 +17,10 @@ tokio = { version = "^1.46.0", features = ["fs"] } tokio-util = { version = "^0.7", features = ["codec"] } reqwest = { version = "^0.12", default-features = false, features = ["json", "multipart", "stream"] } +[dev-dependencies] +wiremock = "0.6" +tokio = { version = "^1.46.0", features = ["macros", "rt-multi-thread"] } + [features] default = ["native-tls"] native-tls = ["reqwest/native-tls"] diff --git a/samples/client/petstore/rust/reqwest/petstore-async/README.md b/samples/client/petstore/rust/reqwest/petstore-async/README.md index debe86b4fd9c..2867d0c10beb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore-async/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-async/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-async/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs index b6eb3e4a354d..a3ba46c92709 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/pet_api.rs @@ -13,6 +13,8 @@ use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +use tokio::fs::File as TokioFile; +use tokio_util::codec::{BytesCodec, FramedRead}; /// struct for passing parameters to the method [`add_pet`] #[derive(Clone, Debug)] @@ -568,7 +570,11 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } if let Some(ref param_value) = params.file { - multipart_form = multipart_form.file("file", param_value.as_os_str()).await?; + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("file", file_part); } req_builder = req_builder.multipart(multipart_form); diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs index 0a8e733d6cf7..20d2c519d4b6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/apis/testing_api.rs @@ -20,6 +20,19 @@ pub struct TestsAllOfWithOneModelGetParams { pub person: models::Person } +/// struct for passing parameters to the method [`tests_inline_enum_boxing_get`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingGetParams { + /// Filter by status (inline enum) + pub status: Option +} + +/// struct for passing parameters to the method [`tests_inline_enum_boxing_post`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingPostParams { + pub model_with_inline_enum: models::ModelWithInlineEnum +} + /// struct for typed successes of method [`tests_all_of_with_one_model_get`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -37,6 +50,22 @@ pub enum TestsFileResponseGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed successes of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostSuccess { + Status200(models::ModelWithInlineEnum), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -59,6 +88,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -116,6 +159,62 @@ pub async fn tests_file_response_get(configuration: &configuration::Configuratio } } +/// Tests inline enum query parameters +pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingGetParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = params.status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingPostParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(¶ms.model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-async/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-async/tests/inline_enum_boxing_test.rs b/samples/client/petstore/rust/reqwest/petstore-async/tests/inline_enum_boxing_test.rs new file mode 100644 index 000000000000..a91b928ee18d --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-async/tests/inline_enum_boxing_test.rs @@ -0,0 +1,142 @@ +use petstore_reqwest_async::models::{model_with_inline_enum, ModelWithInlineEnum, Order}; + +/// This test verifies that inline enum fields in model constructors +/// are NOT wrapped in Box::new(), which was a bug in the generator. +/// +/// Enums are Copy types and should never be boxed. The bug would cause +/// compilation errors like "expected enum Status, found Box". +/// +/// Regression test for: https://github.com/OpenAPITools/openapi-generator/issues/XXXXX +#[test] +fn test_inline_enum_not_boxed_in_constructor() { + // This test verifies that we can construct models with inline enums + // without wrapping them in Box::new() + + // Before the fix, this would fail to compile because the generated + // constructor would try to call Box::new() on the enum + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + + // Verify we can access the enum field + assert_eq!(model.status, model_with_inline_enum::Status::Draft); +} + +#[test] +fn test_existing_inline_enum_in_order_model() { + // The Order model has an inline Status enum (placed, approved, shipped) + // This ensures the fix works for enums in other models too + let mut order = Order::new(); + + // Set the status to a specific enum value + order.status = Some(petstore_reqwest_async::models::order::Status::Placed); + + // Verify we can access and compare the enum + assert_eq!(order.status, Some(petstore_reqwest_async::models::order::Status::Placed)); + + // Verify it's not boxed - this is a compile-time check + if let Some(status) = order.status { + let _status_ref: petstore_reqwest_async::models::order::Status = status; + assert_eq!(status, petstore_reqwest_async::models::order::Status::Placed); + } +} + +#[test] +fn test_multiple_inline_enums_in_same_model() { + // Test that a model with multiple inline enum fields works correctly + let mut model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Published); + + // Set the optional priority enum + model.priority = Some(model_with_inline_enum::Priority::High); + + assert_eq!(model.status, model_with_inline_enum::Status::Published); + assert_eq!(model.priority, Some(model_with_inline_enum::Priority::High)); +} + +#[test] +fn test_inline_enum_field_types() { + // Verify the types are correct - enums should be Status, not Box + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Archived); + + // This is a compile-time check - if status were Box, this wouldn't compile + let _status_ref: &model_with_inline_enum::Status = &model.status; + + // Optional fields should also not be boxed + if let Some(ref priority) = model.priority { + let _priority_ref: &model_with_inline_enum::Priority = priority; + } +} + +/// Test serialization/deserialization with inline enums +#[test] +fn test_inline_enum_serialization() { + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + + // Serialize to JSON + let json = serde_json::to_string(&model).unwrap(); + assert!(json.contains("\"status\":\"draft\"")); + + // Deserialize back + let deserialized: ModelWithInlineEnum = serde_json::from_str(&json).unwrap(); + assert_eq!(deserialized.status, model_with_inline_enum::Status::Draft); +} + +/// Test all enum variants +#[test] +fn test_all_status_variants() { + let draft = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + assert_eq!(draft.status, model_with_inline_enum::Status::Draft); + + let published = ModelWithInlineEnum::new(model_with_inline_enum::Status::Published); + assert_eq!( + published.status, + model_with_inline_enum::Status::Published + ); + + let archived = ModelWithInlineEnum::new(model_with_inline_enum::Status::Archived); + assert_eq!(archived.status, model_with_inline_enum::Status::Archived); +} + +/// Test all priority variants +#[test] +fn test_all_priority_variants() { + let mut model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + + model.priority = Some(model_with_inline_enum::Priority::Low); + assert_eq!(model.priority, Some(model_with_inline_enum::Priority::Low)); + + model.priority = Some(model_with_inline_enum::Priority::Medium); + assert_eq!( + model.priority, + Some(model_with_inline_enum::Priority::Medium) + ); + + model.priority = Some(model_with_inline_enum::Priority::High); + assert_eq!(model.priority, Some(model_with_inline_enum::Priority::High)); + + model.priority = Some(model_with_inline_enum::Priority::Critical); + assert_eq!( + model.priority, + Some(model_with_inline_enum::Priority::Critical) + ); +} + +/// Demonstrate what the bug was - if enums were boxed, this wouldn't compile +#[test] +fn test_bug_demonstration() { + // The bug was that the generator would produce code like: + // ModelWithInlineEnum { + // status: Box::new(status), // WRONG - enums shouldn't be boxed + // ... + // } + // + // This would cause a compilation error because the field type is Status, not Box + + // With the fix, this compiles successfully: + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + assert_eq!(model.status, model_with_inline_enum::Status::Draft); + + // The fix ensures inline enums are NOT wrapped in Box::new() + assert!( + true, + "Inline enums work correctly without boxing - this is compile-time protection" + ); +} diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES index 6f32de967eaa..47b8ff2042ca 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +52,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md index 70797a929e68..8a7dd5c695da 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs index b6eb3e4a354d..a3ba46c92709 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/pet_api.rs @@ -13,6 +13,8 @@ use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +use tokio::fs::File as TokioFile; +use tokio_util::codec::{BytesCodec, FramedRead}; /// struct for passing parameters to the method [`add_pet`] #[derive(Clone, Debug)] @@ -568,7 +570,11 @@ pub async fn upload_file(configuration: &configuration::Configuration, params: U multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } if let Some(ref param_value) = params.file { - multipart_form = multipart_form.file("file", param_value.as_os_str()).await?; + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("file", file_part); } req_builder = req_builder.multipart(multipart_form); diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs index 0a8e733d6cf7..20d2c519d4b6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/apis/testing_api.rs @@ -20,6 +20,19 @@ pub struct TestsAllOfWithOneModelGetParams { pub person: models::Person } +/// struct for passing parameters to the method [`tests_inline_enum_boxing_get`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingGetParams { + /// Filter by status (inline enum) + pub status: Option +} + +/// struct for passing parameters to the method [`tests_inline_enum_boxing_post`] +#[derive(Clone, Debug)] +pub struct TestsInlineEnumBoxingPostParams { + pub model_with_inline_enum: models::ModelWithInlineEnum +} + /// struct for typed successes of method [`tests_all_of_with_one_model_get`] #[derive(Debug, Clone, Serialize, Deserialize)] @@ -37,6 +50,22 @@ pub enum TestsFileResponseGetSuccess { UnknownValue(serde_json::Value), } +/// struct for typed successes of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetSuccess { + Status200(Vec), + UnknownValue(serde_json::Value), +} + +/// struct for typed successes of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostSuccess { + Status200(models::ModelWithInlineEnum), + UnknownValue(serde_json::Value), +} + /// struct for typed successes of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -59,6 +88,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -116,6 +159,62 @@ pub async fn tests_file_response_get(configuration: &configuration::Configuratio } } +/// Tests inline enum query parameters +pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingGetParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = params.status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, params: TestsInlineEnumBoxingPostParams) -> Result, Error> { + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(¶ms.model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Ok(ResponseContent { status, content, entity }) + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_type_testing_get(configuration: &configuration::Configuration) -> Result, Error> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..d496e9ec1d76 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-avoid-box/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES index 6f32de967eaa..47b8ff2042ca 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +52,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md index dfc578b3b381..848fdc3a4190 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs index 464779523d35..f286b427dac9 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/apis/testing_api.rs @@ -29,6 +29,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -97,6 +111,84 @@ pub fn tests_file_response_get(configuration: &configuration::Configuration, ) - } } +/// Tests inline enum query parameters +pub fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, status: Option<&str>) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_status = status; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, model_with_inline_enum: models::ModelWithInlineEnum) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_model_with_inline_enum = model_with_inline_enum; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModelWithInlineEnum`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModelWithInlineEnum`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-awsv4signature/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES index 64b012eb8d81..3a5b251043b0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/FooArrayItemRefTest.md docs/FooBaz.md docs/FooCategory.md docs/FooEnumArrayTesting.md +docs/FooModelWithInlineEnum.md +docs/FooModelWithInlineEnumMetadata.md docs/FooNullableArray.md docs/FooNumericEnumTesting.md docs/FooOptionalTesting.md @@ -47,6 +49,8 @@ src/models/foo_array_item_ref_test.rs src/models/foo_baz.rs src/models/foo_category.rs src/models/foo_enum_array_testing.rs +src/models/foo_model_with_inline_enum.rs +src/models/foo_model_with_inline_enum_metadata.rs src/models/foo_nullable_array.rs src/models/foo_numeric_enum_testing.rs src/models/foo_optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md index 6063804ad40a..4376f98c23eb 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [FooBaz](docs/FooBaz.md) - [FooCategory](docs/FooCategory.md) - [FooEnumArrayTesting](docs/FooEnumArrayTesting.md) + - [FooModelWithInlineEnum](docs/FooModelWithInlineEnum.md) + - [FooModelWithInlineEnumMetadata](docs/FooModelWithInlineEnumMetadata.md) - [FooNullableArray](docs/FooNullableArray.md) - [FooNumericEnumTesting](docs/FooNumericEnumTesting.md) - [FooOptionalTesting](docs/FooOptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooAnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooAnyTypeTest.md index ca27b3a52bc1..c3bafcf48585 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooAnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooAnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooArrayItemRefTest.md index 2cd0ec4d9ca4..b020ee67a2d6 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooEnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooEnumArrayTesting.md index 3f1eee350689..803f71120d26 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooEnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooEnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooModelWithInlineEnum.md new file mode 100644 index 000000000000..decf8a67f1e4 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# FooModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::FooModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..dd379d0e02ea --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# FooModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md index 5a5e81cb347d..47dc108651df 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooOrder.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPet.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPet.md index 02172d58736a..abdc7c8b71d2 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPet.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPropertyTest.md index cf58ec6c6cee..98fecbd67825 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooPropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md index 76008e985b30..fb3dceb5b57f 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooTypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUniqueItemArrayTesting.md index 5377655af8da..03d2f7d3a638 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/FooUniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/PetApi.md index 02966f7ea103..e0865c49638f 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**FooPage**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**FooPage**](FooPage.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**FooPage**](.md)> | The page number | | +**page** | Option<[**FooPage**](FooPage.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md index 15b595cfd335..55e67cfc4aff 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::FooModelWithInlineEnum tests_inline_enum_boxing_post(foo_model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**foo_model_with_inline_enum** | [**FooModelWithInlineEnum**](FooModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::FooModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::FooTypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs index 4486a14b2630..6cc8c976ba35 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/apis/testing_api.rs @@ -29,6 +29,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -97,6 +111,84 @@ pub fn tests_file_response_get(configuration: &configuration::Configuration, ) - } } +/// Tests inline enum query parameters +pub fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, status: Option<&str>) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_status = status; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::FooModelWithInlineEnum>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::FooModelWithInlineEnum>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, foo_model_with_inline_enum: models::FooModelWithInlineEnum) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_foo_model_with_inline_enum = foo_model_with_inline_enum; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_foo_model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FooModelWithInlineEnum`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FooModelWithInlineEnum`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_model_with_inline_enum.rs new file mode 100644 index 000000000000..91d2c8dabaf1 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FooModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl FooModelWithInlineEnum { + pub fn new(status: Status) -> FooModelWithInlineEnum { + FooModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..57ed6696c016 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/foo_model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// FooModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct FooModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl FooModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> FooModelWithInlineEnumMetadata { + FooModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs index ee04b2836dcb..274afa5c1dd0 100644 --- a/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-model-name-prefix/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod foo_category; pub use self::foo_category::FooCategory; pub mod foo_enum_array_testing; pub use self::foo_enum_array_testing::FooEnumArrayTesting; +pub mod foo_model_with_inline_enum; +pub use self::foo_model_with_inline_enum::FooModelWithInlineEnum; +pub mod foo_model_with_inline_enum_metadata; +pub use self::foo_model_with_inline_enum_metadata::FooModelWithInlineEnumMetadata; pub mod foo_nullable_array; pub use self::foo_nullable_array::FooNullableArray; pub mod foo_numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/.openapi-generator/FILES index 6f32de967eaa..47b8ff2042ca 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/.openapi-generator/FILES @@ -10,6 +10,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +52,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/README.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/README.md index b6046cda26f8..36adc1554e90 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/README.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/pet_api.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/pet_api.rs index 5daf6ba8737a..2adab42af534 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/pet_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/pet_api.rs @@ -13,6 +13,8 @@ use reqwest; use serde::{Deserialize, Serialize, de::Error as _}; use crate::{apis::ResponseContent, models}; use super::{Error, configuration, ContentType}; +use tokio::fs::File as TokioFile; +use tokio_util::codec::{BytesCodec, FramedRead}; /// struct for typed errors of method [`add_pet`] @@ -494,7 +496,11 @@ pub async fn upload_file(configuration: &configuration::Configuration, pet_id: i multipart_form = multipart_form.text("additionalMetadata", param_value.to_string()); } if let Some(ref param_value) = p_form_file { - multipart_form = multipart_form.file("file", param_value.as_os_str()).await?; + let file = TokioFile::open(param_value).await?; + let stream = FramedRead::new(file, BytesCodec::new()); + let file_name = param_value.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default(); + let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name); + multipart_form = multipart_form.part("file", file_part); } req_builder = req_builder.multipart(multipart_form); diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/testing_api.rs index 6c1f9a5c43c1..e8afa6500d14 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/apis/testing_api.rs @@ -29,6 +29,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -97,6 +111,84 @@ pub async fn tests_file_response_get(configuration: &configuration::Configuratio } } +/// Tests inline enum query parameters +pub async fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, status: Option<&str>) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_status = status; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub async fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, model_with_inline_enum: models::ModelWithInlineEnum) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_model_with_inline_enum = model_with_inline_enum; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_str(&content)).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModelWithInlineEnum`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModelWithInlineEnum`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub async fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore-serde-path-to-error/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator-ignore b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator-ignore index 7484ee590a38..798c6f5eb975 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator-ignore +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator-ignore @@ -21,3 +21,7 @@ #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md + +# Preserve test files and dependencies +Cargo.toml +tests/inline_enum_boxing_test.rs diff --git a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES index 6f32de967eaa..3732c5117e3b 100644 --- a/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES +++ b/samples/client/petstore/rust/reqwest/petstore/.openapi-generator/FILES @@ -1,6 +1,5 @@ .gitignore .travis.yml -Cargo.toml README.md docs/ActionContainer.md docs/AnyTypeTest.md @@ -10,6 +9,8 @@ docs/Baz.md docs/Category.md docs/EnumArrayTesting.md docs/FakeApi.md +docs/ModelWithInlineEnum.md +docs/ModelWithInlineEnumMetadata.md docs/NullableArray.md docs/NumericEnumTesting.md docs/OptionalTesting.md @@ -50,6 +51,8 @@ src/models/enum_array_testing.rs src/models/mod.rs src/models/model_ref.rs src/models/model_return.rs +src/models/model_with_inline_enum.rs +src/models/model_with_inline_enum_metadata.rs src/models/nullable_array.rs src/models/numeric_enum_testing.rs src/models/optional_testing.rs diff --git a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml index 004697204fc2..a7b21616b3e2 100644 --- a/samples/client/petstore/rust/reqwest/petstore/Cargo.toml +++ b/samples/client/petstore/rust/reqwest/petstore/Cargo.toml @@ -15,6 +15,10 @@ url = "^2.5" uuid = { version = "^1.8", features = ["serde", "v4"] } reqwest = { version = "^0.12", default-features = false, features = ["json", "blocking", "multipart"] } +[dev-dependencies] +wiremock = "0.6" +tokio = { version = "^1.46.0", features = ["macros", "rt-multi-thread"] } + [features] default = ["native-tls"] native-tls = ["reqwest/native-tls"] diff --git a/samples/client/petstore/rust/reqwest/petstore/README.md b/samples/client/petstore/rust/reqwest/petstore/README.md index 5652deff432c..e0e1492b5ff8 100644 --- a/samples/client/petstore/rust/reqwest/petstore/README.md +++ b/samples/client/petstore/rust/reqwest/petstore/README.md @@ -43,6 +43,8 @@ Class | Method | HTTP request | Description *StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *TestingApi* | [**tests_all_of_with_one_model_get**](docs/TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) *TestingApi* | [**tests_file_response_get**](docs/TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +*TestingApi* | [**tests_inline_enum_boxing_get**](docs/TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +*TestingApi* | [**tests_inline_enum_boxing_post**](docs/TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors *TestingApi* | [**tests_type_testing_get**](docs/TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema *UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user *UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array @@ -63,6 +65,8 @@ Class | Method | HTTP request | Description - [Baz](docs/Baz.md) - [Category](docs/Category.md) - [EnumArrayTesting](docs/EnumArrayTesting.md) + - [ModelWithInlineEnum](docs/ModelWithInlineEnum.md) + - [ModelWithInlineEnumMetadata](docs/ModelWithInlineEnumMetadata.md) - [NullableArray](docs/NullableArray.md) - [NumericEnumTesting](docs/NumericEnumTesting.md) - [OptionalTesting](docs/OptionalTesting.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/AnyTypeTest.md b/samples/client/petstore/rust/reqwest/petstore/docs/AnyTypeTest.md index cfcbd80fed0e..ed6cc47063ac 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/AnyTypeTest.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/AnyTypeTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**foo** | Option<[**serde_json::Value**](.md)> | | +**foo** | Option<**serde_json::Value**> | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md b/samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md index 616deda7c4b5..bbb039922bd7 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/ArrayItemRefTest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **list_with_array_ref** | [**Vec>**](Vec.md) | | -**list_with_object_ref** | [**Vec>**](std::collections::HashMap.md) | | +**list_with_object_ref** | **Vec>** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md index fb4c54df47d5..cdac6bc1965a 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/EnumArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**required_enums** | **Vec** | | +**required_enums** | **Vec** | (enum: A, B, C) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/ModelWithInlineEnum.md b/samples/client/petstore/rust/reqwest/petstore/docs/ModelWithInlineEnum.md new file mode 100644 index 000000000000..e5fb9caafd6f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/ModelWithInlineEnum.md @@ -0,0 +1,14 @@ +# ModelWithInlineEnum + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | Model ID | [optional] +**status** | **Status** | Status with inline enum (tests inline enum not being boxed in constructor) (enum: draft, published, archived) | +**priority** | Option<**Priority**> | Priority level (optional inline enum) (enum: low, medium, high, critical) | [optional] +**metadata** | Option<[**models::ModelWithInlineEnumMetadata**](ModelWithInlineEnumMetadata.md)> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/ModelWithInlineEnumMetadata.md b/samples/client/petstore/rust/reqwest/petstore/docs/ModelWithInlineEnumMetadata.md new file mode 100644 index 000000000000..cc306c4daa02 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/docs/ModelWithInlineEnumMetadata.md @@ -0,0 +1,11 @@ +# ModelWithInlineEnumMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | Option<**Vec**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md index d9a09c397432..ee573a52eb8a 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/Order.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **pet_id** | Option<**i64**> | | [optional] **quantity** | Option<**i32**> | | [optional] **ship_date** | Option<**String**> | | [optional] -**status** | Option<**String**> | Order Status | [optional] +**status** | Option<**Status**> | Order Status (enum: placed, approved, delivered) | [optional] **complete** | Option<**bool**> | | [optional][default to false] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/Pet.md b/samples/client/petstore/rust/reqwest/petstore/docs/Pet.md index e7a72caa16e9..ac5bbde8c174 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/Pet.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/Pet.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **name** | **String** | | **photo_urls** | **Vec** | | **tags** | Option<[**Vec**](Tag.md)> | | [optional] -**status** | Option<**String**> | pet status in the store | [optional] +**status** | Option<**Status**> | pet status in the store (enum: available, pending, sold) | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/PetApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/PetApi.md index fdef2e1f7f63..63d277a8830d 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/PetApi.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/PetApi.md @@ -181,7 +181,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page_explode** | Option<[**Page**](.md)> | Object containing page `size` and page `number`. | | +**page_explode** | Option<[**Page**](Page.md)> | Object containing page `size` and page `number`. | | ### Return type @@ -211,7 +211,7 @@ Returns a list of pets Name | Type | Description | Required | Notes ------------- | ------------- | ------------- | ------------- | ------------- -**page** | Option<[**Page**](.md)> | The page number | | +**page** | Option<[**Page**](Page.md)> | The page number | | ### Return type diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md b/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md index 3f36c163de0b..e8261d40d3a3 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/PropertyTest.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**uuid** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**uuid** | Option<**uuid::Uuid**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md b/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md index c5d3483462e2..a14a8e0c081d 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/TestingApi.md @@ -6,6 +6,8 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**tests_all_of_with_one_model_get**](TestingApi.md#tests_all_of_with_one_model_get) | **GET** /tests/allOfWithOneModel | Test for allOf with a single option. (One of the issues in #20500) [**tests_file_response_get**](TestingApi.md#tests_file_response_get) | **GET** /tests/fileResponse | Returns an image file +[**tests_inline_enum_boxing_get**](TestingApi.md#tests_inline_enum_boxing_get) | **GET** /tests/inlineEnumBoxing | Get model with inline enums +[**tests_inline_enum_boxing_post**](TestingApi.md#tests_inline_enum_boxing_post) | **POST** /tests/inlineEnumBoxing | Test for inline enum fields not being boxed in model constructors [**tests_type_testing_get**](TestingApi.md#tests_type_testing_get) | **GET** /tests/typeTesting | Route to test the TypeTesting schema @@ -63,6 +65,66 @@ No authorization required [[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) +## tests_inline_enum_boxing_get + +> Vec tests_inline_enum_boxing_get(status) +Get model with inline enums + +Tests inline enum query parameters + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**status** | Option<**String**> | Filter by status (inline enum) | | + +### Return type + +[**Vec**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## tests_inline_enum_boxing_post + +> models::ModelWithInlineEnum tests_inline_enum_boxing_post(model_with_inline_enum) +Test for inline enum fields not being boxed in model constructors + +Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**model_with_inline_enum** | [**ModelWithInlineEnum**](ModelWithInlineEnum.md) | | [required] | + +### Return type + +[**models::ModelWithInlineEnum**](ModelWithInlineEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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) + + ## tests_type_testing_get > models::TypeTesting tests_type_testing_get() diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md b/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md index 27b8f2622424..4134b7a23531 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/TypeTesting.md @@ -10,7 +10,7 @@ Name | Type | Description | Notes **double** | **f64** | | **string** | **String** | | **boolean** | **bool** | | -**uuid** | [**uuid::Uuid**](uuid::Uuid.md) | | +**uuid** | **uuid::Uuid** | | **bytes** | **String** | | **nullable_bytes** | Option<**String**> | | [optional] **decimal** | **String** | | diff --git a/samples/client/petstore/rust/reqwest/petstore/docs/UniqueItemArrayTesting.md b/samples/client/petstore/rust/reqwest/petstore/docs/UniqueItemArrayTesting.md index 6e103e2bb28d..32b20fdb80c9 100644 --- a/samples/client/petstore/rust/reqwest/petstore/docs/UniqueItemArrayTesting.md +++ b/samples/client/petstore/rust/reqwest/petstore/docs/UniqueItemArrayTesting.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**unique_item_array** | **Vec** | Helper object for the unique item array test | +**unique_item_array** | **HashSet** | Helper object for the unique item array test (enum: unique_item_1, unique_item_2, unique_item_3) | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs index 464779523d35..f286b427dac9 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/apis/testing_api.rs @@ -29,6 +29,20 @@ pub enum TestsFileResponseGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`tests_inline_enum_boxing_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`tests_inline_enum_boxing_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TestsInlineEnumBoxingPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`tests_type_testing_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -97,6 +111,84 @@ pub fn tests_file_response_get(configuration: &configuration::Configuration, ) - } } +/// Tests inline enum query parameters +pub fn tests_inline_enum_boxing_get(configuration: &configuration::Configuration, status: Option<&str>) -> Result, Error> { + // add a prefix to parameters to efficiently prevent name collisions + let p_query_status = status; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_query_status { + req_builder = req_builder.query(&[("status", ¶m_value.to_string())]); + } + 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(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ModelWithInlineEnum>`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + +/// Regression test to ensure inline enum fields are not wrapped in Box::new() in model constructors +pub fn tests_inline_enum_boxing_post(configuration: &configuration::Configuration, model_with_inline_enum: models::ModelWithInlineEnum) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_body_model_with_inline_enum = model_with_inline_enum; + + let uri_str = format!("{}/tests/inlineEnumBoxing", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str); + + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + req_builder = req_builder.json(&p_body_model_with_inline_enum); + + let req = req_builder.build()?; + let resp = configuration.client.execute(req)?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text()?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ModelWithInlineEnum`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ModelWithInlineEnum`")))), + } + } else { + let content = resp.text()?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + pub fn tests_type_testing_get(configuration: &configuration::Configuration, ) -> Result> { let uri_str = format!("{}/tests/typeTesting", configuration.base_path); diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs index 277e6f130a45..5f33e4b9f1ed 100644 --- a/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/mod.rs @@ -12,6 +12,10 @@ pub mod category; pub use self::category::Category; pub mod enum_array_testing; pub use self::enum_array_testing::EnumArrayTesting; +pub mod model_with_inline_enum; +pub use self::model_with_inline_enum::ModelWithInlineEnum; +pub mod model_with_inline_enum_metadata; +pub use self::model_with_inline_enum_metadata::ModelWithInlineEnumMetadata; pub mod nullable_array; pub use self::nullable_array::NullableArray; pub mod numeric_enum_testing; diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/model_with_inline_enum.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/model_with_inline_enum.rs new file mode 100644 index 000000000000..842e1bbd6765 --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/model_with_inline_enum.rs @@ -0,0 +1,73 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnum { + /// Model ID + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + /// Status with inline enum (tests inline enum not being boxed in constructor) + #[serde(rename = "status")] + pub status: Status, + /// Priority level (optional inline enum) + #[serde(rename = "priority", skip_serializing_if = "Option::is_none")] + pub priority: Option, + #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")] + pub metadata: Option>, +} + +impl ModelWithInlineEnum { + pub fn new(status: Status) -> ModelWithInlineEnum { + ModelWithInlineEnum { + id: None, + status, + priority: None, + metadata: None, + } + } +} +/// Status with inline enum (tests inline enum not being boxed in constructor) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Status { + #[serde(rename = "draft")] + Draft, + #[serde(rename = "published")] + Published, + #[serde(rename = "archived")] + Archived, +} + +impl Default for Status { + fn default() -> Status { + Self::Draft + } +} +/// Priority level (optional inline enum) +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Priority { + #[serde(rename = "low")] + Low, + #[serde(rename = "medium")] + Medium, + #[serde(rename = "high")] + High, + #[serde(rename = "critical")] + Critical, +} + +impl Default for Priority { + fn default() -> Priority { + Self::Low + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore/src/models/model_with_inline_enum_metadata.rs b/samples/client/petstore/rust/reqwest/petstore/src/models/model_with_inline_enum_metadata.rs new file mode 100644 index 000000000000..504ac44052da --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/src/models/model_with_inline_enum_metadata.rs @@ -0,0 +1,29 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// ModelWithInlineEnumMetadata : Optional metadata object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ModelWithInlineEnumMetadata { + #[serde(rename = "tags", skip_serializing_if = "Option::is_none")] + pub tags: Option>, +} + +impl ModelWithInlineEnumMetadata { + /// Optional metadata object + pub fn new() -> ModelWithInlineEnumMetadata { + ModelWithInlineEnumMetadata { + tags: None, + } + } +} + diff --git a/samples/client/petstore/rust/reqwest/petstore/tests/inline_enum_boxing_test.rs b/samples/client/petstore/rust/reqwest/petstore/tests/inline_enum_boxing_test.rs new file mode 100644 index 000000000000..2f02bda7d23f --- /dev/null +++ b/samples/client/petstore/rust/reqwest/petstore/tests/inline_enum_boxing_test.rs @@ -0,0 +1,142 @@ +use petstore_reqwest::models::{model_with_inline_enum, ModelWithInlineEnum, Order}; + +/// This test verifies that inline enum fields in model constructors +/// are NOT wrapped in Box::new(), which was a bug in the generator. +/// +/// Enums are Copy types and should never be boxed. The bug would cause +/// compilation errors like "expected enum Status, found Box". +/// +/// Regression test for: https://github.com/OpenAPITools/openapi-generator/issues/XXXXX +#[test] +fn test_inline_enum_not_boxed_in_constructor() { + // This test verifies that we can construct models with inline enums + // without wrapping them in Box::new() + + // Before the fix, this would fail to compile because the generated + // constructor would try to call Box::new() on the enum + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + + // Verify we can access the enum field + assert_eq!(model.status, model_with_inline_enum::Status::Draft); +} + +#[test] +fn test_existing_inline_enum_in_order_model() { + // The Order model has an inline Status enum (placed, approved, shipped) + // This ensures the fix works for enums in other models too + let mut order = Order::new(); + + // Set the status to a specific enum value + order.status = Some(petstore_reqwest::models::order::Status::Placed); + + // Verify we can access and compare the enum + assert_eq!(order.status, Some(petstore_reqwest::models::order::Status::Placed)); + + // Verify it's not boxed - this is a compile-time check + if let Some(status) = order.status { + let _status_ref: petstore_reqwest::models::order::Status = status; + assert_eq!(status, petstore_reqwest::models::order::Status::Placed); + } +} + +#[test] +fn test_multiple_inline_enums_in_same_model() { + // Test that a model with multiple inline enum fields works correctly + let mut model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Published); + + // Set the optional priority enum + model.priority = Some(model_with_inline_enum::Priority::High); + + assert_eq!(model.status, model_with_inline_enum::Status::Published); + assert_eq!(model.priority, Some(model_with_inline_enum::Priority::High)); +} + +#[test] +fn test_inline_enum_field_types() { + // Verify the types are correct - enums should be Status, not Box + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Archived); + + // This is a compile-time check - if status were Box, this wouldn't compile + let _status_ref: &model_with_inline_enum::Status = &model.status; + + // Optional fields should also not be boxed + if let Some(ref priority) = model.priority { + let _priority_ref: &model_with_inline_enum::Priority = priority; + } +} + +/// Test serialization/deserialization with inline enums +#[test] +fn test_inline_enum_serialization() { + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + + // Serialize to JSON + let json = serde_json::to_string(&model).unwrap(); + assert!(json.contains("\"status\":\"draft\"")); + + // Deserialize back + let deserialized: ModelWithInlineEnum = serde_json::from_str(&json).unwrap(); + assert_eq!(deserialized.status, model_with_inline_enum::Status::Draft); +} + +/// Test all enum variants +#[test] +fn test_all_status_variants() { + let draft = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + assert_eq!(draft.status, model_with_inline_enum::Status::Draft); + + let published = ModelWithInlineEnum::new(model_with_inline_enum::Status::Published); + assert_eq!( + published.status, + model_with_inline_enum::Status::Published + ); + + let archived = ModelWithInlineEnum::new(model_with_inline_enum::Status::Archived); + assert_eq!(archived.status, model_with_inline_enum::Status::Archived); +} + +/// Test all priority variants +#[test] +fn test_all_priority_variants() { + let mut model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + + model.priority = Some(model_with_inline_enum::Priority::Low); + assert_eq!(model.priority, Some(model_with_inline_enum::Priority::Low)); + + model.priority = Some(model_with_inline_enum::Priority::Medium); + assert_eq!( + model.priority, + Some(model_with_inline_enum::Priority::Medium) + ); + + model.priority = Some(model_with_inline_enum::Priority::High); + assert_eq!(model.priority, Some(model_with_inline_enum::Priority::High)); + + model.priority = Some(model_with_inline_enum::Priority::Critical); + assert_eq!( + model.priority, + Some(model_with_inline_enum::Priority::Critical) + ); +} + +/// Demonstrate what the bug was - if enums were boxed, this wouldn't compile +#[test] +fn test_bug_demonstration() { + // The bug was that the generator would produce code like: + // ModelWithInlineEnum { + // status: Box::new(status), // WRONG - enums shouldn't be boxed + // ... + // } + // + // This would cause a compilation error because the field type is Status, not Box + + // With the fix, this compiles successfully: + let model = ModelWithInlineEnum::new(model_with_inline_enum::Status::Draft); + assert_eq!(model.status, model_with_inline_enum::Status::Draft); + + // The fix ensures inline enums are NOT wrapped in Box::new() + assert!( + true, + "Inline enums work correctly without boxing - this is compile-time protection" + ); +}