OpenAPITools / OpenAPITools/openapi-generator
[BUG] [C++][Pistache] cpp-pistache-server generating API include undefined "Object.h"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the shown swagger.yaml and the cpp-pistache-server generation command, then inspect the generated api/DefaultApi.h alongside the model files listed in the output tree. Check the related C issue #2338 for context. Done means the generated API no longer references the missing Object.h file and the output matches the available generated headers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100