Repository: OpenAPITools/openapi-generator

Issue #1827: [BUG][C++] cpp-pistache - missing support for object without properties/additionalProperties
Created: 2019-01-06T08:08:25Z
Description

When the model or inline type is type object only with no additionalProperties or properties the compilation failed due to reference to Object type.
fatal error: Object.h: No such file or directory
 #include "Object.h"

openapi-generator version

master
OpenAPI declaration file content or url

definitions:
  Result:
    type: object
Related issues/PRs

#1637

Duplicate issue #2769: [BUG] [C++][Pistache] cpp-pistache-server generating API include undefined "Object.h"
Created: 2019-04-30T08:45:54Z
Bug Report Checklist

 Have you provided a full/minimal spec to reproduce the issue?
 Have you validated the input using an OpenAPI validator (example)?
 What's the version of OpenAPI Generator used?
 Have you search for related issues/PRs?
 What's the actual output vs expected output?
 [Optional] Bounty to sponsor the fix (example)


Description

The generated Api.h file include "Obejct.h" which was not exist
/*
 * DefaultApi.h
 *
 *
 */

#ifndef DefaultApi_H_
#define DefaultApi_H_


#include <pistache/endpoint.h>
#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>

#include "Interface.h"
#include "Object.h"
#include <string>

namespace io {
namespace swagger {
namespace server {
namespace api {

using namespace io::swagger::server::model;

class  DefaultApi {


The Obejct.h was not generated and used :
.
├── api
│   ├── DefaultApi.cpp
│   └── DefaultApi.h
├── CMakeLists.txt
├── impl
│   ├── DefaultApiImpl.cpp
│   └── DefaultApiImpl.h
├── main-api-server.cpp
├── model
│   ├── Helpers.cpp
│   ├── Helpers.h
│   ├── InlineResponse200.cpp
│   ├── InlineResponse200.h
│   ├── Interface.cpp
│   ├── Interface.h
│   ├── Link.cpp
│   └── Link.h
└── README.md


openapi-generator version

4.0.0-SNAPSHOT
OpenAPI declaration file content or url
swagger 2.0 but not openapi 3.0.0
swagger: '2.0'

info:
  title: REST API
  version: v1

basePath: /api/hardware/v1

schemes:
  - http

paths:
  /vnf/{vnfId}/vm/{vmId}/interface:
    parameters:
      - in: path
        name: vnfId
        description: VNF instance Id
        required: true
        type: string
      - in: path
        name: vmId
        description: VM instance Id
        required: true
        type: string
    post:
      summary: Create interface instance under specified VM
      description: Create interface
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: body
          name: interface
          description: json containing interface configuration
          schema:
            $ref: "#/definitions/Interface"
      responses:
        '200':
          description: OK
          schema:
            properties:
              link:
                $ref: "#/definitions/Link"
          examples:
            application/json:
              {
                "link": {
                  "rel": "self",
                  "href": "/vnf/1/vm/1/interface/1"
                }
              }
        '400':
          description: Bad request
        '404':
          description: Not found
        default:
          description: Unexpected error

definitions:
  Link:
    title: HATEOAS link
    properties:
      rel:
        description: relation with the link
        type: string
        example: "self"
      href:
        description: URIs relative to base URI
        type: string
        example: "/vnf/1/vm/100/interface/1"
    required:
      - href

  Interface:
    title: Interface.
    required:
      - ipAddress
      - name
      - type
    properties:
      ipAddress:
        type: string
        example: 169.254.0.4
      name:
        type: string
        enum:
          - eth0
          - eth1
        example: eth0
      type:
        type: string
        enum:
          - physical
          - logical
        example: physical
Command line used for generation
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i swagger.yaml \
-g cpp-pistache-server \
-o cpp
Steps to reproduce
Generate the code then check the DefaultApi.h file.
Related issues/PRs
#2338 for C but not for C++
Suggest a fix
Remove the "Object.h" from DefaultApi.h file, maybe i don't know the reason why adding this, could someone point out?

Closing comment (2019-05-01T15:25:36Z): Duplicate of #1827