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
  • #2769
Closed
Open
Issue created Apr 30, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [C++][Pistache] cpp-pistache-server generating API include undefined "Object.h"

Created by: haibinzero

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?

Assignee
Assign to
Time tracking