Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: allow colons in TS interface property names #1152

Merged
merged 9 commits into from
Oct 3, 2018

Conversation

smasala
Copy link
Contributor

@smasala smasala commented Oct 1, 2018

Developed with @Xyaren

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if 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\.
  • Filed the PR against the correct branch: master (3.3.x), 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09)

Description of the PR

Fix latest version by adding single quotes to properties with colons.

Example:

export interface MyInterface {
    'my:name:property': string;
}

Original issue: #1080

return name;
}

private boolean hasIllegalCharacters(String name) {
Copy link
Member

Choose a reason for hiding this comment

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

a description in which context the characters are "illegal" would be nice

@macjohnny
Copy link
Member

@smasala you need to replace the tab with spaces in https://github.com/OpenAPITools/openapi-generator/pull/1152/files#diff-328108658e03bbcf6cc8b931ffa7a63eR201

if (hasIllegalCharacters(name)) {
name = "\'" + name + "\'";
}

return name;
}

private boolean hasIllegalCharacters(String name) {
/**
* Checks whether illegal characters are present in the given param
Copy link
Member

Choose a reason for hiding this comment

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

what is an illegal character and why?

@smasala
Copy link
Contributor Author

smasala commented Oct 2, 2018

@macjohnny this PR is now complete

@@ -184,6 +186,33 @@ public String toVarName(String name) {
return name;
}

@Override()
Copy link
Member

Choose a reason for hiding this comment

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

@smasala what about updating toParamName with the code logic in toVarName (line 167 to 186) and then toVarName will call toParamName instead before the additional propertyHasBreakingCharacters check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wing328 and then leaving the toPropertyName completely out?

@wing328 wing328 merged commit 1916025 into OpenAPITools:master Oct 3, 2018
@smasala
Copy link
Contributor Author

smasala commented Oct 3, 2018

Thanks @wing328 and @macjohnny

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* Allow colons in interface property names: OpenAPITools#1080

* replace tabs with spaces

* add docs

* add example in doc

* update docs

* update docs

* remove language specific docs in DefaultCodegen

* Delete addPet-BodyParams.csv

* remove toPropertyName and update toVarName instead for TS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants