Skip to content

[C++] Use 'const' for cpp getters even when the return type is an aggregate #1175

Open
@alotia

Description

@alotia
Description

We are using openapi-generator to generate C++ classes from Java. For primitive types, the C++ getter method has 'const' qualifier, but when aggregates are specified, the method does not have have the const qualifier. Can a 'const' be added for getter methods even when the return type is an aggregate? (I am not very familiar with C++, and maybe there is a reason this is not being done. And I am filing this on behalf of someone who mentioned that not having a const on these getters causes them some grief.)

Please Note: I had originally filed this issue against swagger-codegen (v2.2.3), and William Cheng had asked to try out the latest version of OpenAPI Generator, but it does not address the issue I had. He had then recommended that I file an issue in OpenAPI as well. For your reference, the swagger-codegen issue is: swagger-api/swagger-codegen#8770

openapi-generator version

We are using openapi-generator-maven-plugin v3.3.0
and openapi-generator v3.3.0

OpenAPI declaration file content or url
Command line used for generation

Using the openapi-generator-maven-plugin to generate the code. Please let me know if you need any additional info

Steps to reproduce

Please use the included sample Java code to generate a C++ class. If you need any additional info, please let me know.

Related issues/PRs

swagger-api/swagger-codegen#8770

Suggest a fix/enhancement

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