-
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.
✨ Add vehicles, species, and planets
Adds remaining core resources.
- Loading branch information
Showing
5 changed files
with
208 additions
and
1 deletion.
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,66 @@ | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
|
||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
|
||
namespace SWAPI; | ||
|
||
@route("/planets") | ||
namespace planets { | ||
/** | ||
* Get all the planet resources. | ||
* | ||
* @param search Case-insensitive partial match on the `name` field. | ||
*/ | ||
op list(search: string): Planet[]; | ||
|
||
@route("/{planetId}") | ||
namespace planet { | ||
/** | ||
* Get a specific planet resource. | ||
* | ||
* @param planetId Numeric ID of the planet to get. | ||
*/ | ||
op read(@path planetId: int32): Planet; | ||
} | ||
} | ||
|
||
/** A Planet resource is a large mass, planet or planetoid in the Star Wars Universe, at the time of 0 ABY. */ | ||
model Planet { | ||
/** The name of this planet. */ | ||
name: string; | ||
|
||
/** The diameter of this planet in kilometers. */ | ||
diameter: string; | ||
|
||
/** The number of standard hours it takes for this planet to complete a single rotation on its axis. */ | ||
rotation_period: string; | ||
|
||
/** The number of standard days it takes for this planet to complete a single orbit of its local star. */ | ||
orbital_period: string; | ||
|
||
/** A number denoting the gravity of this planet, where "1" is normal or 1 standard G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. */ | ||
gravity: string; | ||
|
||
/** The average population of sentient beings inhabiting this planet. */ | ||
population: string; | ||
|
||
/** The climate of this planet. Comma separated if diverse. */ | ||
climate: string; | ||
|
||
/** The terrain of this planet. Comma separated if diverse. */ | ||
terrain: string; | ||
|
||
/** The percentage of the planet surface that is naturally occurring water or bodies of water. */ | ||
surface_water: 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; | ||
} |
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,66 @@ | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
|
||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
|
||
namespace SWAPI; | ||
|
||
@route("/species") | ||
namespace species { | ||
/** | ||
* Get all the species resources. | ||
* | ||
* @param search Case-insensitive partial match on the `name` field. | ||
*/ | ||
op list(search: string): Species[]; | ||
|
||
@route("/{speciesId}") | ||
namespace species { | ||
/** | ||
* Get a specific species resource. | ||
* | ||
* @param speciesId Numeric ID of the species to get. | ||
*/ | ||
op read(@path speciesId: int32): Species; | ||
} | ||
} | ||
|
||
/** A Species resource is a type of person or character within the Star Wars Universe. */ | ||
model Species { | ||
/** The name of this species. */ | ||
name: string; | ||
|
||
/** The classification of this species, such as "mammal" or "reptile". */ | ||
classification: string; | ||
|
||
/** The designation of this species, such as "sentient". */ | ||
designation: string; | ||
|
||
/** The average height of this species in centimeters. */ | ||
average_height: string; | ||
|
||
/** The average lifespan of this species in years. */ | ||
average_lifespan: string; | ||
|
||
/** A comma-separated string of common eye colors for this species, "none" if this species does not typically have eyes. */ | ||
eye_colors: string; | ||
|
||
/** A comma-separated string of common hair colors for this species, "none" if this species does not typically have hair. */ | ||
hair_colors: string; | ||
|
||
/** A comma-separated string of common skin colors for this species, "none" if this species does not typically have skin. */ | ||
skin_colors: string; | ||
|
||
/** The language commonly spoken by this species. */ | ||
language: 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; | ||
} |
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,72 @@ | ||
import "@typespec/http"; | ||
import "@typespec/rest"; | ||
|
||
using TypeSpec.Http; | ||
using TypeSpec.Rest; | ||
|
||
namespace SWAPI; | ||
|
||
@route("/vehicles") | ||
namespace vehicles { | ||
/** | ||
* Get all the vehicle resources. | ||
* | ||
* @param search Case-insensitive partial match on the `name` and `model` fields. | ||
*/ | ||
op list(search: string): Vehicle[]; | ||
|
||
@route("/{vehicleId}") | ||
namespace vehicle { | ||
/** | ||
* Get a specific vehicle resource. | ||
* | ||
* @param vehicleId Numeric ID of the vehicle to get. | ||
*/ | ||
op read(@path vehicleId: int32): Vehicle; | ||
} | ||
} | ||
|
||
/** A Vehicle resource is a single transport craft that **does not have** hyperdrive capability. */ | ||
model Vehicle { | ||
/** The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder bike". */ | ||
name: string; | ||
|
||
/** The model or official name of this vehicle. Such as "All-Terrain Attack Transport". */ | ||
`model`: string; | ||
|
||
/** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ | ||
vehicle_class: string; | ||
|
||
/** The manufacturer of this vehicle. Comma separated if more than one. */ | ||
manufacturer: string; | ||
|
||
/** The length of this vehicle in meters. */ | ||
length: string; | ||
|
||
/** The cost of this vehicle new, in Galactic Credits. */ | ||
cost_in_credits: string; | ||
|
||
/** The number of personnel needed to run or pilot this vehicle. */ | ||
crew: string; | ||
|
||
/** The number of non-essential people this vehicle can transport. */ | ||
passengers: string; | ||
|
||
/** The maximum speed of this vehicle in the atmosphere. */ | ||
max_atmosphering_speed: string; | ||
|
||
/** The maximum number of kilograms that this vehicle can transport. */ | ||
cargo_capacity: string; | ||
|
||
/** The maximum length of time that this vehicle 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; | ||
} |