@wajunworks/swagger-client
v20241002.0.1
Published
TS Swagger client generator
Downloads
142
Readme
About The Project
In modern software development, integrating and maintaining consistent communication between backend services and frontend/mobile applications is crucial. To streamline this process, our project introduces an innovative solution: an automated SDK generator designed specifically for backend teams. This tool leverages the power of Swagger (OpenAPI) specifications to generate NPM packages that serve as SDKs. These SDKs facilitate seamless integration for frontend and mobile teams, promoting efficiency and reducing manual coding efforts.
Key Features
Automated SDK Generation:
The core functionality of our project is to automatically generate a Node.js SDK during the CI/CD pipeline. By utilizing Swagger JSON specifications, the generator creates clean, lightweight, and maintainable code.
CI/CD Integration:
The generator integrates seamlessly with CI/CD pipelines, ensuring that SDKs are up-to-date with the latest API changes. This automation reduces the need for manual intervention and ensures consistency across development environments.
Multi-Platform Support:
The generated SDK is designed to be versatile, supporting usage in both frontend and mobile development environments. It is compatible with any project that uses Node.js, making it a robust solution for various development teams.
Clean and Lightweight Code:
The SDK generator emphasizes producing clean, readable, and efficient code. This focus ensures that the SDK is easy to integrate, extend, and maintain.
Built With
This section should list any major frameworks/libraries used to bootstrap your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.
Getting Started
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
Prerequisites
This is an example of how to list things you need to use the software and how to install them.
- npm
npm install npm@latest -g
Installation
Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services.
- create a swagger.ts
const generater = new SwaggerGenerator();
await generater
.setOpenApiSpecificationUrl(
"https://xxx.json"
)
.setName("MobileApi")
.buildAsync();
- run the swagger file
npx ts-node -O '{\"module\":\"commonjs\"}' test/Startup.ts
- then the client will locale in the project direcotry (/api)
Usage
the client will generate like
export class MobileApiClient {
get axios(): AxiosInstance;
get aIDiagnostic(): IAIDiagnosticClient;
}
you can use the client in your code like below, you should init the client instance in your framework recommand. like init the client as provider in react.js
const client = new MobileApiClient().
const data = await client.heallthrecord.bloodpressure.listAsync({});
For more examples, please refer to the Documentation
Roadmap
- [x] Generate Response Result
- [x] Support Request Path Parameter
- [x] Support Request Query Parameter
- [ ] Support Request Body Parameter
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Contact
Jack Wong - @j113203 - [email protected]
Project Link: https://github.com/j113203/swagger-client-generator
Acknowledgments
Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!