This repo demonstrates the use of OpenAPI Spec and Swagger tools to build REST APIs, documentation, and generated SDKs. It was created to support my presentation on designing APIs with OpenAPI
The repo is broken into 4 sections.
/api A Sample API built with swagger-node. All the other sections require the API to be running.
/docs A documentation site using swagger-ui that runs off the OpenAPI spec on the sample API.
/codgen A Codegen example demonstrating how to build a TypeScript client SDK based on the sample API.
/ng-demo A sample Angular site that connects to our sample API via the codgen-built client SDK.
Contains a sample api generated by swagger-node.
[sudo] npm install -g swagger npm install api swagger project start api
To Start OpenAPI Doc Editor:
swagger project edit api
Contains a compiled version of the codegen cli, as well as a sample install script for generating a typescript client library for our lyrics api.
Note: You'll need to have the api running before building the client library, as it will fetch the swagger info from
Generate a TypeScript Library:
Contains an Angular demo app that uses the codegen generated client library to connect to our api.
Note: You'll need the api running.
[sudo npm install -g @angular/cli cd ng-demo npm install ng serve --open
Note: Need the api running!
npm install docs node docs/app.js
Then check out http://127.0.0.1:3006