Skip to content

Commit

Permalink
➖ Remove unused @typespec/rest
Browse files Browse the repository at this point in the history
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
  • Loading branch information
connorjs committed Sep 10, 2023
1 parent 1086476 commit bc828fb
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 41 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions src/films.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import "@typespec/http";
import "@typespec/rest";

using TypeSpec.Http;
using TypeSpec.Rest;

namespace SWAPI;

Expand Down
19 changes: 15 additions & 4 deletions src/main.tsp
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 0 additions & 4 deletions src/people.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import "@typespec/http";
import "@typespec/rest";

using TypeSpec.Http;
using TypeSpec.Rest;

namespace SWAPI;

Expand Down
4 changes: 0 additions & 4 deletions src/planets.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import "@typespec/http";
import "@typespec/rest";

using TypeSpec.Http;
using TypeSpec.Rest;

namespace SWAPI;

Expand Down
9 changes: 0 additions & 9 deletions src/root.tsp
Original file line number Diff line number Diff line change
@@ -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. */
Expand Down
4 changes: 0 additions & 4 deletions src/species.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import "@typespec/http";
import "@typespec/rest";

using TypeSpec.Http;
using TypeSpec.Rest;

namespace SWAPI;

Expand Down
4 changes: 0 additions & 4 deletions src/starships.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import "@typespec/http";
import "@typespec/rest";

using TypeSpec.Http;
using TypeSpec.Rest;

namespace SWAPI;

Expand Down
4 changes: 0 additions & 4 deletions src/vehicles.tsp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import "@typespec/http";
import "@typespec/rest";

using TypeSpec.Http;
using TypeSpec.Rest;

namespace SWAPI;

Expand Down

0 comments on commit bc828fb

Please sign in to comment.