https://github.com/connorjs/swapi-typespec
TypeSpec representation of SWAPI: The Star Wars API.
https://github.com/connorjs/swapi-typespec
api openapi openapi3 starwars swagger swapi typespec
Last synced: about 1 month ago
JSON representation
TypeSpec representation of SWAPI: The Star Wars API.
- Host: GitHub
- URL: https://github.com/connorjs/swapi-typespec
- Owner: connorjs
- License: mit
- Created: 2023-09-09T00:02:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-11T21:36:11.000Z (over 1 year ago)
- Last Synced: 2025-04-06T21:16:09.745Z (about 1 month ago)
- Topics: api, openapi, openapi3, starwars, swagger, swapi, typespec
- Language: JavaScript
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# SWAPI TypeSpec
[TypeSpec][typespec] representation of [SWAPI: The Star Wars API][swapi].
[![CI Build][ci-build-badge]][ci-build]
[![npm version][npm-version-badge]][npm-version][ci-build]: https://github.com/connorjs/swapi-typespec/actions/workflows/ci-build.yml
[ci-build-badge]: https://github.com/connorjs/swapi-typespec/actions/workflows/ci-build.yml/badge.svg
[npm-version]: https://www.npmjs.com/package/swapi-typespec
[npm-version-badge]: https://img.shields.io/npm/v/swapi-typespec## About
I created this project to learn about TypeSpec through first-hand usage.
The generated Open API 3 specification has 878 lines (with no blank lines) in a
single file. The TypeSpec source has 493 lines (about ⅓ are blank lines for
readability) split across 8 files for logical organization, which is a ~45%
reduction in lines of code.If we ignore the imports, using statements, and blank lines within models, then
the TypeSpec only has 353 lines. That means a 60% reduction in code to maintain.## Getting started
Follow these steps to consume the generated Open API specification for SWAPI.
1. Install this package as a dependency.
```sh
npm install -D swapi-typespec
```2. Reference the generated Open API specification directly.
```sh
./node_modules/swapi-typespec/swapi.openapi.yaml
```[swapi]: https://swapi.dev
[typespec]: https://microsoft.github.io/typespec/