diff --git a/package-lock.json b/package-lock.json index ac4f42e..6a27eb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "devDependencies": { "@typespec/compiler": "~0.47.1", "@typespec/http": "~0.47.0", + "@typespec/openapi": "^0.47.0", "@typespec/openapi3": "~0.47.0", "@typespec/prettier-plugin-typespec": "~0.47.0", "husky": "^8.0.3", @@ -135,7 +136,6 @@ "resolved": "https://registry.npmjs.org/@typespec/openapi/-/openapi-0.47.0.tgz", "integrity": "sha512-p10NA5MQ1/z/yltTmK9g/RHgRQa+UPJg7ntcix8I9DIwX6u3yJReYwWBrKLeRNExd8ylNHNqjXTwiHJfptmR3w==", "dev": true, - "peer": true, "engines": { "node": ">=16.0.0" }, diff --git a/package.json b/package.json index d79aa0c..508fca3 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "devDependencies": { "@typespec/compiler": "~0.47.1", "@typespec/http": "~0.47.0", + "@typespec/openapi": "^0.47.0", "@typespec/openapi3": "~0.47.0", "@typespec/prettier-plugin-typespec": "~0.47.0", "husky": "^8.0.3", diff --git a/src/films.tsp b/src/films.tsp index d5a8f03..4547eb3 100644 --- a/src/films.tsp +++ b/src/films.tsp @@ -9,6 +9,7 @@ namespace films { * * @param search Case-insensitive partial match on the `title` field. */ + @OpenAPI.operationId("ListFilms") op list(search: string): Film[]; @route("/{filmId}") @@ -18,6 +19,7 @@ namespace films { * * @param filmId Numeric ID of the film to get. */ + @OpenAPI.operationId("GetFilm") op read(@path filmId: int32): Film; } } diff --git a/src/main.tsp b/src/main.tsp index 63bf3a2..819c96d 100644 --- a/src/main.tsp +++ b/src/main.tsp @@ -1,4 +1,5 @@ import "@typespec/http"; +import "@typespec/openapi"; import "./films.tsp"; import "./people.tsp"; diff --git a/src/people.tsp b/src/people.tsp index d03da9b..7acfd16 100644 --- a/src/people.tsp +++ b/src/people.tsp @@ -9,6 +9,7 @@ namespace people { * * @param search Case-insensitive partial match on the `name` field. */ + @OpenAPI.operationId("ListPerson") op list(search: string): Person[]; @route("/{personId}") @@ -18,6 +19,7 @@ namespace people { * * @param personId Numeric ID of the person to get. */ + @OpenAPI.operationId("GetPerson") op read(@path personId: int32): Person; } } diff --git a/src/planets.tsp b/src/planets.tsp index ad73de9..8828509 100644 --- a/src/planets.tsp +++ b/src/planets.tsp @@ -9,6 +9,7 @@ namespace planets { * * @param search Case-insensitive partial match on the `name` field. */ + @OpenAPI.operationId("ListPlanet") op list(search: string): Planet[]; @route("/{planetId}") @@ -18,6 +19,7 @@ namespace planets { * * @param planetId Numeric ID of the planet to get. */ + @OpenAPI.operationId("GetPlanet") op read(@path planetId: int32): Planet; } } diff --git a/src/root.tsp b/src/root.tsp index 821725b..fe7744b 100644 --- a/src/root.tsp +++ b/src/root.tsp @@ -4,8 +4,10 @@ namespace SWAPI; /** Gets the `Root` resource. */ @route("/") -@get -op root(): Root; +namespace root { + @OpenAPI.operationId("GetRoot") + op read(): Root; +} /** * The Root resource provides information on all available resources within the diff --git a/src/species.tsp b/src/species.tsp index 863bc55..4d06107 100644 --- a/src/species.tsp +++ b/src/species.tsp @@ -9,6 +9,7 @@ namespace species { * * @param search Case-insensitive partial match on the `name` field. */ + @OpenAPI.operationId("ListSpecies") op list(search: string): Species[]; @route("/{speciesId}") @@ -18,6 +19,7 @@ namespace species { * * @param speciesId Numeric ID of the species to get. */ + @OpenAPI.operationId("GetSpecies") op read(@path speciesId: int32): Species; } } diff --git a/src/starships.tsp b/src/starships.tsp index bc2901e..0fe8f77 100644 --- a/src/starships.tsp +++ b/src/starships.tsp @@ -9,6 +9,7 @@ namespace starships { * * @param search Case-insensitive partial match on the `name` and `model` fields. */ + @OpenAPI.operationId("ListStarships") op list(search: string): Starship[]; @route("/{starshipId}") @@ -18,6 +19,7 @@ namespace starships { * * @param starshipId Numeric ID of the starship to get. */ + @OpenAPI.operationId("GetStarship") op read(@path starshipId: int32): Starship; } } diff --git a/src/vehicles.tsp b/src/vehicles.tsp index a99f156..b517343 100644 --- a/src/vehicles.tsp +++ b/src/vehicles.tsp @@ -9,6 +9,7 @@ namespace vehicles { * * @param search Case-insensitive partial match on the `name` and `model` fields. */ + @OpenAPI.operationId("ListVehicles") op list(search: string): Vehicle[]; @route("/{vehicleId}") @@ -18,6 +19,7 @@ namespace vehicles { * * @param vehicleId Numeric ID of the vehicle to get. */ + @OpenAPI.operationId("GetVehicle") op read(@path vehicleId: int32): Vehicle; } }