Closed baholladay closed 7 years ago
@baholladay I would suggest you to generate JS API client using the latest master, which comes with documentation (markdown) on how to use the module.
I was seeing the same error when I exported a javascript client from the editor GUI and added it to my node project.
When I switched to the command line codegen, I got a series of errors like this instead:
ERROR in ./~/whooos-reading-client-api/src/model/DefaultApi.js
Module not found: Error: Cannot resolve module 'InlineResponse200' in /Users/kraken/Learn2Earn/wr_client/node_modules/whooos-reading-client-api/src/model
@ ./~/whooos-reading-client-api/src/model/DefaultApi.js 14:1-16:4
Interestingly, I saw that some of the filenames within 'index.js' were off:
WhooosReadingClientApi.inline_response_200 = require('./model/inline_response_200.js');
Manually changing the file path to InlineResponse200.js
(along with others) to match the filename in the export fixed this problem for me.
I ended up just switching over to https://github.com/swagger-api/swagger-js and have had good results so far.
@gregsherrid I'll take a look at the file name issue later today.
@gregsherrid the issue should be addressed in the master.
src|js_fix_filename⚡ ⇒ ls model/Model200Response.js
model/Model200Response.js
src|js_fix_filename⚡ ⇒ grep Model200Response index.js
define(['ApiClient', 'model/AdditionalPropertiesClass', 'model/Animal', 'model/AnimalFarm', 'model/ApiResponse', 'model/ArrayTest', 'model/Cat', 'model/Category', 'model/Dog', 'model/EnumClass', 'model/EnumTest', 'model/FormatTest', 'model/MixedPropertiesAndAdditionalPropertiesClass', 'model/Model200Response', 'model/ModelReturn', 'model/Name', 'model/Order', 'model/Pet', 'model/ReadOnlyFirst', 'model/SpecialModelName', 'model/Tag', 'model/User', 'api/FakeApi', 'api/PetApi', 'api/StoreApi', 'api/UserApi'], factory);
module.exports = factory(require('./ApiClient'), require('./model/AdditionalPropertiesClass'), require('./model/Animal'), require('./model/AnimalFarm'), require('./model/ApiResponse'), require('./model/ArrayTest'), require('./model/Cat'), require('./model/Category'), require('./model/Dog'), require('./model/EnumClass'), require('./model/EnumTest'), require('./model/FormatTest'), require('./model/MixedPropertiesAndAdditionalPropertiesClass'), require('./model/Model200Response'), require('./model/ModelReturn'), require('./model/Name'), require('./model/Order'), require('./model/Pet'), require('./model/ReadOnlyFirst'), require('./model/SpecialModelName'), require('./model/Tag'), require('./model/User'), require('./api/FakeApi'), require('./api/PetApi'), require('./api/StoreApi'), require('./api/UserApi'));
}(function(ApiClient, AdditionalPropertiesClass, Animal, AnimalFarm, ApiResponse, ArrayTest, Cat, Category, Dog, EnumClass, EnumTest, FormatTest, MixedPropertiesAndAdditionalPropertiesClass, Model200Response, ModelReturn, Name, Order, Pet, ReadOnlyFirst, SpecialModelName, Tag, User, FakeApi, PetApi, StoreApi, UserApi) {
* The Model200Response model constructor.
* @property {module:model/Model200Response}
Model200Response: Model200Response,
Please pull the latest to give it another try.
@baholladay sorry to hear that you've switched to swagger-js to resolve the issue.
Do you mind pulling the latest master to generate the JS API client again and see if you experience the same issue?
I believe, this is fixed. I don't encounter such issue with the latest Swagger-Codegen.
@frol thanks for the verification. Issue closed.
@baholladay @gregsherrid please let us know if you still encounter similar issues in the latest master.
This seems to fix the ApiClient issue but if you define models it's not loading the models. (for me I'm getting Module not found: 'model/Project') and I can confirm it generated modules
@akeemphilbert You might hit the CommonJS vs AMD issue #3466.
After updating my API from the editor.swagger.io -> generate client -> javascript export, I can no longer import my API. I get the following errors:
Module not found: Error: Cannot resolve module 'ApiClient' in ...
This is for all imports listed in src/index.js. I noticed that the relative paths were updated for the AMD import logic and I believe it is tied to those changes. For instance, in index.js:
define(['./ApiClient',... => define(['ApiClient',...
Are there any known issues with these relative path changes?