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

[Javascript] ES6 and react / react-native #9635

Open
arthurpankiewicz opened this issue Aug 12, 2019 · 0 comments
Open

[Javascript] ES6 and react / react-native #9635

arthurpankiewicz opened this issue Aug 12, 2019 · 0 comments

Comments

@arthurpankiewicz
Copy link

arthurpankiewicz commented Aug 12, 2019

Description

I am trying to use swagger-codegen to generate client-side code in my monorepo project

Swagger-codegen version

2.4.7

Swagger declaration file content or url

http://petstore.swagger.io/v2/swagger.json

Command line used for generation
swagger-codegen generate \                                                                                                                                                                        
--input-spec http://petstore.swagger.io/v2/swagger.json \
--lang javascript \
--output ./petstore \
--template-dir ./es6 \
--additional-properties usePromises=true,useES6=true
Steps to reproduce
  1. Within my monorepo I am running the swagger-codegen generate command at the packages level
app
  - packages
    - repo1
    - repo2
    - repo3
  - package.json

The es6 template-dir is taken from the github issue linked below.

  1. cd into packages/petstore and run npm install

  2. rerun my react app

First issue

The template-dir does not seem to solve the experimental classProperties problem:

../petstore/src/ApiClient.js
SyntaxError: /path/to/packages/petstore/src/ApiClient.js: Support for the experimental syntax 'classProperties' isn't currently enabled (231:33):

I can get around this issue by replacing all classProperties with methods of the same name.

Second issue

If I use the workaround in the first issue, I now receive the error

TypeError: _petstore_src__WEBPACK_IMPORTED_MODULE_5__.PetApi.getPetById is not a function

when importing import { PetApi } from '../path/to/petstore/src and trying to call

PetApi.getPetById(1)
Related issues/PRs

#8024

I'm sure I'm missing an obvious step here, so any help is appreciated.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant