[BUG][cpp-restsdk] key-type of a map is hardcoded to utility::string_t
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Open modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java around line 466, then run the provided Java generation command with the sample OpenAPI YAML. Check PetCollection.h and confirm the map key follows the supplied string type mapping while the existing property mappings remain correct.
Written by the indexing model from the issue text.
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")
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 103
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenAPITools/openapi-generator
-
Issue: Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
OpenAPITools/openapi-generator#24978 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenAPITools/openapi-generator#24975 ·
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenAPITools/openapi-generator#24859 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24852 · 1 comment ·
-
[BUG][KOTLIN] Fails to compile after updating to 7.25.0 with useJackson3=false useSpringBoot4=true OpenIssue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24842 · 1 comment ·
All issues in OpenAPITools/openapi-generator
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100