[C++][Pistache-server] model is not a namespace-name
Created by: CyrilleBenard
Description
The generator seems to add systematically the instruction using namespace xxx::yyy::model ; without any needs and without, at least, one corresponding definition of the model namespace. The C++ compilation failed.
Compilation error looks like
In file included from api/CheckApi.cpp:13:0:
api/CheckApi.h:39:60: error: ‘model’ is not a namespace-name
using namespace com::bcom::amf::microservice::server::ms1::model;
^
api/CheckApi.h:39:65: error: expected namespace-name before ‘;’ token
using namespace com::bcom::amf::microservice::server::ms1::model;
^
api/CheckApi.cpp:23:60: error: ‘model’ is not a namespace-name
using namespace com::bcom::amf::microservice::server::ms1::model;
^
api/CheckApi.cpp:23:65: error: expected namespace-name before ‘;’ token
using namespace com::bcom::amf::microservice::server::ms1::model;
^
NOTE : The hierarchical namespace names shown above is mine but the bug issue is non dependent. Using the default namespaces will produce a similar compilation error. If needed, you will find my config.json file content below
openapi-generator version
3.1.2-SNAPSHOT
OpenAPI declaration file content or url
openapi: "3.0.0"
info:
version: 1.0.0
title: Check unknown namespace-name model
servers:
- url: http://localhost:8080
paths:
/check:
get:
summary: blabla
operationId: list
tags:
- Check
responses:
'200':
description: Everythings gonna be alright
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Bytes"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Bytes"
components:
schemas:
Bytes:
format: byte
type: string
Content:
type: object
properties:
type:
$ref: '#/components/schemas/Bytes'
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Check unknown namespace-name model"
},
"servers": [
{
"url": "http://localhost:8080"
}
],
"paths": {
"/check": {
"get": {
"summary": "blabla",
"operationId": "list",
"tags": [
"Check"
],
"responses": {
"200": {
"description": "Everythings gonna be alright",
"headers": {
"x-next": {
"description": "A link to the next page of responses",
"schema": {
"type": "string"
}
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Bytes"
}
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Bytes"
}
}
}
}
}
}
},
"components": {
"schemas": {
"Bytes": {
"format": "byte",
"type": "string"
},
"Content": {
"type": "object",
"properties": {
"type": {
"$ref": "#/components/schemas/Bytes"
}
}
}
}
}
}
config.json :
{
"modelPackage" : "com.bcom.amf.microservice.server.ms1.model",
"apiPackage" : "com.bcom.amf.microservice.server.ms1.api"
}
Command line used for generation
Generate :
openapi-generator-cli.sh generate -i ./openapi.yaml -g cpp-pistache-server -c ./config.json -o .
Compile :
g++ -c -I./api -I./model -I./impl -Wall -g -std=c++11 -o obj/api/CheckApi.o api/CheckApi.cpp
Steps to reproduce
Generate & compile
Related issues/PRs
N/A
Suggest a fix/enhancement
In case the generator needs to let this behavior as this, include systematically the ModelBase.h header file ... but I don't think its the best proposal ever seen