Skip model generation if it's a top-level map or array#1296
Conversation
|
@wing328 I think here is a matter of choice how we want to do for alias, if we use However it does not apply this behavior when the array/map alias is part of a model like here #1251/#1273 We can do this as a next steps. |
|
@etherealjoy thanks for the review. cc @OpenAPITools/generator-core-team |
|
I have a regression here with #391 :( EDIT: |
|
@etherealjoy I'll take a look tomorrow to see if I can hunt down the bugs |
|
I pushed another fix and got the following (different) code snippet for void UeContext::fromJson(const nlohmann::json& val)
{
{
m_Groups.clear();
if(val.find("groups") != val.end())
{
for( auto& item : val["groups"] )
{
m_Groups.push_back(item);
}
}
}
}Please give it another try when you've time. |
|
Fixes #1465 as well! |
|
If no further feedback on this PR, I'll merge this on coming Monday. |
I still got this kind of wrong generated code with current master (3.3.4) :/ |
|
@CyrilleBenard std::vector<std::string> m_Groups;
m_Groups.clear();
if(val.find("groups") != val.end())
{
for( auto& item : val["groups"] )
{
m_Groups.push_back(item);
}
} UeContext:
type: object
properties:
groups:
type: array
items:
$ref: '#/components/schemas/GroupId'
GroupId:
type: string |
|
Oh sorry I omitted m_Groups was a string. I got the same kind of issue when m_Groups is a type defined by a model class. I'm going to reproduce the issue in a small context usage and will open another bug issue. |
|
@CyrilleBenard |
…1296) * update samples * remove string boolean map spec * add logic to skip array alias being generated as model * fix alias to array * remove unused ruby files * remove unused ruby (oas3) files * unalias response schema * fix NPE when no model defined * fix ruby openapi3 script * update samples * add global openapi, schemas for unaliasing * minor code cleanup/refactoring using globalSchemas * Revert "minor code cleanup/refactoring using globalSchemas" This reverts commit 20a2bbc.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master,3.4.x,4.0.x. Default:master.Description of the PR
Skip model generation if it's a top-level "additionalProperties' (an alias to "additionalProperties")
Closes #391
cc @OpenAPITools/generator-core-team