diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index e82ee5999cd..1ab927a6a26 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -6836,8 +6836,8 @@ public class DefaultCodegen implements CodegenConfig { enc.getContentType(), headers, enc.getStyle().toString(), - enc.getExplode().booleanValue(), - enc.getAllowReserved().booleanValue() + enc.getExplode() == null ? false : enc.getExplode().booleanValue(), + enc.getAllowReserved() == null ? false : enc.getAllowReserved().booleanValue() ); String propName = encodingEntry.getKey(); ceMap.put(propName, ce); diff --git a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml index c6bb52c52ee..4d36982cab5 100644 --- a/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/r/petstore.yaml @@ -618,6 +618,24 @@ components: application/xml: schema: $ref: '#/components/schemas/Pet' + multipart/related: # message with binary body part + schema: + type: object + properties: # Request parts + jsonData: + $ref: '#/components/schemas/Pet' + binaryDataN2Information: + type: string + format: binary + encoding: + jsonData: + contentType: application/json + binaryDataN2Information: + contentType: application/vnd.3gpp.ngap + headers: + Content-Id: + schema: + type: string description: Pet object that needs to be added to the store required: true securitySchemes: diff --git a/samples/client/petstore/R/.openapi-generator/FILES b/samples/client/petstore/R/.openapi-generator/FILES index 0549314051d..80c184e6178 100644 --- a/samples/client/petstore/R/.openapi-generator/FILES +++ b/samples/client/petstore/R/.openapi-generator/FILES @@ -24,6 +24,7 @@ R/pet_api.R R/pig.R R/store_api.R R/tag.R +R/update_pet_request.R R/user.R R/user_api.R README.md @@ -45,6 +46,7 @@ docs/PetApi.md docs/Pig.md docs/StoreApi.md docs/Tag.md +docs/UpdatePetRequest.md docs/User.md docs/UserApi.md git_push.sh diff --git a/samples/client/petstore/R/NAMESPACE b/samples/client/petstore/R/NAMESPACE index 77557a91938..4c676e98b4c 100644 --- a/samples/client/petstore/R/NAMESPACE +++ b/samples/client/petstore/R/NAMESPACE @@ -27,6 +27,7 @@ export(Order) export(Pet) export(Pig) export(Tag) +export(UpdatePetRequest) export(User) # APIs diff --git a/samples/client/petstore/R/R/update_pet_request.R b/samples/client/petstore/R/R/update_pet_request.R new file mode 100644 index 00000000000..dcd957d2380 --- /dev/null +++ b/samples/client/petstore/R/R/update_pet_request.R @@ -0,0 +1,95 @@ +# 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 + +#' @docType class +#' @title UpdatePetRequest +#' +#' @description UpdatePetRequest Class +#' +#' @format An \code{R6Class} generator object +#' +#' @field jsonData \link{Pet} [optional] +#' +#' @field binaryDataN2Information data.frame [optional] +#' +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +UpdatePetRequest <- R6::R6Class( + 'UpdatePetRequest', + public = list( + `jsonData` = NULL, + `binaryDataN2Information` = NULL, + initialize = function( + `jsonData`=NULL, `binaryDataN2Information`=NULL, ... + ) { + if (!is.null(`jsonData`)) { + stopifnot(R6::is.R6(`jsonData`)) + self$`jsonData` <- `jsonData` + } + if (!is.null(`binaryDataN2Information`)) { + self$`binaryDataN2Information` <- `binaryDataN2Information` + } + }, + toJSON = function() { + UpdatePetRequestObject <- list() + if (!is.null(self$`jsonData`)) { + UpdatePetRequestObject[['jsonData']] <- + self$`jsonData`$toJSON() + } + if (!is.null(self$`binaryDataN2Information`)) { + UpdatePetRequestObject[['binaryDataN2Information']] <- + self$`binaryDataN2Information` + } + + UpdatePetRequestObject + }, + fromJSON = function(UpdatePetRequestJson) { + UpdatePetRequestObject <- jsonlite::fromJSON(UpdatePetRequestJson) + if (!is.null(UpdatePetRequestObject$`jsonData`)) { + jsonDataObject <- Pet$new() + jsonDataObject$fromJSON(jsonlite::toJSON(UpdatePetRequestObject$jsonData, auto_unbox = TRUE, digits = NA)) + self$`jsonData` <- jsonDataObject + } + if (!is.null(UpdatePetRequestObject$`binaryDataN2Information`)) { + self$`binaryDataN2Information` <- UpdatePetRequestObject$`binaryDataN2Information` + } + self + }, + toJSONString = function() { + jsoncontent <- c( + if (!is.null(self$`jsonData`)) { + sprintf( + '"jsonData": + %s + ', + jsonlite::toJSON(self$`jsonData`$toJSON(), auto_unbox=TRUE, digits = NA) + )}, + if (!is.null(self$`binaryDataN2Information`)) { + sprintf( + '"binaryDataN2Information": + "%s" + ', + self$`binaryDataN2Information` + )} + ) + jsoncontent <- paste(jsoncontent, collapse = ",") + paste('{', jsoncontent, '}', sep = "") + }, + fromJSONString = function(UpdatePetRequestJson) { + UpdatePetRequestObject <- jsonlite::fromJSON(UpdatePetRequestJson) + self$`jsonData` <- Pet$new()$fromJSON(jsonlite::toJSON(UpdatePetRequestObject$jsonData, auto_unbox = TRUE, digits = NA)) + self$`binaryDataN2Information` <- UpdatePetRequestObject$`binaryDataN2Information` + self + }, + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + } + + ) +) + diff --git a/samples/client/petstore/R/README.md b/samples/client/petstore/R/README.md index 538251cf406..d486189e323 100644 --- a/samples/client/petstore/R/README.md +++ b/samples/client/petstore/R/README.md @@ -96,6 +96,7 @@ Class | Method | HTTP request | Description - [Pet](docs/Pet.md) - [Pig](docs/Pig.md) - [Tag](docs/Tag.md) + - [UpdatePetRequest](docs/UpdatePetRequest.md) - [User](docs/User.md) diff --git a/samples/client/petstore/R/docs/PetApi.md b/samples/client/petstore/R/docs/PetApi.md index d67f8fe20a2..88dd0b503d7 100644 --- a/samples/client/petstore/R/docs/PetApi.md +++ b/samples/client/petstore/R/docs/PetApi.md @@ -64,7 +64,7 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: application/json, application/xml + - **Content-Type**: application/json, application/xml, multipart/related - **Accept**: application/xml, application/json ### HTTP response details @@ -359,7 +359,7 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: application/json, application/xml + - **Content-Type**: application/json, application/xml, multipart/related - **Accept**: application/xml, application/json ### HTTP response details diff --git a/samples/client/petstore/R/docs/UpdatePetRequest.md b/samples/client/petstore/R/docs/UpdatePetRequest.md new file mode 100644 index 00000000000..619f0b2262a --- /dev/null +++ b/samples/client/petstore/R/docs/UpdatePetRequest.md @@ -0,0 +1,10 @@ +# petstore::UpdatePetRequest + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**jsonData** | [**Pet**](Pet.md) | | [optional] +**binaryDataN2Information** | **data.frame** | | [optional] + + diff --git a/samples/client/petstore/R/tests/testthat/test_update_pet_request.R b/samples/client/petstore/R/tests/testthat/test_update_pet_request.R new file mode 100644 index 00000000000..b39b2b4d0d7 --- /dev/null +++ b/samples/client/petstore/R/tests/testthat/test_update_pet_request.R @@ -0,0 +1,20 @@ +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate + +context("Test UpdatePetRequest") + +model_instance <- UpdatePetRequest$new() + +test_that("jsonData", { + # tests for the property `jsonData` (Pet) + + # uncomment below to test the property + #expect_equal(model.instance$`jsonData`, "EXPECTED_RESULT") +}) + +test_that("binaryDataN2Information", { + # tests for the property `binaryDataN2Information` (data.frame) + + # uncomment below to test the property + #expect_equal(model.instance$`binaryDataN2Information`, "EXPECTED_RESULT") +})