Skip to content

Commit 705248e

Browse files
http-specs, add smoke test (#7529)
replace #6981 fix #5927 Timothee recommended putting them into "packages/http-specs/smoke" folder.
1 parent a6beab2 commit 705248e

File tree

5 files changed

+402
-1
lines changed

5 files changed

+402
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: feature
3+
packages:
4+
- "@typespec/http-specs"
5+
---
6+
7+
Add smoke tests

packages/http-specs/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "module",
77
"scripts": {
88
"watch": "tsc -p ./tsconfig.build.json --watch",
9-
"build": "tsc -p ./tsconfig.build.json && pnpm validate-scenarios",
9+
"build": "tsc -p ./tsconfig.build.json && pnpm validate-scenarios && pnpm build:smoke",
1010
"clean": "rimraf dist/ temp/",
1111
"test:e2e": "pnpm validate-mock-apis && pnpm validate-client-server",
1212
"validate:all": "pnpm build && pnpm regen-docs && pnpm test:e2e",
@@ -19,6 +19,7 @@
1919
"validate-mock-apis": "tsp-spector validate-mock-apis ./specs",
2020
"check-scenario-coverage": "tsp-spector check-coverage ./specs",
2121
"validate-client-server": "concurrently \"tsp-spector server start ./specs\" \"pnpm knock\"; tsp-spector server stop",
22+
"build:smoke": "tsp compile smoke/petstore --warn-as-error --no-emit && tsp compile smoke/todoapp --warn-as-error --no-emit",
2223
"client": "pnpm knock",
2324
"knock": "tsp-spector knock ./specs",
2425
"serve": "tsp-spector serve ./specs",
@@ -48,6 +49,7 @@
4849
"@types/node": "~22.13.11",
4950
"@typespec/openapi": "workspace:^",
5051
"@typespec/openapi3": "workspace:^",
52+
"@typespec/json-schema": "workspace:^",
5153
"concurrently": "^9.1.2",
5254
"rimraf": "~6.0.1",
5355
"typescript": "~5.8.2"
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import "@typespec/rest";
2+
import "@typespec/openapi";
3+
4+
@service(#{ title: "Pet Store Service" })
5+
namespace PetStore;
6+
7+
using TypeSpec.Http;
8+
using TypeSpec.Rest;
9+
using TypeSpec.Rest.Resource;
10+
11+
@error
12+
model PetStoreError {
13+
code: int32;
14+
message: string;
15+
}
16+
17+
@resource("pets")
18+
model Pet {
19+
@key("petId")
20+
id: int32;
21+
22+
name: string;
23+
tag?: string;
24+
25+
@minValue(0)
26+
@maxValue(20)
27+
age: int32;
28+
29+
ownerId: int64;
30+
}
31+
32+
@resource("toys")
33+
@parentResource(Pet)
34+
model Toy {
35+
@key("toyId")
36+
id: int64;
37+
38+
petId: int64;
39+
name: string;
40+
}
41+
42+
@resource("owners")
43+
model Owner {
44+
@key("ownerId")
45+
id: int64;
46+
47+
name: string;
48+
age: int32;
49+
}
50+
51+
@resource("checkups")
52+
model Checkup {
53+
@key("checkupId")
54+
id: int32;
55+
56+
vetName: string;
57+
notes: string;
58+
}
59+
60+
@segment("insurance")
61+
model Insurance {
62+
provider: string;
63+
premium: int32;
64+
deductible: int32;
65+
}
66+
67+
interface Pets extends ResourceOperations<Pet, PetStoreError> {}
68+
69+
interface PetCheckups
70+
extends ExtensionResourceCreateOrUpdate<Checkup, Pet, PetStoreError>,
71+
ExtensionResourceList<Checkup, Pet, PetStoreError> {}
72+
73+
interface PetInsurance extends SingletonResourceOperations<Insurance, Pet, PetStoreError> {}
74+
75+
interface Toys extends ResourceRead<Toy, PetStoreError> {
76+
@autoRoute
77+
@listsResource(Toy)
78+
list(
79+
...ParentKeysOf<Toy>,
80+
@query nameFilter: string,
81+
): CollectionWithNextLink<Toy> | PetStoreError;
82+
}
83+
84+
interface ToyInsurance extends SingletonResourceOperations<Insurance, Toy, PetStoreError> {}
85+
86+
interface Checkups
87+
extends ResourceCreateOrUpdate<Checkup, PetStoreError>,
88+
ResourceList<Checkup, PetStoreError> {}
89+
90+
interface Owners extends ResourceOperations<Owner, PetStoreError> {}
91+
92+
interface OwnerCheckups
93+
extends ExtensionResourceCreateOrUpdate<Checkup, Owner, PetStoreError>,
94+
ExtensionResourceList<Checkup, Owner, PetStoreError> {}
95+
96+
interface OwnerInsurance extends SingletonResourceOperations<Insurance, Owner, PetStoreError> {}

0 commit comments

Comments
 (0)