Skip to content

Commit 9787ee3

Browse files
committed
Finish server implementation, update samples
1 parent bf32cbf commit 9787ee3

File tree

9 files changed

+185
-170
lines changed

9 files changed

+185
-170
lines changed

main.tsp

+3-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import "@typespec/rest";
33
import "@typespec/openapi3";
44
import "@typespec/openapi";
55
import "@typespec/json-schema";
6-
76
using Http;
87
using JsonSchema;
98

@@ -112,21 +111,15 @@ model TodoUrlAttachment {
112111

113112
@jsonSchema
114113
model TodoFileAttachment {
115-
/** The todo item this is attached to */
116-
@visibility("read") todoItemId: TodoItem.id;
117-
118114
/** The file name of the attachment */
119115
@maxLength(255)
120116
filename: string;
121117

122118
/** The media type of the attachment */
123119
mediaType: string;
124120

125-
/** The url where the attachment can be downloaded from */
126-
@visibility("read") url: url;
127-
128121
/** The contents of the file */
129-
@visibility("create") contents: bytes;
122+
contents: bytes;
130123
}
131124

132125
@jsonSchema
@@ -193,12 +186,6 @@ namespace Users {
193186
op create(
194187
@body user: User,
195188
): WithStandardErrors<UserCreatedResponse | UserExistsResponse | InvalidUserResponse>;
196-
197-
@route("validate")
198-
@get
199-
op validate(
200-
@query token: string,
201-
): WithStandardErrors<NoContentResponse | InvalidUserResponse>;
202189
}
203190

204191
@route("items")
@@ -278,12 +265,9 @@ namespace TodoItems {
278265

279266
@sharedRoute
280267
@post
281-
op createUrlAttachment(
282-
@header contentType: "application/json",
268+
op createAttachment(
283269
@path itemId: TodoItem.id,
284-
contents: TodoAttachment,
270+
@body contents: TodoAttachment,
285271
): WithStandardErrors<NoContentResponse | NotFoundResponse>;
286-
287-
@delete op delete(@path itemId: TodoItem.id): OkResponse | NotFoundResponse;
288272
}
289273
}

package-lock.json

+73-70
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
"@fastify/multipart": "^8.1.0",
1515
"@fastify/swagger": "^8.14.0",
1616
"@scalar/fastify-api-reference": "^1.17.6",
17+
"@types/json-merge-patch": "^0.0.10",
1718
"@typespec/compiler": "latest",
1819
"@typespec/http": "latest",
1920
"@typespec/json-schema": "latest",
2021
"@typespec/openapi": "latest",
2122
"@typespec/openapi3": "latest",
2223
"@typespec/rest": "latest",
2324
"fastify": "^4.26.1",
24-
"fastify-openapi-glue": "^4.4.3"
25+
"fastify-openapi-glue": "^4.4.3",
26+
"json-merge-patch": "^1.0.2"
2527
},
2628
"overrides": {
2729
"@azure-tools/typespec-client-generator-core": "0.40.0"

0 commit comments

Comments
 (0)