Skip to content

TypeSpec + Rails + TypeScript - end-to-end typed OpenAPI implementation

Notifications You must be signed in to change notification settings

reagent/blog-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e1425dd · Mar 12, 2024

History

9 Commits
Feb 29, 2024
Mar 12, 2024
Feb 29, 2024
Feb 29, 2024

Repository files navigation

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

About

TypeSpec + Rails + TypeScript - end-to-end typed OpenAPI implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published