Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.9 KB

README.md

File metadata and controls

53 lines (41 loc) · 1.9 KB

Rails API <=> TypeSpec <=> TypeScript Client

This is a sample project to demonstrate an end-to-end API service implementation that relies on a shared TypeSpec specification.

Components

The project consists of 3 components:

  • API Spec -- The main specification that defines types for both the server application and supports auto-generation of typed clients in any language that supports using the OpenAPI specification. More details can be found in that project's README.

  • Server -- A simple Rails API-only application that exposes endpoints for managing blog posts. It uses the generated OpenAPI spec along with the committee middleware to validate incoming requests and, in non-production environments, outgoing responses to ensure they conform to the spec. See the README for details.

  • Client -- Contains a TypeScript API client that is generated from the published spec (using swagger-typescript-api) and can interact with the server via a commandline interface. See the README to get this set up.

Running the Application

At a high-level, you can initialize the server and start it on the default port:

cd server && bin/setup && rails s

Once that is running, you can jump into the client directory to run the commandline tooling:

cd client && yarn && yarn cli --help