Description
The use of a [type string, format binary] inside a body generates a miscalled method <string>::fromJson().
The method generated is as below (see the call to newItem.fromJson)
void Body::fromJson(nlohmann::json& val)
{
if(val.find("binaryDataN2Information") != val.end())
{
if(!val["binaryDataN2Information"].is_null())
{
std::string newItem;
newItem.fromJson(val["binaryDataN2Information"]);
setBinaryDataN2Information( newItem );
}
}
}
The compilation error looks like :
model/Body.cpp: In member function ‘virtual void com::bcom::amf::microservice::server::ms1::model::Body::fromJson(nlohmann::json&)’:
model/Body.cpp:59:21: error: ‘std::__cxx11::string {aka class std::__cxx11::basic_string<char>}’ has no member named ‘fromJson’
newItem.fromJson(val["binaryDataN2Information"]);
^
openapi-generator version
3.1.2-SNAPSHOT
OpenAPI declaration file content or url
openapi: "3.0.0"
info:
version: 1.0.0
title: Check wrong generation of a body containing string/binary type
servers:
- url: http://localhost:8080
paths:
/check:
post:
summary: see title
tags:
- Non UE N2 Message Transfer
operationId: NonUeN2MessageTransfer
requestBody:
content:
application/json:
schema:
type: object
properties: # Request parts
binaryDataN2Information:
type: string
format: binary
required: true
responses:
'200':
description: Non UE N2 Message Transfer successfully initiated.
content:
application/json:
schema:
$ref: '#/components/schemas/content'
default:
description: Unexpected error
components:
schemas:
Bytes:
format: byte
type: string
Content:
type: object
properties:
type:
$ref: '#/components/schemas/Bytes'
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Check wrong generation of a body containing string/binary type"
},
"servers": [
{
"url": "http://localhost:8080"
}
],
"paths": {
"/check": {
"post": {
"summary": "see title",
"tags": [
"Non UE N2 Message Transfer"
],
"operationId": "NonUeN2MessageTransfer",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"binaryDataN2Information": {
"type": "string",
"format": "binary"
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Non UE N2 Message Transfer successfully initiated.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/content"
}
}
}
},
"default": {
"description": "Unexpected error"
}
}
}
}
},
"components": {
"schemas": {
"Bytes": {
"format": "byte",
"type": "string"
},
"Content": {
"type": "object",
"properties": {
"type": {
"$ref": "#/components/schemas/Bytes"
}
}
}
}
}
}
Command line used for generation
Generate :
openapi-generator-cli.sh generate -i ./openapi.yaml -g cpp-pistache-server -c ./config.json -o .
Compile :
g++ -c -I./api -I./model -I./impl -Wall -g -std=c++11 -o obj/model/Body.o model/Body.cpp
Steps to reproduce
Generate & compile
Related issues/PRs
N/A
Suggest a fix/enhancement
Not sure what we are supposed to do :/
Description
The use of a [type string, format binary] inside a body generates a miscalled method <string>::fromJson().
The method generated is as below (see the call to newItem.fromJson)
The compilation error looks like :
openapi-generator version
3.1.2-SNAPSHOT
OpenAPI declaration file content or url
{ "openapi": "3.0.0", "info": { "version": "1.0.0", "title": "Check wrong generation of a body containing string/binary type" }, "servers": [ { "url": "http://localhost:8080" } ], "paths": { "/check": { "post": { "summary": "see title", "tags": [ "Non UE N2 Message Transfer" ], "operationId": "NonUeN2MessageTransfer", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "binaryDataN2Information": { "type": "string", "format": "binary" } } } } }, "required": true }, "responses": { "200": { "description": "Non UE N2 Message Transfer successfully initiated.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/content" } } } }, "default": { "description": "Unexpected error" } } } } }, "components": { "schemas": { "Bytes": { "format": "byte", "type": "string" }, "Content": { "type": "object", "properties": { "type": { "$ref": "#/components/schemas/Bytes" } } } } } }Command line used for generation
Generate :
Compile :
Steps to reproduce
Generate & compile
Related issues/PRs
N/A
Suggest a fix/enhancement
Not sure what we are supposed to do :/