Bug Report Checklist
Description
The cpp-restsdk generator always uses utility::string_t as the type of the key in an std::map, even if a different type-mapping is given.
openapi-generator version
v7.20.0
OpenAPI declaration file content or url
openapi: 3.1.0
info:
title: Example
description: Example
version: 1.0.0
components:
schemas:
Pet:
type: object
properties:
name:
type: string
age:
type: integer
required: [ name, age ]
PetCollection:
type: object
properties:
collectionName:
type: string
owners:
type: array
items:
type: string
pets:
type: object
additionalProperties:
$ref: "#/components/schemas/Pet"
required: [collectionName, owners, pets]
Generation Details
java -jar openapi-generator-cli-7.20.0.jar generate -i openapi.yaml -g cpp-restsdk -o petstore --type-mappings string=std::string
Steps to reproduce
- Generate C++ code as described above
- Check type of
m_Pets in PetCollection.h
The current result is
std::map<utility::string_t, std::shared_ptr<Pet>> m_Pets;
while the expected outcome is
std::map<std::string, std::shared_ptr<Pet>> m_Pets;
Note that the type-mapping for m_CollectionName and m_Owners is correct and uses the provided std::string.
Related issues/PRs
-
Suggest a fix
It looks like utility::string_t is hardcoded in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java#L466
Probably utility::string_t on this line has to be changed to getSchemaType("string")
Bug Report Checklist
Description
The cpp-restsdk generator always uses
utility::string_tas the type of the key in anstd::map, even if a different type-mapping is given.openapi-generator version
v7.20.0
OpenAPI declaration file content or url
Generation Details
java -jar openapi-generator-cli-7.20.0.jar generate -i openapi.yaml -g cpp-restsdk -o petstore --type-mappings string=std::stringSteps to reproduce
m_PetsinPetCollection.hThe current result is
std::map<utility::string_t, std::shared_ptr<Pet>> m_Pets;while the expected outcome is
std::map<std::string, std::shared_ptr<Pet>> m_Pets;Note that the type-mapping for
m_CollectionNameandm_Ownersis correct and uses the providedstd::string.Related issues/PRs
-
Suggest a fix
It looks like
utility::string_tis hardcoded in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java#L466Probably
utility::string_ton this line has to be changed togetSchemaType("string")