Skip to content

Commit b4f1170

Browse files
mikeharderharryli0108
authored andcommitted
[TypeSpec] Upgrade @typespec/compiler to 0.45.1, re-enable format check in CI (Azure#24442)
- Includes fix for microsoft/typespec#2060 - Fixes Azure#24443
1 parent b0678ef commit b4f1170

File tree

4 files changed

+146
-121
lines changed

4 files changed

+146
-121
lines changed

eng/pipelines/templates/steps/typespec-ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ steps:
3333
fi
3434
3535
# Format parent folder to include shared files
36-
# Disabled until https://github.com/microsoft/typespec/issues/2060 is fixed
37-
# npx tsp format ../**/*.tsp
36+
npx tsp format ../**/*.tsp
3837
3938
popd
4039

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@azure-tools/typespec-azure-resource-manager": "0.31.0",
1313
"@azure-tools/typespec-client-generator-core": "0.31.0",
1414
"@azure-tools/typespec-providerhub": "0.31.0",
15-
"@typespec/compiler": "0.45.0",
15+
"@typespec/compiler": "0.45.1",
1616
"@typespec/http": "0.45.0",
1717
"@typespec/openapi": "0.45.0",
1818
"@typespec/rest": "0.45.0",

specification/eventgrid/Azure.Messaging.EventGrid/main.tsp

Lines changed: 140 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import "@typespec/rest";
33
import "@typespec/versioning";
44
import "@azure-tools/typespec-azure-core";
55

6-
@useAuth(
7-
ApiKeyAuth<ApiKeyLocation.header, "SharedAccessKey">
8-
)
9-
6+
@useAuth(ApiKeyAuth<ApiKeyLocation.header, "SharedAccessKey">)
107
@service({
118
title: "Azure.Messaging.EventGridClient",
129
})
@@ -19,8 +16,6 @@ import "@azure-tools/typespec-azure-core";
1916
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge?api-Version={apiVersion}
2017
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release?api-version={apiVersion}
2118
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject?api-version={apiVersion}
22-
23-
2419
@server(
2520
"{endpoint}",
2621
"The host name of the namespace",
@@ -29,7 +24,6 @@ import "@azure-tools/typespec-azure-core";
2924
endpoint: url,
3025
}
3126
)
32-
3327
@doc("Azure Messaging EventGrid Client")
3428
@versioned(ServiceApiVersions)
3529
namespace Azure.Messaging.EventGrid {
@@ -42,7 +36,7 @@ namespace Azure.Messaging.EventGrid {
4236
#suppress "@azure-tools/typespec-azure-core/documentation-required" "https://github.com/Azure/typespec-azure/issues/3107"
4337
enum ServiceApiVersions {
4438
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
45-
v2023_06_01_preview: "2023-06-01-preview"
39+
v2023_06_01_preview: "2023-06-01-preview",
4640
}
4741

4842
@doc("Properties of an event published to an Azure Messaging EventGrid Namespace topic using the CloudEvent 1.0 Schema.")
@@ -58,7 +52,7 @@ namespace Azure.Messaging.EventGrid {
5852

5953
@doc("Event data specific to the event type, encoded as a base64 string.")
6054
data_base64?: bytes;
61-
55+
6256
@doc("Type of event related to the originating occurrence.")
6357
type: string;
6458

@@ -101,7 +95,7 @@ namespace Azure.Messaging.EventGrid {
10195
@doc("Array of receive responses, one per cloud event.")
10296
value: ReceiveDetails[];
10397
}
104-
98+
10599
@doc("Failed LockToken information.")
106100
model FailedLockToken {
107101
@doc("LockToken value")
@@ -111,7 +105,7 @@ namespace Azure.Messaging.EventGrid {
111105
errorCode: string;
112106

113107
@doc("Description of the token error.")
114-
errorDescription: string;
108+
errorDescription: string;
115109
}
116110

117111
@doc("The result of the Publish operation.")
@@ -166,129 +160,161 @@ namespace Azure.Messaging.EventGrid {
166160
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}:publish?api-version={apiVersion}}
167161

168162
@doc("Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. ")
169-
@route("/topics/{topicName}:publish", {shared: true})
170-
@post op PublishCloudEvent is Azure.Core.RpcOperation<{
171-
@doc("content type")
172-
@header("content-type")
173-
contentType: "application/cloudevents+json; charset=utf-8";
174-
175-
@doc("Topic Name.")
176-
@path
177-
topicName: string;
178-
179-
@doc("Single Cloud Event being published.")
180-
@body
181-
event: CloudEvent;
182-
}, PublishResult>;
183-
184-
185-
@doc("Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. ")
186-
@route("/topics/{topicName}:publish", {shared: true})
187-
@post op PublishCloudEvents is Azure.Core.RpcOperation<{
188-
@doc("content type")
189-
@header("content-type")
190-
contentType: "application/cloudevents-batch+json; charset=utf-8";
191-
192-
@doc("Topic Name.")
193-
@path
194-
topicName: string;
195-
196-
@doc("Array of Cloud Events being published.")
197-
@body
198-
events: CloudEvent[];
199-
}, PublishResult>;
163+
@route(
164+
"/topics/{topicName}:publish",
165+
{
166+
shared: true,
167+
}
168+
)
169+
@post
170+
op PublishCloudEvent is Azure.Core.RpcOperation<
171+
{
172+
@doc("content type")
173+
@header("content-type")
174+
contentType: "application/cloudevents+json; charset=utf-8";
175+
176+
@doc("Topic Name.")
177+
@path
178+
topicName: string;
179+
180+
@doc("Single Cloud Event being published.")
181+
@body
182+
event: CloudEvent;
183+
},
184+
PublishResult
185+
>;
186+
187+
@doc("Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. ")
188+
@route(
189+
"/topics/{topicName}:publish",
190+
{
191+
shared: true,
192+
}
193+
)
194+
@post
195+
op PublishCloudEvents is Azure.Core.RpcOperation<
196+
{
197+
@doc("content type")
198+
@header("content-type")
199+
contentType: "application/cloudevents-batch+json; charset=utf-8";
200+
201+
@doc("Topic Name.")
202+
@path
203+
topicName: string;
204+
205+
@doc("Array of Cloud Events being published.")
206+
@body
207+
events: CloudEvent[];
208+
},
209+
PublishResult
210+
>;
200211

201212
// Receive Operation:
202213
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive?api-Version={apiVersion}&maxWaitTime=60&maxEvents={maxEvents}
203-
214+
204215
@doc("Receive Batch of Cloud Events from the Event Subscription.")
205216
@route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive")
206-
@post op ReceiveCloudEvents is Azure.Core.RpcOperation<{
207-
@doc("Topic Name.")
208-
@path
209-
topicName: string;
210-
211-
@doc("Event Subscription Name.")
212-
@path
213-
eventSubscriptionName: string;
214-
215-
@doc("Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1.")
216-
@query
217-
maxEvents?: int32 = 1;
218-
219-
@doc("Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds.")
220-
@encode("seconds", int32)
221-
@query
222-
maxWaitTime?: duration;
223-
}, ReceiveResult>;
217+
@post
218+
op ReceiveCloudEvents is Azure.Core.RpcOperation<
219+
{
220+
@doc("Topic Name.")
221+
@path
222+
topicName: string;
223+
224+
@doc("Event Subscription Name.")
225+
@path
226+
eventSubscriptionName: string;
227+
228+
@doc("Max Events count to be received. Minimum value is 1, while maximum value is 100 events. If not specified, the default value is 1.")
229+
@query
230+
maxEvents?: int32 = 1;
231+
232+
@doc("Max wait time value for receive operation in Seconds. It is the time in seconds that the server approximately waits for the availability of an event and responds to the request. If an event is available, the broker responds immediately to the client. Minimum value is 10 seconds, while maximum value is 120 seconds. If not specified, the default value is 60 seconds.")
233+
@encode("seconds", int32)
234+
@query
235+
maxWaitTime?: duration;
236+
},
237+
ReceiveResult
238+
>;
224239

225240
// Acknowledge Operation:
226241
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge&apiVersion={apiVersion}
227242

228243
@doc("Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully acknowledged. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.")
229-
230244
@route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge")
231-
@post op AcknowledgeCloudEvents is Azure.Core.RpcOperation<{
232-
@doc("content type")
233-
@header("content-type")
234-
contentType: "application/json; charset=utf-8";
235-
236-
@doc("Topic Name.")
237-
@path
238-
topicName: string;
239-
240-
@doc("Event Subscription Name.")
241-
@path
242-
eventSubscriptionName: string;
243-
244-
@doc("AcknowledgeOptions.")
245-
@body
246-
lockTokens: AcknowledgeOptions;
247-
}, AcknowledgeResult>;
245+
@post
246+
op AcknowledgeCloudEvents is Azure.Core.RpcOperation<
247+
{
248+
@doc("content type")
249+
@header("content-type")
250+
contentType: "application/json; charset=utf-8";
251+
252+
@doc("Topic Name.")
253+
@path
254+
topicName: string;
255+
256+
@doc("Event Subscription Name.")
257+
@path
258+
eventSubscriptionName: string;
259+
260+
@doc("AcknowledgeOptions.")
261+
@body
262+
lockTokens: AcknowledgeOptions;
263+
},
264+
AcknowledgeResult
265+
>;
248266

249267
// Release Operation:
250268
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release?api-version={apiVersion}
251-
269+
252270
@doc("Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully released. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information.")
253271
@route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release")
254-
@post op ReleaseCloudEvents is Azure.Core.RpcOperation<{
255-
@doc("content type")
256-
@header("content-type")
257-
contentType: "application/json; charset=utf-8";
258-
259-
@doc("Topic Name.")
260-
@path
261-
topicName: string;
262-
263-
@doc("Event Subscription Name.")
264-
@path
265-
eventSubscriptionName: string;
266-
267-
@doc("ReleaseOptions")
268-
@body
269-
lockTokens : ReleaseOptions;
270-
}, ReleaseResult>;
272+
@post
273+
op ReleaseCloudEvents is Azure.Core.RpcOperation<
274+
{
275+
@doc("content type")
276+
@header("content-type")
277+
contentType: "application/json; charset=utf-8";
278+
279+
@doc("Topic Name.")
280+
@path
281+
topicName: string;
282+
283+
@doc("Event Subscription Name.")
284+
@path
285+
eventSubscriptionName: string;
286+
287+
@doc("ReleaseOptions")
288+
@body
289+
lockTokens: ReleaseOptions;
290+
},
291+
ReleaseResult
292+
>;
271293

272294
// Reject Operation:
273295
// POST https://{namespaceName}.{region}.eventgrid.azure.net/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject?api-version={apiVersion}
274296

275297
@doc("Reject batch of Cloud Events.")
276298
@route("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject")
277-
@post op RejectCloudEvents is Azure.Core.RpcOperation<{
278-
@doc("content type")
279-
@header("content-type")
280-
contentType: "application/json; charset=utf-8";
281-
282-
@doc("Topic Name.")
283-
@path
284-
topicName: string;
285-
286-
@doc("Event Subscription Name.")
287-
@path
288-
eventSubscriptionName: string;
289-
290-
@doc("RejectOptions")
291-
@body
292-
lockTokens : RejectOptions;
293-
}, RejectResult>;
299+
@post
300+
op RejectCloudEvents is Azure.Core.RpcOperation<
301+
{
302+
@doc("content type")
303+
@header("content-type")
304+
contentType: "application/json; charset=utf-8";
305+
306+
@doc("Topic Name.")
307+
@path
308+
topicName: string;
309+
310+
@doc("Event Subscription Name.")
311+
@path
312+
eventSubscriptionName: string;
313+
314+
@doc("RejectOptions")
315+
@body
316+
lockTokens: RejectOptions;
317+
},
318+
RejectResult
319+
>;
294320
}

0 commit comments

Comments
 (0)