npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

api-di-connector

v1.1.0

Published

generate api from swagger

Downloads

14

Readme

API DI Connector

npm version

Description

The api-di-connector package provides the ability to generate connectors for working with your Swagger API. It supports Swagger version v3 and utilizes a restClient based on the Axios library.

Installation

npm i -D api-di-connector

Additional packages for production

npm i axios axios-retry

Example

npx api-di-connector

User Console Operations

√ Add Swagger Link: example.com/v3/api-docs
√ Project Language: js/ts

Details

This repository contains a service implementation with the following directory structure:

service
|-- ApiService
| |-- api
| | |-- ApiModule1Class1
| |-- ApiDiContainer
| |-- RestClient
| |-- interfaces (optional for TypeScript)
| |-- SwaggerSchemas

ApiService

The ApiService directory encompasses the core functionality of the service.

ApiDiContainer

The ApiDiContainer is a dependency injection container that consolidates all classes defined in the api directory. It serves as a centralized mechanism for managing dependencies within the service.

RestClient

The RestClient module defines the basic methods for interacting with the axios library, providing a foundation for making HTTP requests. It encapsulates common functionalities required for communication with external APIs.

TypeScript Interfaces (optional)

If TypeScript is chosen as the language, the interfaces directory contains TypeScript interfaces that represent the schemas defined in the Swagger documentation

Features

  • Generation of connectors for PATCH, POST, DELETE, GET requests based on Swagger specification v3.
  • Addition of query parameters, path parameters, and body for POST requests to the respective controllers.
  • Generation of annotations for controllers.
  • Use of Bearer authorization in request headers.

Usage

// Example usage of generated connectors
import ApiDiContainer from '@service/apiService/apiDiContainer';
ApiDiContainer.ProxyApiUser.getUsers().then((res) => {
  this.setState({ listOfUser: res.data });
});

Notes

  • Ensure that your Swagger API adheres to the Swagger v3 specification.
  • Before usage, make sure you have the Axios package installed.

License

This project is licensed under the ISC License.