diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java index edde98f3e8d..a6449587ac3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptFetchClientCodegen.java @@ -40,6 +40,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege supportingFiles.add(new SupportingFile("package.json.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("typings.json.mustache", "", "typings.json")); supportingFiles.add(new SupportingFile("tsconfig.json.mustache", "", "tsconfig.json")); + supportingFiles.add(new SupportingFile("tslint.json.mustache", "", "tslint.json")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); if(additionalProperties.containsKey(NPM_NAME)) { diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache index b3cfa638030..907089e33bd 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/api.mustache @@ -10,7 +10,7 @@ import * as assign from "core-js/library/fn/object/assign"; interface Dictionary { [index: string]: T; } export interface FetchAPI { (url: string, init?: any): Promise; } -const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ''); +const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); export interface FetchArgs { url: string; @@ -83,8 +83,10 @@ export const {{classname}}FetchParamCreactor = { .replace(`{${"{{baseName}}"}}`, `${ params["{{paramName}}"] }`){{/pathParams}}; let urlObj = url.parse(baseUrl, true); {{#hasQueryParams}} - urlObj.query = {{#supportsES6}}Object.{{/supportsES6}}assign({}, urlObj.query, { {{#queryParams}} - "{{baseName}}": params["{{paramName}}"],{{/queryParams}} + urlObj.query = {{#supportsES6}}Object.{{/supportsES6}}assign({}, urlObj.query, { + {{#queryParams}} + "{{baseName}}": params["{{paramName}}"], + {{/queryParams}} }); {{/hasQueryParams}} let fetchOptions: RequestInit = {{#supportsES6}}Object.{{/supportsES6}}assign({}, { method: "{{httpMethod}}" }, options); @@ -103,8 +105,8 @@ export const {{classname}}FetchParamCreactor = { }{{/bodyParam}} {{/hasBodyParam}} {{#hasHeaderParams}} - fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({ {{#headerParams}} - "{{baseName}}": params["{{paramName}}"],{{/headerParams}} + fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({ + {{#headerParams}}"{{baseName}}": params["{{paramName}}"],{{/headerParams}} }, contentTypeHeader); {{/hasHeaderParams}} {{^hasHeaderParams}} diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache index 5243c579c29..05aec69d7ec 100644 --- a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/package.json.mustache @@ -10,9 +10,11 @@ {{/supportsES6}}"isomorphic-fetch": "^2.2.1" }, "scripts" : { - "prepublish" : "typings install && tsc" + "prepublish" : "typings install && tsc", + "test": "tslint api.ts" }, "devDependencies": { + "tslint": "^3.15.1", "typescript": "^1.8.10", "typings": "^1.0.4" } diff --git a/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/tslint.json.mustache b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/tslint.json.mustache new file mode 100644 index 00000000000..6eb02acec8c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/tslint.json.mustache @@ -0,0 +1,101 @@ +{ + "jsRules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-duplicate-variable": true, + "no-eval": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + }, + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "no-var-keyword": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} diff --git a/samples/client/petstore-security-test/typescript-fetch/api.ts b/samples/client/petstore-security-test/typescript-fetch/api.ts index e935898c22f..6936a0ffb53 100644 --- a/samples/client/petstore-security-test/typescript-fetch/api.ts +++ b/samples/client/petstore-security-test/typescript-fetch/api.ts @@ -8,18 +8,6 @@ * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. */ import * as querystring from "querystring"; @@ -31,7 +19,7 @@ import * as assign from "core-js/library/fn/object/assign"; interface Dictionary { [index: string]: T; } export interface FetchAPI { (url: string, init?: any): Promise; } -const BASE_PATH = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r".replace(/\/+$/, ''); +const BASE_PATH = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r".replace(/\/+$/, ""); export interface FetchArgs { url: string; @@ -46,7 +34,7 @@ export class BaseAPI { this.basePath = basePath; this.fetch = fetch; } -} +}; /** * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r @@ -68,7 +56,7 @@ export const FakeApiFetchParamCreactor = { * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ - testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any): FetchArgs { + testCodeInjectEndRnNR(params: { "test code inject * ' " =end rn n r"?: string; }, options?: any): FetchArgs { const baseUrl = `/fake`; let urlObj = url.parse(baseUrl, true); let fetchOptions: RequestInit = assign({}, { method: "PUT" }, options); @@ -76,7 +64,7 @@ export const FakeApiFetchParamCreactor = { let contentTypeHeader: Dictionary; contentTypeHeader = { "Content-Type": "application/x-www-form-urlencoded" }; fetchOptions.body = querystring.stringify({ - "test code inject */ ' " =end -- \r\n \n \r": params.test code inject * ' " =end rn n r, + "test code inject */ ' " =end -- \r\n \n \r": params["test code inject * ' " =end rn n r"], }); if (contentTypeHeader) { fetchOptions.headers = contentTypeHeader; @@ -86,7 +74,7 @@ export const FakeApiFetchParamCreactor = { options: fetchOptions, }; }, -} +}; /** * FakeApi - functional programming interface @@ -96,7 +84,7 @@ export const FakeApiFp = { * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ - testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { + testCodeInjectEndRnNR(params: { "test code inject * ' " =end rn n r"?: string; }, options?: any): (fetch: FetchAPI, basePath?: string) => Promise { const fetchArgs = FakeApiFetchParamCreactor.testCodeInjectEndRnNR(params, options); return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { @@ -118,7 +106,7 @@ export class FakeApi extends BaseAPI { * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ - testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any) { + testCodeInjectEndRnNR(params: { "test code inject * ' " =end rn n r"?: string; }, options?: any) { return FakeApiFp.testCodeInjectEndRnNR(params, options)(this.fetch, this.basePath); } }; @@ -132,9 +120,9 @@ export const FakeApiFactory = function (fetch?: FetchAPI, basePath?: string) { * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r */ - testCodeInjectEndRnNR(params: { test code inject * ' " =end rn n r?: string; }, options?: any) { + testCodeInjectEndRnNR(params: { "test code inject * ' " =end rn n r"?: string; }, options?: any) { return FakeApiFp.testCodeInjectEndRnNR(params, options)(fetch, basePath); }, - } + }; }; diff --git a/samples/client/petstore-security-test/typescript-fetch/package.json b/samples/client/petstore-security-test/typescript-fetch/package.json index 97e572353a3..0204e3c39c9 100644 --- a/samples/client/petstore-security-test/typescript-fetch/package.json +++ b/samples/client/petstore-security-test/typescript-fetch/package.json @@ -1,7 +1,7 @@ { "name": "typescript-fetch-api", "version": "0.0.0", - "license": "Apache-2.0", + "license": "Unlicense", "main": "./dist/api.js", "browser": "./dist/api.js", "typings": "./dist/api.d.ts", @@ -10,9 +10,11 @@ "isomorphic-fetch": "^2.2.1" }, "scripts" : { - "prepublish" : "typings install && tsc" + "prepublish" : "typings install && tsc", + "test": "tslint api.ts" }, "devDependencies": { + "tslint": "^3.15.1", "typescript": "^1.8.10", "typings": "^1.0.4" } diff --git a/samples/client/petstore-security-test/typescript-fetch/tslint.json b/samples/client/petstore-security-test/typescript-fetch/tslint.json new file mode 100644 index 00000000000..6eb02acec8c --- /dev/null +++ b/samples/client/petstore-security-test/typescript-fetch/tslint.json @@ -0,0 +1,101 @@ +{ + "jsRules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-duplicate-variable": true, + "no-eval": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + }, + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "no-var-keyword": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/default/api.ts b/samples/client/petstore/typescript-fetch/builds/default/api.ts index fdf7cbc5cdc..c8445d1edfb 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/api.ts @@ -19,7 +19,7 @@ import * as assign from "core-js/library/fn/object/assign"; interface Dictionary { [index: string]: T; } export interface FetchAPI { (url: string, init?: any): Promise; } -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); +const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface FetchArgs { url: string; @@ -132,7 +132,7 @@ export const PetApiFetchParamCreactor = { let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; - fetchOptions.headers = assign({ + fetchOptions.headers = assign({ "api_key": params["apiKey"], }, contentTypeHeader); return { @@ -148,7 +148,7 @@ export const PetApiFetchParamCreactor = { findPetsByStatus(params: { "status"?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByStatus`; let urlObj = url.parse(baseUrl, true); - urlObj.query = assign({}, urlObj.query, { + urlObj.query = assign({}, urlObj.query, { "status": params["status"], }); let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); @@ -170,7 +170,7 @@ export const PetApiFetchParamCreactor = { findPetsByTags(params: { "tags"?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByTags`; let urlObj = url.parse(baseUrl, true); - urlObj.query = assign({}, urlObj.query, { + urlObj.query = assign({}, urlObj.query, { "tags": params["tags"], }); let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); @@ -970,7 +970,7 @@ export const UserApiFetchParamCreactor = { loginUser(params: { "username"?: string; "password"?: string; }, options?: any): FetchArgs { const baseUrl = `/user/login`; let urlObj = url.parse(baseUrl, true); - urlObj.query = assign({}, urlObj.query, { + urlObj.query = assign({}, urlObj.query, { "username": params["username"], "password": params["password"], }); diff --git a/samples/client/petstore/typescript-fetch/builds/default/package.json b/samples/client/petstore/typescript-fetch/builds/default/package.json index ce62ea19fbe..0204e3c39c9 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/package.json +++ b/samples/client/petstore/typescript-fetch/builds/default/package.json @@ -10,9 +10,11 @@ "isomorphic-fetch": "^2.2.1" }, "scripts" : { - "prepublish" : "typings install && tsc" + "prepublish" : "typings install && tsc", + "test": "tslint api.ts" }, "devDependencies": { + "tslint": "^3.15.1", "typescript": "^1.8.10", "typings": "^1.0.4" } diff --git a/samples/client/petstore/typescript-fetch/builds/default/tslint.json b/samples/client/petstore/typescript-fetch/builds/default/tslint.json new file mode 100644 index 00000000000..6eb02acec8c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/default/tslint.json @@ -0,0 +1,101 @@ +{ + "jsRules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-duplicate-variable": true, + "no-eval": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + }, + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "no-var-keyword": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts index 2a5a95b3c21..832e5417e0e 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/api.ts @@ -18,7 +18,7 @@ import * as isomorphicFetch from "isomorphic-fetch"; interface Dictionary { [index: string]: T; } export interface FetchAPI { (url: string, init?: any): Promise; } -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); +const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface FetchArgs { url: string; @@ -131,7 +131,7 @@ export const PetApiFetchParamCreactor = { let fetchOptions: RequestInit = Object.assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; - fetchOptions.headers = Object.assign({ + fetchOptions.headers = Object.assign({ "api_key": params["apiKey"], }, contentTypeHeader); return { @@ -147,7 +147,7 @@ export const PetApiFetchParamCreactor = { findPetsByStatus(params: { "status"?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByStatus`; let urlObj = url.parse(baseUrl, true); - urlObj.query = Object.assign({}, urlObj.query, { + urlObj.query = Object.assign({}, urlObj.query, { "status": params["status"], }); let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); @@ -169,7 +169,7 @@ export const PetApiFetchParamCreactor = { findPetsByTags(params: { "tags"?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByTags`; let urlObj = url.parse(baseUrl, true); - urlObj.query = Object.assign({}, urlObj.query, { + urlObj.query = Object.assign({}, urlObj.query, { "tags": params["tags"], }); let fetchOptions: RequestInit = Object.assign({}, { method: "GET" }, options); @@ -969,7 +969,7 @@ export const UserApiFetchParamCreactor = { loginUser(params: { "username"?: string; "password"?: string; }, options?: any): FetchArgs { const baseUrl = `/user/login`; let urlObj = url.parse(baseUrl, true); - urlObj.query = Object.assign({}, urlObj.query, { + urlObj.query = Object.assign({}, urlObj.query, { "username": params["username"], "password": params["password"], }); diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/package.json b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json index e05dd91ca8c..9797e3483f9 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/package.json +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/package.json @@ -9,9 +9,11 @@ "isomorphic-fetch": "^2.2.1" }, "scripts" : { - "prepublish" : "typings install && tsc" + "prepublish" : "typings install && tsc", + "test": "tslint api.ts" }, "devDependencies": { + "tslint": "^3.15.1", "typescript": "^1.8.10", "typings": "^1.0.4" } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/tslint.json b/samples/client/petstore/typescript-fetch/builds/es6-target/tslint.json new file mode 100644 index 00000000000..6eb02acec8c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/tslint.json @@ -0,0 +1,101 @@ +{ + "jsRules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-duplicate-variable": true, + "no-eval": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + }, + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "no-var-keyword": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts index fdf7cbc5cdc..c8445d1edfb 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/api.ts @@ -19,7 +19,7 @@ import * as assign from "core-js/library/fn/object/assign"; interface Dictionary { [index: string]: T; } export interface FetchAPI { (url: string, init?: any): Promise; } -const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ''); +const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface FetchArgs { url: string; @@ -132,7 +132,7 @@ export const PetApiFetchParamCreactor = { let fetchOptions: RequestInit = assign({}, { method: "DELETE" }, options); let contentTypeHeader: Dictionary; - fetchOptions.headers = assign({ + fetchOptions.headers = assign({ "api_key": params["apiKey"], }, contentTypeHeader); return { @@ -148,7 +148,7 @@ export const PetApiFetchParamCreactor = { findPetsByStatus(params: { "status"?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByStatus`; let urlObj = url.parse(baseUrl, true); - urlObj.query = assign({}, urlObj.query, { + urlObj.query = assign({}, urlObj.query, { "status": params["status"], }); let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); @@ -170,7 +170,7 @@ export const PetApiFetchParamCreactor = { findPetsByTags(params: { "tags"?: Array; }, options?: any): FetchArgs { const baseUrl = `/pet/findByTags`; let urlObj = url.parse(baseUrl, true); - urlObj.query = assign({}, urlObj.query, { + urlObj.query = assign({}, urlObj.query, { "tags": params["tags"], }); let fetchOptions: RequestInit = assign({}, { method: "GET" }, options); @@ -970,7 +970,7 @@ export const UserApiFetchParamCreactor = { loginUser(params: { "username"?: string; "password"?: string; }, options?: any): FetchArgs { const baseUrl = `/user/login`; let urlObj = url.parse(baseUrl, true); - urlObj.query = assign({}, urlObj.query, { + urlObj.query = assign({}, urlObj.query, { "username": params["username"], "password": params["password"], }); diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json index 07cbcf57454..f4c8ca8a162 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/package.json @@ -10,9 +10,11 @@ "isomorphic-fetch": "^2.2.1" }, "scripts" : { - "prepublish" : "typings install && tsc" + "prepublish" : "typings install && tsc", + "test": "tslint api.ts" }, "devDependencies": { + "tslint": "^3.15.1", "typescript": "^1.8.10", "typings": "^1.0.4" } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/tslint.json b/samples/client/petstore/typescript-fetch/builds/with-npm-version/tslint.json new file mode 100644 index 00000000000..6eb02acec8c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/tslint.json @@ -0,0 +1,101 @@ +{ + "jsRules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-duplicate-variable": true, + "no-eval": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + }, + "rules": { + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "indent": [ + true, + "spaces" + ], + "no-eval": true, + "no-internal-module": true, + "no-trailing-whitespace": true, + "no-unsafe-finally": true, + "no-var-keyword": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +}