Open
Description
Description
As far as I know, the generator is not yet compliant with the anyOf syntax but I'm not sure of that because the generator does not fail nor warn when it encounter it (?).
On the other hand, the generator produces a C++ code that do not compile, using Object type that has not been defined or mapped ?
One of compile error looks like :
In file included from ./model/Content.h:24:0,
from api/CheckApi.h:29,
from api/CheckApi.cpp:13:
./model/AmfEventArea.h:24:20: fatal error: Object.h: No such file or directory
See also AmfEventArea.h for Object type usage
class AmfEventArea
: public ModelBase
{
public:
AmfEventArea();
virtual ~AmfEventArea();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
nlohmann::json toJson() const override;
void fromJson(nlohmann::json& json) override;
/////////////////////////////////////////////
/// AmfEventArea members
/// <summary>
///
/// </summary>
Object getPresence() const;
void setPresence(Object const& value);
bool presenceIsSet() const;
void unsetPresence();
protected:
Object m_Presence;
bool m_PresenceIsSet;
};
Below a sample to easily reproduce the error
openapi-generator version
3.1.1-SNAPSHOT
OpenAPI declaration file content or url
openapi: "3.0.0"
info:
version: 1.0.0
title: Check ByteArray
servers:
- url: http://localhost:8080
paths:
/CheckAnyOf:
get:
summary: Check AnyOf generation
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/Content"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Content"
components:
schemas:
PresenceState:
anyOf:
- type: string
enum:
- "IN"
- "OUT"
- "UNKNOWN"
- type: string
AmfEventArea:
type: object
properties:
presence:
$ref: '#/components/schemas/PresenceState'
Content:
type: object
properties:
type:
$ref: '#/components/schemas/AmfEventArea'
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Check ByteArray"
},
"servers": [
{
"url": "http://localhost:8080"
}
],
"paths": {
"/CheckAnyOf": {
"get": {
"summary": "Check AnyOf generation",
"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/Content"
}
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Content"
}
}
}
}
}
}
},
"components": {
"schemas": {
"PresenceState": {
"type": "string\nenum:\n - \"IN\"\n - \"OUT\"\n - \"UNKNOWN\""
},
"AmfEventArea": {
"type": "object",
"properties": {
"presence": {
"$ref": "#/components/schemas/PresenceState"
}
}
},
"Content": {
"type": "object",
"properties": {
"type": {
"$ref": "#/components/schemas/AmfEventArea"
}
}
}
}
}
}
Command line used for generation
Generation
openapi-generator-cli.sh generate -i ./openapi.yaml -g cpp-pistache-server -c ./config.json -o .
Compilation
g++ -c -I./api -I./model -I./impl -Wall -g -std=c++11 -o obj/api/CheckApi.o api/CheckApi.cpp
Steps to reproduce
Just generate and compile
Related issues/PRs
N/A