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

New Javascript flowtyped generator #176

Merged
merged 8 commits into from
Jun 25, 2018
Merged

Conversation

jaypea
Copy link
Contributor

@jaypea jaypea commented May 29, 2018

As discussed in swagger-api/swagger-codegen#5733 there is no generator which outputs Javascript which is properly flow typed and easy to use with React.

Here is it now.

Is is based on the Typescript Fetch Generator, so differs from the other Javascript Generators in code and architecture.

Simply adding flow annotations didn't work with the current js es6 code.

The code is written in ES6 with flow syntax. In order to use it as a library in your react app, it comes with a npm build script to transpile it into node.js and browser compatible es5 syntax with additional .js.flow for flow to use the types properly.

steps to use this client as a npm library:

create yourself a new folder and repo for the client sdk
generate client with java -jar swagger-codegen-cli-2.3.1.jar generate -i swagger.json -l javascript-flowtyped -o
npm install
NODE_ENV=production npm run build
git add .
git commit -m 'update sdk version'
git tag v
git push && git push --tags
in your react app do:
npm install #v
import { * as api } from 'client-sdk-package'
if you want to generate the api directly inside your client-app you can do so. just import the files from the generated src then. these are pure es6 with flow types and need to be transpiled like you would do with the other code.

this is a copy of my changes in swagger-api/swagger-codegen#8101 without adjustments to this new project.
@wing328 please advise how to proceed with this PR

@wing328
Copy link
Member

wing328 commented Jun 1, 2018

@jaypea thanks for the PR. I'll work with you on this after the 3.0.0 stable release (due today)

@jimschubert jimschubert added the WIP Work in Progress label Jun 10, 2018
@jimschubert
Copy link
Member

@jaypea I've added the WIP label.

@wing328 this is tagged for 3.0.1 (going out tomorrow). We may want to tag only at minor versions, just to make it easier to maintain milestones.

@wing328 wing328 removed this from the 3.0.1 milestone Jun 11, 2018
@wing328
Copy link
Member

wing328 commented Jun 16, 2018

@jaypea I've pushed a few commits for enhancements:

  • add JS flowtype samples
  • setup CI to catch errors thrown by npm run build
  • minor wording changes.

There are other enhancements (day 2 requirement) that I'll open an "issue" (ticket) for tracking.

If these changes look good to you, we can merge it into master and ask other JS developers to try it out.

@jaypea
Copy link
Contributor Author

jaypea commented Jun 19, 2018

@wing328 all looking good. thanks for taking care.

@wing328 wing328 changed the title WIP: new javascript flowtyped generator New Javascript flowtyped generator Jun 25, 2018
@wing328 wing328 removed the WIP Work in Progress label Jun 25, 2018
@wing328 wing328 added this to the 3.0.3 milestone Jun 25, 2018
@wing328 wing328 merged commit a0bfe2b into OpenAPITools:master Jun 25, 2018
@jaypea jaypea deleted the js-flow-typed branch June 25, 2018 16:48
@jaypea jaypea restored the js-flow-typed branch June 25, 2018 16:48
@jaypea jaypea deleted the js-flow-typed branch January 22, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants