You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use additionalProperties in the OpenAPI definition in order to allow accepting responses in the following JSON payload format (Array of maps with string as map key and a fixed typed object as map value. It would make my job easier if it wouldn't be in an array format, but I have to work with this type definition in a company environment. Namings are already altered to avoid sensitive info.):
The generated ExampleApi.h and ExampleApi.cpp files do not compile, because std::map lacks the template parameters for the key and value type. Expected output is the following:
Run v6.0.0 version of openapi-codegen-cli with swagger.yml in the root folder. I used the dockerized execution.
docker run --rm -v "${PWD}:/local" --user "$(shell id -u):$(shell id -g)" openapitools/openapi-generator-cli:v6.0.0 generate \
-i /local/swagger.yml \
-g cpp-restsdk \
-o /local/myclient
Also tried openapitools/openapi-generator-cli:latest too, but result was the same. Tried manually building from master with ./mvnw clean install, but the 6.0.1-SNAPSHOT build failed.
swagger-codegen-cli:2.4.27 is already able to recognize an array of MapWithNestedSchema types, but has other troubles of generating MapWithNestedSchema as an std::map.
// models/MapWithNestedSchema.h
class MapWithNestedSchema
: public null<String, NestedSchema>
{
...
}
I tried copying the existing .mustache file templates for the API header and source and modifying them as a workaround, but so far I was only able to use the {#isMap} directive on request parameter types ({#allParams} -> {dataType}). If there would be a way to specify my custom .mustache file to check for map type or nested type in the result, that would be helpful. On the other hand, I would also appreciate help on how to improve the existing .yml file.
The text was updated successfully, but these errors were encountered:
I know that removing the array generates a valid function signature with std::map<utility::string_t, std::shared_ptr<NestedSchema>>> as return type, but the YAML is given to me. I cannot change it.
Uh oh!
There was an error while loading. Please reload this page.
Bug Report Checklist
Description
I would like to use
additionalProperties
in the OpenAPI definition in order to allow accepting responses in the following JSON payload format (Array of maps with string as map key and a fixed typed object as map value. It would make my job easier if it wouldn't be in an array format, but I have to work with this type definition in a company environment. Namings are already altered to avoid sensitive info.):In a generated Go client, the return type results in the following, which is the expected in Go:
However, I have to write a C++ client, and cpprest-sdk generator on the other hand generates the following type in the function signature:
The generated
ExampleApi.h
andExampleApi.cpp
files do not compile, becausestd::map
lacks the template parameters for the key and value type. Expected output is the following:openapi-generator version
v6.0.0
OpenAPI declaration file content or url
Generation Details
generatorName: cpp-restsdk
outputDir: myclient
inputSpec: swagger.yaml
Steps to reproduce
swagger.yml
in the root folder. I used the dockerized execution.Also tried
openapitools/openapi-generator-cli:latest
too, but result was the same. Tried manually building frommaster
with./mvnw clean install
, but the 6.0.1-SNAPSHOT build failed.Related issues/PRs
#5148
#5222
Suggest a fix
As a workaround, I currently preprocess my
swagger.yml
file withsed
to change the path to return "typeless items" and use them in code that way.swagger-codegen-cli:2.4.27
is already able to recognize an array ofMapWithNestedSchema
types, but has other troubles of generatingMapWithNestedSchema
as anstd::map
.I tried copying the existing
.mustache
file templates for the API header and source and modifying them as a workaround, but so far I was only able to use the{#isMap}
directive on request parameter types ({#allParams} -> {dataType}
). If there would be a way to specify my custom.mustache
file to check for map type or nested type in the result, that would be helpful. On the other hand, I would also appreciate help on how to improve the existing.yml
file.The text was updated successfully, but these errors were encountered: