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

[Typescript All] Prevent usage of reserved keyword for model fields #7112

Merged
merged 3 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
if (Boolean.TRUE.equals(var.isEnum)) {
var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, cm.classname + "." + var.enumName);
}

if (isReservedWord(var.name)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow the JS approach, which is used by other generators (e.g. Ruby, PHP, etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! Will try to commit a fix this week! Thanks for the review!

var.name = escapeReservedWord(var.name);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/typescript-angularjs/git_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
Expand Down
24 changes: 12 additions & 12 deletions samples/client/petstore/typescript-fetch/builds/default/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const COLLECTION_FORMATS = {
* @interface FetchAPI
*/
export interface FetchAPI {
(url: string, init?: any): Promise<any>;
(url: string, init?: any): Promise<Response>;
}

/**
Expand Down Expand Up @@ -689,7 +689,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -709,7 +709,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -785,7 +785,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -806,7 +806,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1188,7 +1188,7 @@ export const StoreApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1637,7 +1637,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1656,7 +1656,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUsersWithArrayInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUsersWithArrayInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1675,7 +1675,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUsersWithListInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUsersWithListInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1694,7 +1694,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1751,7 +1751,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1771,7 +1771,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
Expand Down
24 changes: 12 additions & 12 deletions samples/client/petstore/typescript-fetch/builds/es6-target/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const COLLECTION_FORMATS = {
* @interface FetchAPI
*/
export interface FetchAPI {
(url: string, init?: any): Promise<any>;
(url: string, init?: any): Promise<Response>;
}

/**
Expand Down Expand Up @@ -689,7 +689,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
addPet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).addPet(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -709,7 +709,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deletePet(petId: number, apiKey?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).deletePet(petId, apiKey, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -785,7 +785,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updatePet(body: Pet, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePet(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -806,7 +806,7 @@ export const PetApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updatePetWithForm(petId: number, name?: string, status?: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = PetApiFetchParamCreator(configuration).updatePetWithForm(petId, name, status, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1188,7 +1188,7 @@ export const StoreApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deleteOrder(orderId: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = StoreApiFetchParamCreator(configuration).deleteOrder(orderId, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1637,7 +1637,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUser(body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUser(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1656,7 +1656,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUsersWithArrayInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUsersWithArrayInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithArrayInput(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1675,7 +1675,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createUsersWithListInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
createUsersWithListInput(body: Array<User>, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).createUsersWithListInput(body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1694,7 +1694,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
deleteUser(username: string, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).deleteUser(username, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down Expand Up @@ -1751,7 +1751,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
logoutUser(options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).logoutUser(options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand All @@ -1771,7 +1771,7 @@ export const UserApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<any> {
updateUser(username: string, body: User, options?: any): (fetch?: FetchAPI, basePath?: string) => Promise<Response> {
const localVarFetchArgs = UserApiFetchParamCreator(configuration).updateUser(username, body, options);
return (fetch: FetchAPI = portableFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
Expand Down
Loading