Skip to content

[C++][Pistache-Server] Creation of weird #include statements from oneOf-statement #2477

Open
@jochengern

Description

@jochengern
Description

If I use a schema definition as shown in the yaml-snippet below, I get a file Error.h that contains the following #include statement:
#include OneOfErrInternalErrorErrInvalidIdErrCurrentlyNotAllowedErrApplicationNotLoadableErrApplicationNotAvailableErrItemDoesNotExist.h"
that will never compile because such a file does not exist.
It also contains the following method-declrarations:
OneOfErrInternalErrorErrInvalidIdErrCurrentlyNotAllowedErrApplicationNotLoadableErrApplicationNotAvailableErrItemDoesNotExist getCode() const;
void setCode(OneOfErrInternalErrorErrInvalidIdErrCurrentlyNotAllowedErrApplicationNotLoadableErrApplicationNotAvailableErrItemDoesNotExist const& value);

Neither while validating the yaml that contains this schema does issue an error message nor does the creation process.

openapi-generator version

4.0.0-beta2

OpenAPI declaration file content or url

'''yaml
components:
schemas:
Error:
type: object
required:
- code
- message
properties:
code:
oneOf:
- $ref: '#/components/schemas/ErrInternalError'
- $ref: '#/components/schemas/ErrInvalidId'
- $ref: '#/components/schemas/ErrCurrentlyNotAllowed'
- $ref: '#/components/schemas/ErrApplicationNotLoadable'
- $ref: '#/components/schemas/ErrApplicationNotAvailable'
- $ref: '#/components/schemas/ErrItemDoesNotExist'
message:
type: string
'''

Command line used for generation

java -ea -Xms512M -Xmx1024M -server -jar /home/fili/alpine/gernjo/openAPI/openapi-generator-cli-4.0.0-beta2.jar generate -i ./ontrestapi_device/ore_device.yaml -g cpp-pistache-server -o ./generated_server

Suggest a fix
  • Create one include-statement for each of the items listed under oneOf
  • Create one specific setter/getter method for each of the items listed under oneOf

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions