Skip to content

Commit

Permalink
✨ Add vehicles, species, and planets
Browse files Browse the repository at this point in the history
Adds remaining core resources.
  • Loading branch information
connorjs committed Sep 10, 2023
1 parent 5ac9a87 commit 1086476
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ import "./root.tsp";
import "./people.tsp";
import "./films.tsp";
import "./starships.tsp";
import "./vehicles.tsp";
import "./species.tsp";
import "./planets.tsp";
66 changes: 66 additions & 0 deletions src/planets.tsp
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;
}
66 changes: 66 additions & 0 deletions src/species.tsp
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;
}
2 changes: 1 addition & 1 deletion src/starships.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace starships {
/**
* Get all the starship resources.
*
* @param search Case-insensitive partial match on the `title` field.
* @param search Case-insensitive partial match on the `name` and `model` fields.
*/
op list(search: string): Starship[];

Expand Down
72 changes: 72 additions & 0 deletions src/vehicles.tsp
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;
}

0 comments on commit 1086476

Please sign in to comment.