-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
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_PetsinPetCollection.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")