Coder Social home page Coder Social logo

lantianyou / openapi-client-axios Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openapistack/openapi-client-axios

1.0 0.0 0.0 1.96 MB

JavaScript client library for consuming OpenAPI-enabled APIs with axios

Home Page: https://www.npmjs.com/package/openapi-client-axios

License: MIT License

JavaScript 1.33% TypeScript 98.67%

openapi-client-axios's Introduction

openapi-client-axios

CI npm version npm downloads bundle size Total alerts Language grade: JavaScript License Buy me a coffee

JavaScript client library for consuming OpenAPI-enabled APIs with axios. Types included.

Features

  • Create API clients from OpenAPI v3 definitions
  • Client is configured in runtime. No generated code!
  • Generate TypeScript definitions (.d.ts) for your APIs with full IntelliSense support
  • Easy to use API to call API operations using JavaScript methods
    • client.getPet(1)
    • client.searchPets()
    • client.searchPets({ ids: [1, 2, 3] })
    • client.updatePet(1, payload)
  • Built on top of the robust axios JavaScript library
  • Isomorphic, works both in browser and Node.js

Documentation

See full README.md

See DOCS.md

Quick Start

npm install --save axios openapi-client-axios
yarn add axios openapi-client-axios

With promises / CommonJS syntax:

const OpenAPIClientAxios = require('openapi-client-axios').default;

const api = new OpenAPIClientAxios({ definition: 'https://example.com/api/openapi.json' });
api.init()
  .then(client => client.getPetById(1))
  .then(res => console.log('Here is pet id:1 from the api', res.data));

With async-await / ES6 syntax:

import OpenAPIClientAxios from 'openapi-client-axios';

const api = new OpenAPIClientAxios({ definition: 'https://example.com/api/openapi.json' });
api.init();

async function createPet() {
  const client = await api.getClient();
  const res = await client.createPet(null, { name: 'Garfield' });
  console.log('Pet created', res.data);
}

openapi-client-axios's People

Contributors

anttiviljami avatar dankeroni avatar dannyhaak avatar davidnewcomb avatar dependabot[bot] avatar dremendes avatar genehack avatar gfortaine avatar gterral avatar henrycunh avatar jeongy-cho avatar jfpimentel avatar lmarvaud avatar mdwheele avatar npdev453 avatar nponeccop avatar rowrowrowrow avatar sunkan avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.