Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2643
Closed
Open
Issue created Apr 10, 2019 by Administrator@rootContributor

[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.

Assignee
Assign to
Time tracking