Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][C++][Pistache-Server] Incorrect fromJson generation with required items. #2643

Closed
SalDiAngelus opened this issue Apr 10, 2019 · 2 comments

Comments

@SalDiAngelus
Copy link
Contributor

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.

@auto-labeler
Copy link

auto-labeler bot commented Apr 10, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

SalDiAngelus added a commit to SalDiAngelus/openapi-generator that referenced this issue Apr 12, 2019
Refactored to/from json functions to use universal object serialization method.
@etherealjoy etherealjoy added this to the 4.0.0 milestone Apr 19, 2019
@etherealjoy
Copy link
Contributor

Solved with #2653

jimschubert added a commit that referenced this issue Apr 25, 2019
* master: (40 commits)
  Remove quotation marks around {{paramName}} for header params in api-body.mustache (#2727)
  Add FiNC Technologies (#2728)
  fix missing parenthesis for http bearer auth (#2723)
  Add missing closing parenthesis (#2720)
  update perl test with correct body parameter (#2717)
  [Java][Spring] Fix template for reactive implementation with `interfaceOnly` parameter (#2437)
  Bugfix(Perl): Support nested primitive types in ARRARY or HASH for basic object (#2713)
  Remove `-XX:MaxPermSize` (#2712)
  Remove setting generateAliasAsModel in rust server generator (#2714)
  update rust server samples
  Revert "update rust samples"
  update rust samples
  update samples
  [Rust Server] Improve XML support (#2504)
  Improve CONTRIBUTING.md (#2699)
  [PHP][Lumen] Rename template folder (#2707)
  [aspnetcore] Support async tasks and some code cleanups (#2629)
  [C++][Pistache] Fixed #2643 (#2653)
  update petstore samples (#2697)
  [JAVA][Webclient]fix select body for url encoded media type. (#2686)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants