progresso-group / openapi-typescript-client-api-generator Goto Github PK
View Code? Open in Web Editor NEWA generator that reads swagger / open api 3 json configs and generates typescript client services with axios
License: MIT License
A generator that reads swagger / open api 3 json configs and generates typescript client services with axios
License: MIT License
The generic axios code generator by openapi spits out these two files
https://gist.github.com/johndpope/6b08cad61a0ac69f3590beae82fe304a
perhaps this could be used for BaseService ?
Using this cannonical json file
https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/petstore.json
The code generation fails
I suspect because the base service specification is mandatory - it's probably my own fault -
but I need some sample base service so that this code generation succeeds.
./generate.sh
yarn run v1.17.3
$ openapi-typescript-client-api-generator -c petstore.json -sb /client/services -s /client/api/services -m /client/api/models -sm /server/modules/api/models
InStage client api generator
Loading config file...
Config file with version 2.0 found.
Running converter...
Converted.
Augmenting config with server models...
Loaded 0 server models.
Added 0 server models to the configuration.
Config file loaded.
Loading api info...
Done.
Loading models...
Loaded 3 models.
Generating model files...
Generated 3 model files.
Loading request bodies...
Loaded 0 request bodies.
Generating request body files...
Generated 0 request body files.
(node:40147) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
at servicesLoader (/Users/admin/Documents/8secondz-workspace/8secondz-axios/node_modules/@progresso/openapi-typescript-client-api-generator/loaders/servicesLoader.js:5:30)
at generate (/Users/admin/Documents/8secondz-workspace/8secondz-axios/node_modules/@progresso/openapi-typescript-client-api-generator/index.js:48:22)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:40147) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:40147) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
โจ Done in 0.22s.
N.B. there are some models spat out successfully.
/**
* Swagger Petstore 1.0.0 (OpenAPI: 3.0.0)
*
*
* NOTE: This class is auto generated by openapi-typescript-client-api-generator.
* Do not edit the file manually.
*/
export class Pet {
public id: number;
public name: string;
public tag: string;
/**
* Creates a Pet.
*
* @param {number} id
* @param {string} name
* @param {string} tag
*/
constructor(id: number, name: string, tag: string) {
this.id = id;
this.name = name;
this.tag = tag;
}
}
env: node\r: No such file or directory
error Command failed with exit code 127.
seems like there's a fix
https://stackoverflow.com/questions/30344858/node-script-executable-not-working-on-mac-env-node-r-no-such-file-or-directo
brew install dos2unix
dos2unix ./node_modules/@progresso/openapi-typescript-client-api-generator/bin/generator
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.