-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: unable to get model class when using arrays in schema (#207)
* fix: resolve NPE when attempting to use a null modelClass by trying to use the x-parser-schema-id property of the source schemafirst, then try the property name. * fix: fixed issues with keyword schema naming and writing inner classes that should have been their own class; the schema name is going to be correct more often from using x-schema-parser-id instead when appropriate; broke all args constructor for schemas that are arrays with this commit. * fix: created partial for all args constructor; all args constructor now correctly created for array types * chore: remove code smells; stripPackage function is more cohesive; removed need for a tentative class name. * chore: remove useless modelClass assignment in anonSchema allOf handling * chore: clean up todo; use ternary instead of if statement * update snapshot; unnecessary spacing removed due to removal of comment * chore: fix linting problems
- Loading branch information
1 parent
0313e3f
commit 582fced
Showing
11 changed files
with
1,514 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{%- macro allArgsConstructor(className, properties, indentLevel) -%} | ||
{% set indent1 = indentLevel | indent1 -%} | ||
{% set indent2 = indentLevel | indent2 -%} | ||
{% set indent3 = indentLevel | indent3 -%} | ||
{% set first = true -%} | ||
{%- set hasNoProperties = properties | isEmpty -%} | ||
{%- if not hasNoProperties -%} | ||
{{ indent2 }}public {{ className }} ( | ||
{%- for name, prop in properties -%} | ||
{%- set propModelClass = {schema: prop, schemaName: name} | getModelClass %} | ||
{%- set realClassName = propModelClass.getClassName() %} | ||
{%- set variableName = realClassName | identifierName %} | ||
{%- set typeInfo = [name, realClassName, prop] | fixType %} | ||
{%- set type = typeInfo[0] -%} | ||
{%- if first -%} | ||
{%- set first = false -%} | ||
{%- else -%} | ||
, {% endif %} | ||
{{ indent3 }}{{ type }} {{ variableName }} | ||
{%- endfor -%} | ||
) { | ||
{% for name, prop in properties -%} | ||
{%- set propModelClass = {schema: prop, schemaName: name} | getModelClass %} | ||
{%- set realClassName = propModelClass.getClassName() %} | ||
{%- set variableName = realClassName | identifierName -%} | ||
{{ indent3 }}this.{{ variableName }} = {{ variableName }}; | ||
{% endfor -%} | ||
{{ indent2 }}} | ||
{%- endif -%} | ||
{% endmacro %} |
Oops, something went wrong.