forked from loafle/openapi-generator-original
Better null check for encoding (#12597)
* better null check for encoding * add tests * update samples
This commit is contained in:
parent
6be94becee
commit
bd6617b3e7
@ -6836,8 +6836,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
enc.getContentType(),
|
enc.getContentType(),
|
||||||
headers,
|
headers,
|
||||||
enc.getStyle().toString(),
|
enc.getStyle().toString(),
|
||||||
enc.getExplode().booleanValue(),
|
enc.getExplode() == null ? false : enc.getExplode().booleanValue(),
|
||||||
enc.getAllowReserved().booleanValue()
|
enc.getAllowReserved() == null ? false : enc.getAllowReserved().booleanValue()
|
||||||
);
|
);
|
||||||
String propName = encodingEntry.getKey();
|
String propName = encodingEntry.getKey();
|
||||||
ceMap.put(propName, ce);
|
ceMap.put(propName, ce);
|
||||||
|
@ -618,6 +618,24 @@ components:
|
|||||||
application/xml:
|
application/xml:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Pet'
|
$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
|
description: Pet object that needs to be added to the store
|
||||||
required: true
|
required: true
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
|
@ -24,6 +24,7 @@ R/pet_api.R
|
|||||||
R/pig.R
|
R/pig.R
|
||||||
R/store_api.R
|
R/store_api.R
|
||||||
R/tag.R
|
R/tag.R
|
||||||
|
R/update_pet_request.R
|
||||||
R/user.R
|
R/user.R
|
||||||
R/user_api.R
|
R/user_api.R
|
||||||
README.md
|
README.md
|
||||||
@ -45,6 +46,7 @@ docs/PetApi.md
|
|||||||
docs/Pig.md
|
docs/Pig.md
|
||||||
docs/StoreApi.md
|
docs/StoreApi.md
|
||||||
docs/Tag.md
|
docs/Tag.md
|
||||||
|
docs/UpdatePetRequest.md
|
||||||
docs/User.md
|
docs/User.md
|
||||||
docs/UserApi.md
|
docs/UserApi.md
|
||||||
git_push.sh
|
git_push.sh
|
||||||
|
@ -27,6 +27,7 @@ export(Order)
|
|||||||
export(Pet)
|
export(Pet)
|
||||||
export(Pig)
|
export(Pig)
|
||||||
export(Tag)
|
export(Tag)
|
||||||
|
export(UpdatePetRequest)
|
||||||
export(User)
|
export(User)
|
||||||
|
|
||||||
# APIs
|
# APIs
|
||||||
|
95
samples/client/petstore/R/R/update_pet_request.R
Normal file
95
samples/client/petstore/R/R/update_pet_request.R
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
@ -96,6 +96,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [Pet](docs/Pet.md)
|
- [Pet](docs/Pet.md)
|
||||||
- [Pig](docs/Pig.md)
|
- [Pig](docs/Pig.md)
|
||||||
- [Tag](docs/Tag.md)
|
- [Tag](docs/Tag.md)
|
||||||
|
- [UpdatePetRequest](docs/UpdatePetRequest.md)
|
||||||
- [User](docs/User.md)
|
- [User](docs/User.md)
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
- **Content-Type**: application/json, application/xml
|
- **Content-Type**: application/json, application/xml, multipart/related
|
||||||
- **Accept**: application/xml, application/json
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
### HTTP response details
|
### HTTP response details
|
||||||
@ -359,7 +359,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
- **Content-Type**: application/json, application/xml
|
- **Content-Type**: application/json, application/xml, multipart/related
|
||||||
- **Accept**: application/xml, application/json
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
### HTTP response details
|
### HTTP response details
|
||||||
|
10
samples/client/petstore/R/docs/UpdatePetRequest.md
Normal file
10
samples/client/petstore/R/docs/UpdatePetRequest.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# petstore::UpdatePetRequest
|
||||||
|
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**jsonData** | [**Pet**](Pet.md) | | [optional]
|
||||||
|
**binaryDataN2Information** | **data.frame** | | [optional]
|
||||||
|
|
||||||
|
|
@ -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")
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user