From bc828fbde6ea30ee36d402e7ad2aeb16193e7483 Mon Sep 17 00:00:00 2001 From: Connor Sullivan Date: Sat, 9 Sep 2023 20:42:13 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9E=96=20Remove=20unused=20@typespec/rest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cleans up the TypeSpec files, which leads to the removal of the unused `@typespec/rest`. - Moves service definition to `main.tsp` - Alphabetizes (re-orders) the local imports - Removes duplicate `@typespec/http` imports (it only needs to import once, in `main.tsp`) - Update lock file with previous `package.json` changes --- CONTRIBUTING.md | 3 +++ package-lock.json | 7 ++++--- package.json | 1 - src/films.tsp | 4 ---- src/main.tsp | 19 +++++++++++++++---- src/people.tsp | 4 ---- src/planets.tsp | 4 ---- src/root.tsp | 9 --------- src/species.tsp | 4 ---- src/starships.tsp | 4 ---- src/vehicles.tsp | 4 ---- 11 files changed, 22 insertions(+), 41 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bbf044b..3ca4a4d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,6 +19,9 @@ Use `npm run` to list all available scripts. The `release` script executes a - 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. + - Use backticks to escape properties that are TypeSpec keywords. For example, ```typespec `model`: string; // Used in starships.tsp diff --git a/package-lock.json b/package-lock.json index 9163e06..ac4f42e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "swapi-typespec", - "version": "0.1.0", + "version": "1.0.0-alpha.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "swapi-typespec", - "version": "0.1.0", + "version": "1.0.0-alpha.0", + "license": "MIT", "devDependencies": { "@typespec/compiler": "~0.47.1", "@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", @@ -178,6 +178,7 @@ "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.47.0.tgz", "integrity": "sha512-sjxCY2dQ6Wc51W7NYDLgcZdeTI35vFJR0aK+tuYHMTwjhZJK20ezwb/c+RZQ8xyGIyX+vUj9yhTc7lBZGw4n1A==", "dev": true, + "peer": true, "engines": { "node": ">=16.0.0" }, diff --git a/package.json b/package.json index 604e210..d79aa0c 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "@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", diff --git a/src/films.tsp b/src/films.tsp index 6cd6c65..088098a 100644 --- a/src/films.tsp +++ b/src/films.tsp @@ -1,8 +1,4 @@ -import "@typespec/http"; -import "@typespec/rest"; - using TypeSpec.Http; -using TypeSpec.Rest; namespace SWAPI; diff --git a/src/main.tsp b/src/main.tsp index a446df2..63bf3a2 100644 --- a/src/main.tsp +++ b/src/main.tsp @@ -1,7 +1,18 @@ -import "./root.tsp"; -import "./people.tsp"; +import "@typespec/http"; + import "./films.tsp"; +import "./people.tsp"; +import "./planets.tsp"; +import "./root.tsp"; +import "./species.tsp"; import "./starships.tsp"; import "./vehicles.tsp"; -import "./species.tsp"; -import "./planets.tsp"; + +using TypeSpec.Http; + +@service({ + title: "SWAPI: The Star Wars API", + version: "v1", +}) +@server("https://swapi.dev/api/", "SWAPI server") +namespace SWAPI; diff --git a/src/people.tsp b/src/people.tsp index 2f13982..05fc079 100644 --- a/src/people.tsp +++ b/src/people.tsp @@ -1,8 +1,4 @@ -import "@typespec/http"; -import "@typespec/rest"; - using TypeSpec.Http; -using TypeSpec.Rest; namespace SWAPI; diff --git a/src/planets.tsp b/src/planets.tsp index 5064ab1..6665203 100644 --- a/src/planets.tsp +++ b/src/planets.tsp @@ -1,8 +1,4 @@ -import "@typespec/http"; -import "@typespec/rest"; - using TypeSpec.Http; -using TypeSpec.Rest; namespace SWAPI; diff --git a/src/root.tsp b/src/root.tsp index 7fc76bc..ea115f0 100644 --- a/src/root.tsp +++ b/src/root.tsp @@ -1,14 +1,5 @@ -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; /** Gets the `Root` resource. */ diff --git a/src/species.tsp b/src/species.tsp index 8292612..5c4cb98 100644 --- a/src/species.tsp +++ b/src/species.tsp @@ -1,8 +1,4 @@ -import "@typespec/http"; -import "@typespec/rest"; - using TypeSpec.Http; -using TypeSpec.Rest; namespace SWAPI; diff --git a/src/starships.tsp b/src/starships.tsp index fde1041..d12cfa1 100644 --- a/src/starships.tsp +++ b/src/starships.tsp @@ -1,8 +1,4 @@ -import "@typespec/http"; -import "@typespec/rest"; - using TypeSpec.Http; -using TypeSpec.Rest; namespace SWAPI; diff --git a/src/vehicles.tsp b/src/vehicles.tsp index 1add7fc..576a12e 100644 --- a/src/vehicles.tsp +++ b/src/vehicles.tsp @@ -1,8 +1,4 @@ -import "@typespec/http"; -import "@typespec/rest"; - using TypeSpec.Http; -using TypeSpec.Rest; namespace SWAPI;