[BUG][C++][Pistache-Server] Incorrect fromJson generation with required items.
Created by: SalDiAngelus
Description
When a datatype references other datatypes as properties, the generated fromJson function does not deserialize required items.
openapi-generator version
4.0.0-beta3
OpenAPI declaration file content or url
openapi: 3.0.2
info:
title: Bug Test
version: 1.0.0
paths:
/default:
post:
tags:
- default
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DefaultRequest'
required: true
responses:
'201':
description: Created
content:
application/json:
schema:
type: string
components:
schemas:
Item3:
required:
- s
type: object
properties:
s:
type: string
Item1:
required:
- x
- 'y'
- z
type: object
properties:
x:
format: double
type: number
'y':
format: double
type: number
z:
format: double
type: number
Item2:
required:
- i
- j
- k
type: object
properties:
i:
format: double
type: number
j:
format: double
type: number
k:
format: double
type: number
DefaultRequest:
required:
- item1
- item2
- item3
type: object
properties:
item1:
$ref: '#/components/schemas/Item1'
item2:
$ref: '#/components/schemas/Item2'
item3:
$ref: '#/components/schemas/Item3'
Command line used for generation
java -jar .\openapi-generator-cli-4.0.0-beta3.jar generate -i default.yaml -g cpp-pistache-server -o pistache
Steps to reproduce
Run the above command with the included yaml. Notice that DefaultRequest::fromJson() doesn't deserialize anything. Then remove required items from DefaultRequest in the yaml and generate the server again. DefaultRequest::fromJson() will correctly check if the items exist and deserialize them.