Coder Social home page Coder Social logo

kubajastrz / openapi-generator-example Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 87 KB

Example usage of openapi-generator and msw

License: MIT License

Shell 1.35% HTML 1.05% CSS 2.80% TypeScript 68.22% JavaScript 26.58%
openapi generator typescript example openapi-generator react vite mock-service-worker

openapi-generator-example's Introduction

OpenAPI Generator Example

This is an example usage of openapi-generator with typescript-fetch generator.

Getting Started

Requirements:

  • node v12+
  • yarn v1
  • docker (for generating the api client)

Installation:

  1. Clone the repository
  2. Install dependencies
    yarn --frozen-lockfile
  3. Generate the API client
    yarn generate-api
  4. Run the application at http://localhost:3000
    yarn dev

Generating API client from schema

To (re-)generate the API client from schema, run:

yarn generate-api

It will read the schema.yml file in the working directory and pass it into the generator. It can be customized by passing the schema filename:

yarn generate-api custom-schema.yml

The generated output will be in the src/api/generated-api directory.

How it works

Generator Flow Diagram

OpenAPI Generator imports specified schema.yml file and generates the API classes in src/api/generated-api directory.

The application creates ready-for-use API client with helpers for authentication in src/api/index.ts.

Components import API client methods and make API calls.

API calls are intercepted in development environment with Mock Service Worker and optionally served with mocked data on demand. In production environment the interceptor is disabled removed from the application bundle.

openapi-generator-example's People

Contributors

kubajastrz avatar

Watchers

 avatar  avatar  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.