@azure-tools/typespec-azure-core 0.40.0-dev.2 → 0.40.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -48
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +43 -35
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/non-breaking-versioning.d.ts +6 -0
- package/dist/src/rules/non-breaking-versioning.d.ts.map +1 -0
- package/dist/src/rules/non-breaking-versioning.js +52 -0
- package/dist/src/rules/non-breaking-versioning.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ linter:
|
|
|
25
25
|
Available ruleSets:
|
|
26
26
|
|
|
27
27
|
- [`@azure-tools/typespec-azure-core/all`](#@azure-tools/typespec-azure-core/all)
|
|
28
|
+
- [`@azure-tools/typespec-azure-core/canonical-versioning`](#@azure-tools/typespec-azure-core/canonical-versioning)
|
|
28
29
|
|
|
29
30
|
### Rules
|
|
30
31
|
|
|
@@ -32,37 +33,38 @@ Available ruleSets:
|
|
|
32
33
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
34
|
| `@azure-tools/typespec-azure-core/operation-missing-api-version` | Operations need an api version parameter. |
|
|
34
35
|
| `@azure-tools/typespec-azure-core/auth-required` | Enforce service authentication. |
|
|
35
|
-
| `@azure-tools/typespec-azure-core/no-operation-id` | Operation ID is automatically generated by the OpenAPI emitters and should not normally be specified. |
|
|
36
36
|
| `@azure-tools/typespec-azure-core/request-body-problem` | Request body should not be of raw array type. |
|
|
37
37
|
| `@azure-tools/typespec-azure-core/byos` | Use the BYOS pattern recommended for Azure Services. |
|
|
38
38
|
| `@azure-tools/typespec-azure-core/casing-style` | Ensure proper casing style. |
|
|
39
|
-
| `@azure-tools/typespec-azure-core/spread-discriminated-model` | Check a model with a discriminator has not been used in composition. |
|
|
40
39
|
| `@azure-tools/typespec-azure-core/composition-over-inheritance` | Check that if a model is used in an operation and has derived models that it has a discriminator or recommend to use composition via spread or `is`. |
|
|
41
|
-
| `@azure-tools/typespec-azure-core/prefer-csv-collection-format` | It is recommended to use "csv" for collection format of parameters. |
|
|
42
40
|
| `@azure-tools/typespec-azure-core/use-extensible-enum` | Enums should be extensible. |
|
|
43
41
|
| `@azure-tools/typespec-azure-core/known-encoding` | Check for supported encodings. |
|
|
44
|
-
| `@azure-tools/typespec-azure-core/
|
|
42
|
+
| `@azure-tools/typespec-azure-core/long-running-polling-operation-required` | Long-running operations should have a linked polling operation. |
|
|
45
43
|
| [`@azure-tools/typespec-azure-core/no-closed-literal-union`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-closed-literal-union) | Unions of literals should include the base scalar type to mark them as open enum. |
|
|
46
44
|
| [`@azure-tools/typespec-azure-core/no-enum`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-enum) | Azure services should not use enums. |
|
|
47
45
|
| `@azure-tools/typespec-azure-core/no-error-status-codes` | Recommend using the error response defined by Azure REST API guidelines. |
|
|
46
|
+
| `@azure-tools/typespec-azure-core/no-explicit-routes-resource-ops` | The @route decorator should not be used on standard resource operation signatures. |
|
|
48
47
|
| `@azure-tools/typespec-azure-core/no-fixed-enum-discriminator` | Discriminator shouldn't be a fixed enum. |
|
|
48
|
+
| [`@azure-tools/typespec-azure-core/non-breaking-versioning`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/non-breaking-versioning) | Check that only backward compatible versioning change are done to a service. |
|
|
49
49
|
| `@azure-tools/typespec-azure-core/no-nullable` | Use `?` for optional properties. |
|
|
50
50
|
| `@azure-tools/typespec-azure-core/no-offsetdatetime` | Prefer using `utcDateTime` when representing a datetime unless an offset is necessary. |
|
|
51
|
-
| `@azure-tools/typespec-azure-core/no-rpc-path-params` | Operations defined using RpcOperation should not have path parameters. |
|
|
52
|
-
| `@azure-tools/typespec-azure-core/no-explicit-routes-resource-ops` | The @route decorator should not be used on standard resource operation signatures. |
|
|
53
51
|
| `@azure-tools/typespec-azure-core/no-response-body` | Ensure that the body is set correctly for the response type. |
|
|
52
|
+
| `@azure-tools/typespec-azure-core/no-rpc-path-params` | Operations defined using RpcOperation should not have path parameters. |
|
|
53
|
+
| `@azure-tools/typespec-azure-core/no-operation-id` | Operation ID is automatically generated by the OpenAPI emitters and should not normally be specified. |
|
|
54
|
+
| `@azure-tools/typespec-azure-core/prefer-csv-collection-format` | It is recommended to use "csv" for collection format of parameters. |
|
|
54
55
|
| `@azure-tools/typespec-azure-core/no-format` | Azure services should not use the `@format` decorator. |
|
|
55
56
|
| `@azure-tools/typespec-azure-core/no-multiple-discriminator` | Classes should have at most one discriminator. |
|
|
56
57
|
| `@azure-tools/typespec-azure-core/no-rest-library-interfaces` | Resource interfaces from the TypeSpec.Rest.Resource library are incompatible with Azure.Core. |
|
|
57
58
|
| `@azure-tools/typespec-azure-core/no-unknown` | Azure services must not have properties of type `unknown`. |
|
|
58
|
-
| `@azure-tools/typespec-azure-core/bad-record-type` | Identify bad record definitions. |
|
|
59
|
-
| `@azure-tools/typespec-azure-core/response-schema-problem` | Warn about operations having multiple non-error response schemas. |
|
|
60
59
|
| `@azure-tools/typespec-azure-core/property-name-conflict` | Avoid naming conflicts. |
|
|
61
|
-
| `@azure-tools/typespec-azure-core/
|
|
60
|
+
| `@azure-tools/typespec-azure-core/bad-record-type` | Identify bad record definitions. |
|
|
62
61
|
| `@azure-tools/typespec-azure-core/documentation-required` | Require documentation over enums, models, and operations. |
|
|
63
62
|
| `@azure-tools/typespec-azure-core/key-visibility-required` | Key properties need to have an explicit visibility setting. |
|
|
64
|
-
| `@azure-tools/typespec-azure-core/
|
|
63
|
+
| `@azure-tools/typespec-azure-core/response-schema-problem` | Warn about operations having multiple non-error response schemas. |
|
|
64
|
+
| `@azure-tools/typespec-azure-core/rpc-operation-request-body` | Warning for RPC body problems. |
|
|
65
|
+
| `@azure-tools/typespec-azure-core/spread-discriminated-model` | Check a model with a discriminator has not been used in composition. |
|
|
65
66
|
| `@azure-tools/typespec-azure-core/use-standard-names` | Use recommended names for operations. |
|
|
67
|
+
| `@azure-tools/typespec-azure-core/use-standard-operations` | Operations should be defined using a signature from the Azure.Core namespace. |
|
|
66
68
|
|
|
67
69
|
## Decorators
|
|
68
70
|
|
|
@@ -100,9 +102,9 @@ Identifies a ModelProperty as containing the final location for the operation re
|
|
|
100
102
|
|
|
101
103
|
##### Parameters
|
|
102
104
|
|
|
103
|
-
| Name | Type
|
|
104
|
-
| ----------- |
|
|
105
|
-
| finalResult | `
|
|
105
|
+
| Name | Type | Description |
|
|
106
|
+
| ----------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
107
|
+
| finalResult | `Model \| void` | Sets the expected return value for the final result. Overrides<br />any value provided in the decorated property, if the property uses ResourceLocation<Resource>. |
|
|
106
108
|
|
|
107
109
|
#### `@finalOperation`
|
|
108
110
|
|
|
@@ -121,7 +123,7 @@ Identifies that an operation is the final operation for an LRO.
|
|
|
121
123
|
| Name | Type | Description |
|
|
122
124
|
| --------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
123
125
|
| linkedOperation | `Operation` | The linked Operation |
|
|
124
|
-
| parameters | `
|
|
126
|
+
| parameters | `{}` | Map of `RequestParameter<Name>` and/or `ResponseProperty<Name>` that will<br />be passed to the linked operation request. |
|
|
125
127
|
|
|
126
128
|
#### `@fixed`
|
|
127
129
|
|
|
@@ -167,7 +169,7 @@ Identifies an EnumMember as a long-running "Canceled" terminal state.
|
|
|
167
169
|
|
|
168
170
|
##### Target
|
|
169
171
|
|
|
170
|
-
`
|
|
172
|
+
`EnumMember | UnionVariant`
|
|
171
173
|
|
|
172
174
|
##### Parameters
|
|
173
175
|
|
|
@@ -202,7 +204,7 @@ Identifies an enum member as a long-running "Failed" terminal state.
|
|
|
202
204
|
|
|
203
205
|
##### Target
|
|
204
206
|
|
|
205
|
-
`
|
|
207
|
+
`EnumMember | UnionVariant`
|
|
206
208
|
|
|
207
209
|
##### Parameters
|
|
208
210
|
|
|
@@ -238,7 +240,7 @@ status.
|
|
|
238
240
|
|
|
239
241
|
##### Target
|
|
240
242
|
|
|
241
|
-
`
|
|
243
|
+
`Enum | Union | ModelProperty`
|
|
242
244
|
|
|
243
245
|
##### Parameters
|
|
244
246
|
|
|
@@ -255,7 +257,7 @@ Identifies an EnumMember as a long-running "Succeeded" terminal state.
|
|
|
255
257
|
|
|
256
258
|
##### Target
|
|
257
259
|
|
|
258
|
-
`
|
|
260
|
+
`EnumMember | UnionVariant`
|
|
259
261
|
|
|
260
262
|
##### Parameters
|
|
261
263
|
|
|
@@ -294,7 +296,7 @@ Identifies that an operation is used to retrieve the next page for paged operati
|
|
|
294
296
|
| Name | Type | Description |
|
|
295
297
|
| --------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
296
298
|
| linkedOperation | `Operation` | The linked Operation |
|
|
297
|
-
| parameters | `
|
|
299
|
+
| parameters | `{}` | Map of `RequestParameter<Name>` and/or `ResponseProperty<Name>` that will<br />be passed to the linked operation request. |
|
|
298
300
|
|
|
299
301
|
#### `@operationLink`
|
|
300
302
|
|
|
@@ -310,11 +312,11 @@ Identifies an operation that is linked to the target operation.
|
|
|
310
312
|
|
|
311
313
|
##### Parameters
|
|
312
314
|
|
|
313
|
-
| Name | Type
|
|
314
|
-
| --------------- |
|
|
315
|
-
| linkedOperation | `Operation`
|
|
316
|
-
| linkType | `valueof
|
|
317
|
-
| parameters | `
|
|
315
|
+
| Name | Type | Description |
|
|
316
|
+
| --------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
317
|
+
| linkedOperation | `Operation` | The linked Operation |
|
|
318
|
+
| linkType | `valueof string` | A string indicating the role of the linked operation |
|
|
319
|
+
| parameters | `{}` | Map of `RequestParameter<Name>` and/or `ResponseProperty<Name>` that will<br />be passed to the linked operation request. |
|
|
318
320
|
|
|
319
321
|
#### `@pagedResult`
|
|
320
322
|
|
|
@@ -346,9 +348,9 @@ Identifies a model property as containing the location to poll for operation sta
|
|
|
346
348
|
|
|
347
349
|
##### Parameters
|
|
348
350
|
|
|
349
|
-
| Name | Type
|
|
350
|
-
| ------- |
|
|
351
|
-
| options | `
|
|
351
|
+
| Name | Type | Description |
|
|
352
|
+
| ------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
353
|
+
| options | [`PollingOptions`](#pollingoptions) | PollingOptions for the poller pointed to by this link. Overrides<br />settings derived from property value it is decorating, if the value of the<br />property is ResourceLocation<Resource> |
|
|
352
354
|
|
|
353
355
|
#### `@pollingOperation`
|
|
354
356
|
|
|
@@ -367,7 +369,7 @@ Identifies that an operation is a polling operation for an LRO.
|
|
|
367
369
|
| Name | Type | Description |
|
|
368
370
|
| --------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
369
371
|
| linkedOperation | `Operation` | The linked Operation |
|
|
370
|
-
| parameters | `
|
|
372
|
+
| parameters | `{}` | Map of `RequestParameter<Name>` and/or `ResponseProperty<Name>` that will<br />be passed to the linked operation request. |
|
|
371
373
|
|
|
372
374
|
#### `@pollingOperationParameter`
|
|
373
375
|
|
|
@@ -383,9 +385,9 @@ Used to define how to call custom polling operations for long-running operations
|
|
|
383
385
|
|
|
384
386
|
##### Parameters
|
|
385
387
|
|
|
386
|
-
| Name | Type
|
|
387
|
-
| --------------- |
|
|
388
|
-
| targetParameter | `
|
|
388
|
+
| Name | Type | Description |
|
|
389
|
+
| --------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
390
|
+
| targetParameter | `ModelProperty \| string` | A reference to the polling operation parameter this parameter<br />provides a value for, or the name of that parameter. The default value is the name of<br />the decorated parameter or property. |
|
|
389
391
|
|
|
390
392
|
### Azure.Core.Foundations
|
|
391
393
|
|
|
@@ -423,9 +425,9 @@ Identifies a property on a request model that serves as a linked operation param
|
|
|
423
425
|
|
|
424
426
|
##### Parameters
|
|
425
427
|
|
|
426
|
-
| Name | Type
|
|
427
|
-
| ---- |
|
|
428
|
-
| name | `valueof
|
|
428
|
+
| Name | Type | Description |
|
|
429
|
+
| ---- | ---------------- | --------------------------- |
|
|
430
|
+
| name | `valueof string` | Property name on the target |
|
|
429
431
|
|
|
430
432
|
#### `@responseProperty`
|
|
431
433
|
|
|
@@ -441,9 +443,9 @@ Identifies a property on _all_ non-error response models that serve as a linked
|
|
|
441
443
|
|
|
442
444
|
##### Parameters
|
|
443
445
|
|
|
444
|
-
| Name | Type
|
|
445
|
-
| ---- |
|
|
446
|
-
| name | `valueof
|
|
446
|
+
| Name | Type | Description |
|
|
447
|
+
| ---- | ---------------- | --------------------------- |
|
|
448
|
+
| name | `valueof string` | Property name on the target |
|
|
447
449
|
|
|
448
450
|
### Azure.Core.Traits
|
|
449
451
|
|
|
@@ -464,13 +466,13 @@ checks.
|
|
|
464
466
|
##### Target
|
|
465
467
|
|
|
466
468
|
The model type to mark as a trait.
|
|
467
|
-
`
|
|
469
|
+
`unknown`
|
|
468
470
|
|
|
469
471
|
##### Parameters
|
|
470
472
|
|
|
471
|
-
| Name | Type
|
|
472
|
-
| --------- |
|
|
473
|
-
| traitName | `valueof
|
|
473
|
+
| Name | Type | Description |
|
|
474
|
+
| --------- | ---------------- | -------------------------------------------------------------------------------------------------- |
|
|
475
|
+
| traitName | `valueof string` | An optional name to uniquely identify the trait. If unspecified,<br />the model type name is used. |
|
|
474
476
|
|
|
475
477
|
#### `@traitAdded`
|
|
476
478
|
|
|
@@ -483,13 +485,13 @@ to either a trait model type or its envelope property.
|
|
|
483
485
|
|
|
484
486
|
##### Target
|
|
485
487
|
|
|
486
|
-
`
|
|
488
|
+
`Model | ModelProperty`
|
|
487
489
|
|
|
488
490
|
##### Parameters
|
|
489
491
|
|
|
490
|
-
| Name | Type
|
|
491
|
-
| ------------ |
|
|
492
|
-
| addedVersion | `
|
|
492
|
+
| Name | Type | Description |
|
|
493
|
+
| ------------ | -------------------- | ------------------------------------------------- |
|
|
494
|
+
| addedVersion | `EnumMember \| null` | The enum member representing the service version. |
|
|
493
495
|
|
|
494
496
|
#### `@traitContext`
|
|
495
497
|
|
|
@@ -506,9 +508,9 @@ The trait envelope property where the context will be applied.
|
|
|
506
508
|
|
|
507
509
|
##### Parameters
|
|
508
510
|
|
|
509
|
-
| Name | Type
|
|
510
|
-
| -------- |
|
|
511
|
-
| contexts | `
|
|
511
|
+
| Name | Type | Description |
|
|
512
|
+
| -------- | -------------------------------- | ------------------------------------------------------------------------------------------ |
|
|
513
|
+
| contexts | `EnumMember \| Union \| unknown` | An enum member or union of enum members representing the trait's<br />applicable contexts. |
|
|
512
514
|
|
|
513
515
|
#### `@traitLocation`
|
|
514
516
|
|
package/dist/src/linter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AA0EA,eAAO,MAAM,OAAO,+CAgDlB,CAAC"}
|
package/dist/src/linter.js
CHANGED
|
@@ -18,6 +18,7 @@ import { noOffsetDateTimeRule } from "./rules/no-offsetdatetime.js";
|
|
|
18
18
|
import { operationIdRule } from "./rules/no-operation-id.js";
|
|
19
19
|
import { noResponseBodyRule } from "./rules/no-response-body.js";
|
|
20
20
|
import { noRpcPathParamsRule } from "./rules/no-rpc-path-params.js";
|
|
21
|
+
import { nonBreakingVersioningRule } from "./rules/non-breaking-versioning.js";
|
|
21
22
|
import { preferCsvCollectionFormatRule } from "./rules/prefer-csv-collection-format.js";
|
|
22
23
|
import { preventFormatUse } from "./rules/prevent-format.js";
|
|
23
24
|
import { preventMultipleDiscriminator } from "./rules/prevent-multiple-discriminator.js";
|
|
@@ -33,42 +34,44 @@ import { rpcOperationRequestBodyRule } from "./rules/rpc-operation-request-body.
|
|
|
33
34
|
import { spreadDiscriminatedModelRule } from "./rules/spread-discriminated-model.js";
|
|
34
35
|
import { useStandardNames } from "./rules/use-standard-names.js";
|
|
35
36
|
import { useStandardOperations } from "./rules/use-standard-ops.js";
|
|
37
|
+
const rules = [
|
|
38
|
+
apiVersionRule,
|
|
39
|
+
authRequiredRule,
|
|
40
|
+
bodyArrayRule,
|
|
41
|
+
byosRule,
|
|
42
|
+
casingRule,
|
|
43
|
+
compositionOverInheritanceRule,
|
|
44
|
+
extensibleEnumRule,
|
|
45
|
+
knownEncodingRule,
|
|
46
|
+
longRunningOperationsRequirePollingOperation,
|
|
47
|
+
noClosedLiteralUnionRule,
|
|
48
|
+
noEnumRule,
|
|
49
|
+
noErrorStatusCodesRule,
|
|
50
|
+
noExplicitRoutesResourceOps,
|
|
51
|
+
noFixedEnumDiscriminatorRule,
|
|
52
|
+
nonBreakingVersioningRule,
|
|
53
|
+
noNullableRule,
|
|
54
|
+
noOffsetDateTimeRule,
|
|
55
|
+
noResponseBodyRule,
|
|
56
|
+
noRpcPathParamsRule,
|
|
57
|
+
operationIdRule,
|
|
58
|
+
preferCsvCollectionFormatRule,
|
|
59
|
+
preventFormatUse,
|
|
60
|
+
preventMultipleDiscriminator,
|
|
61
|
+
preventRestLibraryInterfaces,
|
|
62
|
+
preventUnknownType,
|
|
63
|
+
propertyNameRule,
|
|
64
|
+
recordTypeRule,
|
|
65
|
+
requireDocumentation,
|
|
66
|
+
requireKeyVisibility,
|
|
67
|
+
responseSchemaMultiStatusCodeRule,
|
|
68
|
+
rpcOperationRequestBodyRule,
|
|
69
|
+
spreadDiscriminatedModelRule,
|
|
70
|
+
useStandardNames,
|
|
71
|
+
useStandardOperations,
|
|
72
|
+
];
|
|
36
73
|
export const $linter = defineLinter({
|
|
37
|
-
rules
|
|
38
|
-
apiVersionRule,
|
|
39
|
-
authRequiredRule,
|
|
40
|
-
operationIdRule,
|
|
41
|
-
bodyArrayRule,
|
|
42
|
-
byosRule,
|
|
43
|
-
casingRule,
|
|
44
|
-
spreadDiscriminatedModelRule,
|
|
45
|
-
compositionOverInheritanceRule,
|
|
46
|
-
preferCsvCollectionFormatRule,
|
|
47
|
-
extensibleEnumRule,
|
|
48
|
-
knownEncodingRule,
|
|
49
|
-
useStandardOperations,
|
|
50
|
-
noClosedLiteralUnionRule,
|
|
51
|
-
noEnumRule,
|
|
52
|
-
noErrorStatusCodesRule,
|
|
53
|
-
noFixedEnumDiscriminatorRule,
|
|
54
|
-
noNullableRule,
|
|
55
|
-
noOffsetDateTimeRule,
|
|
56
|
-
noRpcPathParamsRule,
|
|
57
|
-
noExplicitRoutesResourceOps,
|
|
58
|
-
noResponseBodyRule,
|
|
59
|
-
preventFormatUse,
|
|
60
|
-
preventMultipleDiscriminator,
|
|
61
|
-
preventRestLibraryInterfaces,
|
|
62
|
-
preventUnknownType,
|
|
63
|
-
recordTypeRule,
|
|
64
|
-
responseSchemaMultiStatusCodeRule,
|
|
65
|
-
propertyNameRule,
|
|
66
|
-
rpcOperationRequestBodyRule,
|
|
67
|
-
requireDocumentation,
|
|
68
|
-
requireKeyVisibility,
|
|
69
|
-
longRunningOperationsRequirePollingOperation,
|
|
70
|
-
useStandardNames,
|
|
71
|
-
],
|
|
74
|
+
rules,
|
|
72
75
|
ruleSets: {
|
|
73
76
|
all: {
|
|
74
77
|
enable: {
|
|
@@ -108,6 +111,11 @@ export const $linter = defineLinter({
|
|
|
108
111
|
},
|
|
109
112
|
extends: ["@typespec/http/all"],
|
|
110
113
|
},
|
|
114
|
+
"canonical-versioning": {
|
|
115
|
+
enable: {
|
|
116
|
+
[`@azure-tools/typespec-azure-core/${nonBreakingVersioningRule.name}`]: false,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
111
119
|
},
|
|
112
120
|
});
|
|
113
121
|
//# sourceMappingURL=linter.js.map
|
package/dist/src/linter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,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IAAI;gBACnE,CAAC,oCAAoC,2BAA2B,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBAC9E,CAAC,oCAAoC,oBAAoB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACvE,CAAC,oCAAoC,oBAAoB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACvE,CAAC,oCAAoC,4CAA4C,CAAC,IAAI,EAAE,CAAC,EACvF,IAAI;gBACN,CAAC,oCAAoC,gBAAgB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACnE,CAAC,oCAAoC,gBAAgB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI;gBACnE,CAAC,oCAAoC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK;aAC/D;YACD,OAAO,EAAE,CAAC,oBAAoB,CAAC;SAChC;QACD,sBAAsB,EAAE;YACtB,MAAM,EAAE;gBACN,CAAC,oCAAoC,yBAAyB,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK;aAC9E;SACF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const nonBreakingVersioningRule: import("@typespec/compiler").LinterRuleDefinition<"non-breaking-versioning", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<[string]>;
|
|
3
|
+
readonly addedRequired: "Adding required property is a breaking change.";
|
|
4
|
+
readonly optionalNoDefault: "Property made optional should have a default value.";
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=non-breaking-versioning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-breaking-versioning.d.ts","sourceRoot":"","sources":["../../../src/rules/non-breaking-versioning.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,yBAAyB;;;;EAyDpC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRule, paramMessage } from "@typespec/compiler";
|
|
2
|
+
import { getAddedOnVersions, getMadeOptionalOn, getRemovedOnVersions, getRenamedFromVersions, } from "@typespec/versioning";
|
|
3
|
+
export const nonBreakingVersioningRule = createRule({
|
|
4
|
+
name: "non-breaking-versioning",
|
|
5
|
+
description: "Check that only backward compatible versioning change are done to a service.",
|
|
6
|
+
severity: "warning",
|
|
7
|
+
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/non-breaking-versioning",
|
|
8
|
+
messages: {
|
|
9
|
+
default: paramMessage `Using ${"action"} is not backward compatible.`,
|
|
10
|
+
addedRequired: "Adding required property is a breaking change.",
|
|
11
|
+
optionalNoDefault: "Property made optional should have a default value.",
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
model: checkBadVersioningPattern,
|
|
16
|
+
modelProperty: checkBadVersioningPatternForProperty,
|
|
17
|
+
operation: checkBadVersioningPattern,
|
|
18
|
+
};
|
|
19
|
+
function checkBadVersioningPattern(type) {
|
|
20
|
+
if (getRemovedOnVersions(context.program, type) !== undefined) {
|
|
21
|
+
reportBreakingVersioning("@removed", type);
|
|
22
|
+
}
|
|
23
|
+
if (getRenamedFromVersions(context.program, type) !== undefined) {
|
|
24
|
+
reportBreakingVersioning("@renamedFrom", type);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function checkBadVersioningPatternForProperty(modelProperty) {
|
|
28
|
+
checkBadVersioningPattern(modelProperty);
|
|
29
|
+
if (getAddedOnVersions(context.program, modelProperty) !== undefined &&
|
|
30
|
+
!modelProperty.optional) {
|
|
31
|
+
context.reportDiagnostic({
|
|
32
|
+
messageId: "addedRequired",
|
|
33
|
+
target: modelProperty,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (getMadeOptionalOn(context.program, modelProperty) !== undefined &&
|
|
37
|
+
modelProperty.default === undefined) {
|
|
38
|
+
context.reportDiagnostic({
|
|
39
|
+
messageId: "optionalNoDefault",
|
|
40
|
+
target: modelProperty,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function reportBreakingVersioning(action, target) {
|
|
45
|
+
context.reportDiagnostic({
|
|
46
|
+
format: { action },
|
|
47
|
+
target,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=non-breaking-versioning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-breaking-versioning.js","sourceRoot":"","sources":["../../../src/rules/non-breaking-versioning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC;IAClD,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,8EAA8E;IAC3F,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,gGAAgG;IACrG,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,SAAS,QAAQ,8BAA8B;QACpE,aAAa,EAAE,gDAAgD;QAC/D,iBAAiB,EAAE,qDAAqD;KACzE;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,KAAK,EAAE,yBAAyB;YAChC,aAAa,EAAE,oCAAoC;YACnD,SAAS,EAAE,yBAAyB;SACrC,CAAC;QAEF,SAAS,yBAAyB,CAAC,IAAU;YAC3C,IAAI,oBAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC9D,wBAAwB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAC7C,CAAC;YACD,IAAI,sBAAsB,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;gBAChE,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;Q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