diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index f6f9c774762..c998ecde892 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -671,6 +671,40 @@ public class ApiClient { return params; } + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + /** * Sanitize filename by removing path. * e.g. ../../sun.gif becomes sun.gif diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache index 6e2c3714c0e..a06c2e35d59 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache @@ -86,7 +86,7 @@ public class {{classname}} { // create path and map variables String localVarPath = "{{{path}}}"{{#pathParams}} - .replaceAll("\\{" + "{{baseName}}" + "\\}", localVarApiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; + .replaceAll("\\{" + "{{baseName}}" + "\\}", localVarApiClient.escapeString({{#collectionFormat}}localVarApiClient.collectionPathParameterToString("{{{collectionFormat}}}", {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}.toString(){{/collectionFormat}})){{/pathParams}}; {{javaUtilPrefix}}List localVarQueryParams = new {{javaUtilPrefix}}ArrayList(); {{javaUtilPrefix}}List localVarCollectionQueryParams = new {{javaUtilPrefix}}ArrayList(); diff --git a/modules/openapi-generator/src/main/resources/go/api.mustache b/modules/openapi-generator/src/main/resources/go/api.mustache index 175962642dd..fe72ace87e7 100644 --- a/modules/openapi-generator/src/main/resources/go/api.mustache +++ b/modules/openapi-generator/src/main/resources/go/api.mustache @@ -236,6 +236,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{/hasBodyParam}} {{#authMethods}} {{#isApiKey}} +{{^isKeyInCookie}} if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { @@ -253,7 +254,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams} {{/isKeyInQuery}} } } - +{{/isKeyInCookie}} {{/isApiKey}} {{/authMethods}} r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/README.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/README.mustache index ad56f190c41..9778346d6d4 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/README.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/README.mustache @@ -31,13 +31,15 @@ _without publishing (not recommended):_ ``` {{#useNgPackagr}} -npm install PATH_TO_GENERATED_PACKAGE/dist --save +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save {{/useNgPackagr}} {{^useNgPackagr}} -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/{{npmName}}-{{npmVersion}}.tgz --save {{/useNgPackagr}} ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ {{#useNgPackagr}} diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache index c2642d8f6f9..d57ec62e8d8 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache @@ -18,8 +18,7 @@ "module": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { - "build": "ngc", - "postinstall": "npm run build" + "build": "ngc && npm pack" }, {{/useNgPackagr}} "peerDependencies": { diff --git a/samples/client/petstore-security-test/typescript-angular/README.md b/samples/client/petstore-security-test/typescript-angular/README.md index b6c812a56ef..6fdf5e362fe 100644 --- a/samples/client/petstore-security-test/typescript-angular/README.md +++ b/samples/client/petstore-security-test/typescript-angular/README.md @@ -25,9 +25,11 @@ npm install @ --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/-.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java index 970b2a690c7..a9fe469fe71 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java @@ -637,6 +637,40 @@ public class ApiClient { return params; } + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + /** * Sanitize filename by removing path. * e.g. ../../sun.gif becomes sun.gif diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java index 970b2a690c7..a9fe469fe71 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java @@ -637,6 +637,40 @@ public class ApiClient { return params; } + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + /** * Sanitize filename by removing path. * e.g. ../../sun.gif becomes sun.gif diff --git a/samples/client/petstore/typescript-angular-v2/default/README.md b/samples/client/petstore/typescript-angular-v2/default/README.md index ae7f5c307e4..c84c27deaba 100644 --- a/samples/client/petstore/typescript-angular-v2/default/README.md +++ b/samples/client/petstore/typescript-angular-v2/default/README.md @@ -25,9 +25,11 @@ npm install @ --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/-.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/typescript-angular-v2/npm/README.md b/samples/client/petstore/typescript-angular-v2/npm/README.md index 0239b2b8e0b..a994f6c32fc 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/README.md +++ b/samples/client/petstore/typescript-angular-v2/npm/README.md @@ -25,9 +25,11 @@ npm install @swagger/angular2-typescript-petstore@0.0.1 --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/@swagger/angular2-typescript-petstore-0.0.1.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/typescript-angular-v2/npm/package.json b/samples/client/petstore/typescript-angular-v2/npm/package.json index faed92258ca..23f4a985d13 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/package.json +++ b/samples/client/petstore/typescript-angular-v2/npm/package.json @@ -12,8 +12,7 @@ "module": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { - "build": "ngc", - "postinstall": "npm run build" + "build": "ngc && npm pack" }, "peerDependencies": { "@angular/core": "^2.0.0", diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md index ae7f5c307e4..c84c27deaba 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md @@ -25,9 +25,11 @@ npm install @ --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/-.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/README.md b/samples/client/petstore/typescript-angular-v4.3/npm/README.md index 64246348157..5c6afb247f9 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/README.md +++ b/samples/client/petstore/typescript-angular-v4.3/npm/README.md @@ -25,9 +25,11 @@ npm install @swagger/angular2-typescript-petstore@0.0.1 --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE/dist --save +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE/dist: diff --git a/samples/client/petstore/typescript-angular-v4/npm/README.md b/samples/client/petstore/typescript-angular-v4/npm/README.md index 867df4b48fb..e19758a3a85 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/README.md +++ b/samples/client/petstore/typescript-angular-v4/npm/README.md @@ -25,9 +25,11 @@ npm install @swagger/angular2-typescript-petstore@0.0.1 --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE/dist --save +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE/dist: diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/README.md b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/README.md index b6c812a56ef..6fdf5e362fe 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/README.md +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/README.md @@ -25,9 +25,11 @@ npm install @ --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/-.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/README.md b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/README.md index a1d8a9592d8..cc77efb8f00 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/README.md +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/README.md @@ -25,9 +25,11 @@ npm install @swagger/typescript-angular-petstore@1.0.0 --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE/dist --save +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE/dist: diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/README.md b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/README.md index b6c812a56ef..6fdf5e362fe 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/README.md +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/README.md @@ -25,9 +25,11 @@ npm install @ --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/-.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/README.md b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/README.md index a1d8a9592d8..cc77efb8f00 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/README.md +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/README.md @@ -25,9 +25,11 @@ npm install @swagger/typescript-angular-petstore@1.0.0 --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE/dist --save +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE/dist: diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/README.md b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/README.md index b6c812a56ef..6fdf5e362fe 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/README.md +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/README.md @@ -25,9 +25,11 @@ npm install @ --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/-.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/README.md b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/README.md index a1d8a9592d8..cc77efb8f00 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/README.md +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/README.md @@ -25,9 +25,11 @@ npm install @swagger/typescript-angular-petstore@1.0.0 --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE/dist --save +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE/dist: diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/README.md b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/README.md index b6c812a56ef..6fdf5e362fe 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/README.md +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/README.md @@ -25,9 +25,11 @@ npm install @ --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE --save +npm install PATH_TO_GENERATED_PACKAGE/-.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE: diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/README.md b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/README.md index a1d8a9592d8..cc77efb8f00 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/README.md +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/README.md @@ -25,9 +25,11 @@ npm install @swagger/typescript-angular-petstore@1.0.0 --save _without publishing (not recommended):_ ``` -npm install PATH_TO_GENERATED_PACKAGE/dist --save +npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save ``` +_It's important to take the tgz file, otherwise you'll get trouble with links on windows_ + _using `npm link`:_ In PATH_TO_GENERATED_PACKAGE/dist: