Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
# Prettier default
charset = utf-8
insert_final_newline = true
end_of_line = lf
max_line_length = 80
trim_trailing_whitespace = true

# Custom
# Use tabs: https://alexandersandberg.com/articles/default-to-tabs-instead-of-spaces-for-an-accessible-first-environment/
indent_style = tab

[*.{yaml,yml}]
# YAML disallows tabs: https://yaml.org/spec/
indent_size = 2
indent_style = space
16 changes: 8 additions & 8 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ name: CI Build

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version-file: .node-version
cache: npm

- name: Install
- name: Restore
run: npm ci

- name: Run release build targets
run: npm run release
- name: Build
run: npm run build && npm run format:check
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Build artifacts
node_modules/
swapi.openapi.yaml
swapi.openapi.yaml

# IDEs
.idea/
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
19 changes: 10 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@

### Run scripts

Use `npm run` to list all available scripts. The `release` script executes a
“release build.” The CI build uses this script.
Use `npm run` to list all available scripts.
See [ci-build.yml](.github/workflows/ci-build.yml) for details on the CI build.

### Directory structure

- [src](./src) contains the TypeSpec (`.tsp`) files

## TypeSpec conventions

- Separate files by type. Name files using the plural form, which SWAPI uses
in its documentation.
- Separate files by type.
Name files using the plural form, which SWAPI uses in its documentation.

- Using `@resource` adds _all_ REST operations. Thus, the spec files explicitly
configure `list` and `read` operations because SWAPI only supports those.
- Using `@resource` adds _all_ REST operations.
Thus, the spec files explicitly configure `list` and `read` operations because SWAPI only supports those.

As a result, this project does not use `@typespec/rest` at all. Instead, it
only needs `@typespec/http` for the API definitions.
As a result, this project does not use `@typespec/rest` at all.
Instead, it only needs `@typespec/http` for the API definitions.

- Use backticks to escape properties that are TypeSpec keywords. For example,
- Use backticks to escape properties that are TypeSpec keywords.
For example,
```typespec
`model`: string; // Used in starships.tsp
```
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Connor Sullivan
Copyright (c) 2023,2025 Connor Sullivan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[TypeSpec][typespec] representation of [SWAPI: The Star Wars API][swapi].

[swapi]: https://swapi.dev
[typespec]: https://microsoft.github.io/typespec/

<!-- Badges: Use link shorthand for readability and easier reordering -->

[![CI Build][ci-build-badge]][ci-build]
Expand All @@ -26,7 +29,7 @@ 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
## Installation

Follow these steps to consume the generated Open API specification for SWAPI.

Expand All @@ -42,5 +45,6 @@ Follow these steps to consume the generated Open API specification for SWAPI.
./node_modules/swapi-typespec/swapi.openapi.yaml
```

[swapi]: https://swapi.dev
[typespec]: https://microsoft.github.io/typespec/
## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
Loading
Loading