@@ -1260,6 +1260,79 @@ describe("typespec-client-generator-core: package", () => {
1260
1260
strictEqual ( sdkPackage . enums . length , 2 ) ;
1261
1261
} ) ;
1262
1262
} ) ;
1263
+ it ( "models only package" , async ( ) => {
1264
+ await runner . compile ( `
1265
+ @usage(Usage.input | Usage.output)
1266
+ namespace EventGridClient {
1267
+ model CloudEvent {
1268
+ id: string;
1269
+ }
1270
+ }
1271
+ ` ) ;
1272
+ const sdkPackage = runner . context . sdkPackage ;
1273
+ strictEqual ( sdkPackage . models . length , 1 ) ;
1274
+ strictEqual ( sdkPackage . models [ 0 ] . name , "CloudEvent" ) ;
1275
+ strictEqual ( sdkPackage . clients . length , 0 ) ;
1276
+ } ) ;
1277
+
1278
+ it ( "models only package with azure and versioning decorators" , async ( ) => {
1279
+ const runnerWithCore = await createSdkTestRunner ( {
1280
+ librariesToAdd : [ AzureCoreTestLibrary ] ,
1281
+ autoUsings : [ "Azure.Core" ] ,
1282
+ emitterName : "@azure-tools/typespec-java" ,
1283
+ } ) ;
1284
+ await runnerWithCore . compile ( `
1285
+ @usage(Usage.input | Usage.output)
1286
+ @versioned(ServiceApiVersions)
1287
+ namespace EventGridClient {
1288
+ enum ServiceApiVersions {
1289
+ @useDependency(Versions.v1_0_Preview_2)
1290
+ v2018_01_01: "2018-01-01",
1291
+ @useDependency(Versions.v1_0_Preview_2)
1292
+ v2024_01_01: "2024-01-01",
1293
+ }
1294
+ /**
1295
+ * CloudEvent comments
1296
+ */
1297
+ model CloudEvent {
1298
+ /**
1299
+ * id comments
1300
+ */
1301
+ id: string;
1302
+ }
1303
+
1304
+ /**
1305
+ * Healthcare comments
1306
+ */
1307
+ model HealthcareFhirResourceCreatedEventData {
1308
+ /**
1309
+ * resourceVersionId comments
1310
+ */
1311
+ @added(ServiceApiVersions.v2024_01_01)
1312
+ resourceVersionId: int64;
1313
+ }
1314
+ }
1315
+ ` ) ;
1316
+ const sdkPackage = runnerWithCore . context . sdkPackage ;
1317
+ strictEqual ( sdkPackage . models . length , 2 ) ;
1318
+ const cloudEventModel = sdkPackage . models . find ( ( x ) => x . name === "CloudEvent" ) ;
1319
+ ok ( cloudEventModel ) ;
1320
+ strictEqual ( cloudEventModel . properties . length , 1 ) ;
1321
+ const idProperty = cloudEventModel . properties [ 0 ] ;
1322
+ strictEqual ( idProperty . name , "id" ) ;
1323
+ strictEqual ( idProperty . kind , "property" ) ;
1324
+ deepStrictEqual ( idProperty . apiVersions , [ "2018-01-01" , "2024-01-01" ] ) ;
1325
+
1326
+ const healthcareEventDataModel = sdkPackage . models . find (
1327
+ ( x ) => x . name === "HealthcareFhirResourceCreatedEventData" ,
1328
+ ) ;
1329
+ ok ( healthcareEventDataModel ) ;
1330
+ strictEqual ( healthcareEventDataModel . properties . length , 1 ) ;
1331
+ const resourceVersionIdProperty = healthcareEventDataModel . properties [ 0 ] ;
1332
+ strictEqual ( resourceVersionIdProperty . name , "resourceVersionId" ) ;
1333
+ strictEqual ( resourceVersionIdProperty . kind , "property" ) ;
1334
+ deepStrictEqual ( resourceVersionIdProperty . apiVersions , [ "2024-01-01" ] ) ;
1335
+ } ) ;
1263
1336
} ) ;
1264
1337
1265
1338
function getServiceMethodOfClient (
0 commit comments