From 54f5d73ee245811baf0b82eaae0b0ef3949b9f0a Mon Sep 17 00:00:00 2001 From: Vlad Frolov Date: Sun, 4 Jun 2017 10:42:41 +0300 Subject: [PATCH] [javascript] Added README section for Webpack configuration (closes #3466) (#5767) --- .../resources/Javascript-es6/README.mustache | 27 ++++++++++++++++++- .../main/resources/Javascript/README.mustache | 27 ++++++++++++++++++- .../client/petstore/javascript-es6/README.md | 27 ++++++++++++++++++- .../petstore/javascript-promise-es6/README.md | 27 ++++++++++++++++++- .../petstore/javascript-promise/README.md | 27 ++++++++++++++++++- samples/client/petstore/javascript/README.md | 27 ++++++++++++++++++- 6 files changed, 156 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Javascript-es6/README.mustache b/modules/swagger-codegen/src/main/resources/Javascript-es6/README.mustache index 9bbf4b4f43a..96847c36672 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript-es6/README.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript-es6/README.mustache @@ -32,7 +32,7 @@ npm install {{{projectName}}} --save ``` #### git -# + If the library is hosted at a git repository, e.g. https://github.com/{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}YOUR_USERNAME{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}} then install it via: @@ -103,6 +103,31 @@ api.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensi {{/usePromises}}{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` +### Webpack Configuration + +Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader: + +1. Add `imports-loader` package: + + ```bash + npm install --save-dev imports-loader + ``` +2. Add the following sections to your webpack config (replace `MY_API_CLIENT_NAME` with your module name): + + ```javascript + module: { + rules: [ + { + test: /MY_API_CLIENT_NAME[\/\\]+.*\.js$/, + use: 'imports-loader?define=>false' + } + ] + }, + node: { + fs: 'empty' + } + ``` + ## Documentation for API Endpoints All URIs are relative to *{{basePath}}* diff --git a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache index 9bbf4b4f43a..96847c36672 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/README.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/README.mustache @@ -32,7 +32,7 @@ npm install {{{projectName}}} --save ``` #### git -# + If the library is hosted at a git repository, e.g. https://github.com/{{#gitUserId}}{{.}}{{/gitUserId}}{{^gitUserId}}YOUR_USERNAME{{/gitUserId}}/{{#gitRepoId}}{{.}}{{/gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}} then install it via: @@ -103,6 +103,31 @@ api.{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{#vendorExtensi {{/usePromises}}{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` +### Webpack Configuration + +Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader: + +1. Add `imports-loader` package: + + ```bash + npm install --save-dev imports-loader + ``` +2. Add the following sections to your webpack config (replace `MY_API_CLIENT_NAME` with your module name): + + ```javascript + module: { + rules: [ + { + test: /MY_API_CLIENT_NAME[\/\\]+.*\.js$/, + use: 'imports-loader?define=>false' + } + ] + }, + node: { + fs: 'empty' + } + ``` + ## Documentation for API Endpoints All URIs are relative to *{{basePath}}* diff --git a/samples/client/petstore/javascript-es6/README.md b/samples/client/petstore/javascript-es6/README.md index 740edf8857d..0660de14040 100644 --- a/samples/client/petstore/javascript-es6/README.md +++ b/samples/client/petstore/javascript-es6/README.md @@ -24,7 +24,7 @@ npm install swagger_petstore --save ``` #### git -# + If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via: @@ -69,6 +69,31 @@ api.fakeOuterBooleanSerialize(opts, callback); ``` +### Webpack Configuration + +Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader: + +1. Add `imports-loader` package: + + ```bash + npm install --save-dev imports-loader + ``` +2. Add the following sections to your webpack config (replace `MY_API_CLIENT_NAME` with your module name): + + ```javascript + module: { + rules: [ + { + test: /MY_API_CLIENT_NAME[\/\\]+.*\.js$/, + use: 'imports-loader?define=>false' + } + ] + }, + node: { + fs: 'empty' + } + ``` + ## Documentation for API Endpoints All URIs are relative to *http://petstore.swagger.io:80/v2* diff --git a/samples/client/petstore/javascript-promise-es6/README.md b/samples/client/petstore/javascript-promise-es6/README.md index 05378564d17..86c463ef358 100644 --- a/samples/client/petstore/javascript-promise-es6/README.md +++ b/samples/client/petstore/javascript-promise-es6/README.md @@ -24,7 +24,7 @@ npm install swagger_petstore --save ``` #### git -# + If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via: @@ -66,6 +66,31 @@ api.fakeOuterBooleanSerialize(opts).then(function(data) { ``` +### Webpack Configuration + +Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader: + +1. Add `imports-loader` package: + + ```bash + npm install --save-dev imports-loader + ``` +2. Add the following sections to your webpack config (replace `MY_API_CLIENT_NAME` with your module name): + + ```javascript + module: { + rules: [ + { + test: /MY_API_CLIENT_NAME[\/\\]+.*\.js$/, + use: 'imports-loader?define=>false' + } + ] + }, + node: { + fs: 'empty' + } + ``` + ## Documentation for API Endpoints All URIs are relative to *http://petstore.swagger.io:80/v2* diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 05378564d17..86c463ef358 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -24,7 +24,7 @@ npm install swagger_petstore --save ``` #### git -# + If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via: @@ -66,6 +66,31 @@ api.fakeOuterBooleanSerialize(opts).then(function(data) { ``` +### Webpack Configuration + +Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader: + +1. Add `imports-loader` package: + + ```bash + npm install --save-dev imports-loader + ``` +2. Add the following sections to your webpack config (replace `MY_API_CLIENT_NAME` with your module name): + + ```javascript + module: { + rules: [ + { + test: /MY_API_CLIENT_NAME[\/\\]+.*\.js$/, + use: 'imports-loader?define=>false' + } + ] + }, + node: { + fs: 'empty' + } + ``` + ## Documentation for API Endpoints All URIs are relative to *http://petstore.swagger.io:80/v2* diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index 740edf8857d..0660de14040 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -24,7 +24,7 @@ npm install swagger_petstore --save ``` #### git -# + If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via: @@ -69,6 +69,31 @@ api.fakeOuterBooleanSerialize(opts, callback); ``` +### Webpack Configuration + +Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader: + +1. Add `imports-loader` package: + + ```bash + npm install --save-dev imports-loader + ``` +2. Add the following sections to your webpack config (replace `MY_API_CLIENT_NAME` with your module name): + + ```javascript + module: { + rules: [ + { + test: /MY_API_CLIENT_NAME[\/\\]+.*\.js$/, + use: 'imports-loader?define=>false' + } + ] + }, + node: { + fs: 'empty' + } + ``` + ## Documentation for API Endpoints All URIs are relative to *http://petstore.swagger.io:80/v2*