Skip to content

[Core] Added members for circular refs and container of models - #4758

Open
AIexG wants to merge 14 commits into
OpenAPITools:masterfrom
AIexG:improve_model_gen
Open

[Core] Added members for circular refs and container of models#4758
AIexG wants to merge 14 commits into
OpenAPITools:masterfrom
AIexG:improve_model_gen

Conversation

@AIexG

@AIexGAIexG commented Dec 10, 2019

Copy link
Copy Markdown
Contributor

Added a member circularReferences to CodegenModel which stores all circular referenced schemas. Created ModelUtils method getCircularReferencedSchemaNames() to call recursive detectCircularReferences() to store all found circular references in a Set of strings. Set gets stored in circularReferences.

Add a member flag to CodegenProperty which is true if an array schema consists of object schema items.

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

Related feature request

closes#4757

Additional context

First pull request(s), hopefully doing everything right!

technical committee

cc @OpenAPITools/generator-core-team

* added model utility to handle circular dependencies (e.g. for forward declaration)
* added property isModelContainer if a container contains more models
@AIexGAIexG changed the title Added members for circular refs and container of models[Core] Added members for circular refs and container of modelsDec 10, 2019
@AIexG

AIexG commented Dec 10, 2019

Copy link
Copy Markdown
ContributorAuthor

I noticed that #4553 just got merged, which adds a similar functionality for a different purpose.

@wing328

Copy link
Copy Markdown
Member

When you've time, can you please add some tests similar to those added in #4553 ?

@AIexG

AIexG commented Jan 2, 2020

Copy link
Copy Markdown
ContributorAuthor

Will do when I got some time on my hands again!

@AIexG

Copy link
Copy Markdown
ContributorAuthor

Added some simple test cases, should hopefully be enough!

@AIexGAIexGFeb 6, 2020

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed multiple times now that this list continuously causes conflicts when only separated by spaces. Changing it to line breaks again.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ] detect circular refs in models / detect if container contains models

2 participants

@AIexG@wing328