Skip to content

Commit

Permalink
✨ Root resource and OpenAPI emit
Browse files Browse the repository at this point in the history
Adds the `Root` resource. Installs http, rest, and openapi TypeSpec
packages. Emits Open API document.
  • Loading branch information
connorjs committed Sep 9, 2023
1 parent 1aa8f3d commit 6f40a82
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
node_modules/
28 changes: 26 additions & 2 deletions main.tsp
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
@service
namespace SWAPI;
import "@typespec/http";
import "@typespec/rest";

using TypeSpec.Http;
using TypeSpec.Rest;

@service({
title: "SWAPI: The Star Wars API",
version: "v1",
})
@server("https://swapi.dev/api/", "SWAPI server")
namespace SWAPI {
@route("/")
@get
op root(): Root;

// https://swapi.dev/documentation#root
model Root {
films: string;
people: string;
planets: string;
species: string;
starships: string;
vehicles: string;
}
}
76 changes: 75 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
"type": "module",
"scripts": {
"build": "tsp compile .",
"format": "prettier -l '**/*.{json,md,tsp}'",
"format": "prettier -l '**/*.{json,md,tsp,yaml}'",
"format:fix": "npm run format -- -w",
"prepare": "is-ci || husky install",
"release": "npm run build && npm run format"
},
"lint-staged": {
"**/*.{json,md,tsp}": "prettier -w"
"**/*.{json,md,tsp,yaml}": "prettier -w"
},
"devDependencies": {
"@typespec/compiler": "~0.47.1",
"@typespec/prettier-plugin-typespec": "^0.47.0",
"@typespec/http": "~0.47.0",
"@typespec/openapi3": "~0.47.0",
"@typespec/prettier-plugin-typespec": "~0.47.0",
"@typespec/rest": "~0.47.0",
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"lint-staged": "^14.0.1",
Expand Down
7 changes: 7 additions & 0 deletions tspconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
emit:
- "@typespec/openapi3"
options:
"@typespec/openapi3":
emitter-output-dir: "{project-root}/dist"
omit-unreachable-types: true
output-file: "swapi.openapi.yaml"

0 comments on commit 6f40a82

Please sign in to comment.