-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds `Film` and `Starship` models and their operations.
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
|
||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
|
||
namespace SWAPI; | ||
|
||
@route("/films") | ||
namespace films { | ||
/** | ||
* Get all the film resources. | ||
* | ||
* @param search Case-insensitive partial match on the `title` field. | ||
*/ | ||
op list(search: string): Film[]; | ||
|
||
@route("/{filmId}") | ||
namespace film { | ||
/** | ||
* Get a specific film resource. | ||
* | ||
* @param filmId Numeric ID of the film to get. | ||
*/ | ||
op read(@path filmId: int32): Film; | ||
} | ||
} | ||
|
||
/** A Film resource is a single film. */ | ||
model Film { | ||
/** The title of this film */ | ||
title: string; | ||
|
||
/** The episode number of this film. */ | ||
episode_id: integer; | ||
|
||
/** The opening paragraphs at the beginning of this film. */ | ||
opening_crawl: string; | ||
|
||
/** The name of the director of this film. */ | ||
director: string; | ||
|
||
/** The name(s) of the producer(s) of this film. Comma separated. */ | ||
producer: string; | ||
|
||
/** The ISO 8601 date format of film release at original creator country. */ | ||
release_date: plainDate; | ||
|
||
/** The hypermedia URL of this resource. */ | ||
url: string; | ||
|
||
/** The ISO 8601 date format of the time that this resource was created. */ | ||
created: string; | ||
|
||
/** The ISO 8601 date format of the time that this resource was edited. */ | ||
edited: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
import "./root.tsp"; | ||
import "./people.tsp"; | ||
import "./films.tsp"; | ||
import "./starships.tsp"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
|
||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
|
||
namespace SWAPI; | ||
|
||
@route("/starships") | ||
namespace starships { | ||
/** | ||
* Get all the starship resources. | ||
* | ||
* @param search Case-insensitive partial match on the `title` field. | ||
*/ | ||
op list(search: string): Starship[]; | ||
|
||
@route("/{starshipId}") | ||
namespace starship { | ||
/** | ||
* Get a specific starship resource. | ||
* | ||
* @param starshipId Numeric ID of the starship to get. | ||
*/ | ||
op read(@path starshipId: int32): Starship; | ||
} | ||
} | ||
|
||
/** A Starship resource is a single transport craft that has hyperdrive capability. */ | ||
model Starship { | ||
/** The name of this starship. The common name, such as "Death Star". */ | ||
name: string; | ||
|
||
/** The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 Orbital Battle Station". */ | ||
`model`: string; | ||
|
||
/** The class of this starship, such as "Starfighter" or "Deep Space Mobile Battlestation" */ | ||
starship_class: string; | ||
|
||
/** The manufacturer of this starship. Comma separated if more than one. */ | ||
manufacturer: string; | ||
|
||
/** The cost of this starship new, in galactic credits. */ | ||
cost_in_credits: string; | ||
|
||
/** The length of this starship in meters. */ | ||
length: string; | ||
|
||
/** The number of personnel needed to run or pilot this starship. */ | ||
crew: string; | ||
|
||
/** The number of non-essential people this starship can transport. */ | ||
passengers: string; | ||
|
||
/** The maximum speed of this starship in the atmosphere. "N/A" if this starship is incapable of atmospheric flight. */ | ||
max_atmosphering_speed: string; | ||
|
||
/** The class of this starships hyperdrive. */ | ||
hyperdrive_rating: string; | ||
|
||
/** The Maximum number of Megalights this starship can travel in a standard hour. A "Megalight" is a standard unit of distance and has never been defined before within the Star Wars universe. This figure is only really useful for measuring the difference in speed of starships. We can assume it is similar to AU, the distance between our Sun (Sol) and Earth. */ | ||
MGLT: string; | ||
|
||
/** The maximum number of kilograms that this starship can transport. */ | ||
cargo_capacity: string; | ||
|
||
/** The maximum length of time that this starship can provide consumables for its entire crew without having to resupply. */ | ||
consumables: string; | ||
|
||
/** The hypermedia URL of this resource. */ | ||
url: string; | ||
|
||
/** The ISO 8601 date format of the time that this resource was created. */ | ||
created: string; | ||
|
||
/** The ISO 8601 date format of the time that this resource was edited. */ | ||
edited: string; | ||
} |