@azure-tools/typespec-azure-core 0.53.0-dev.5 → 0.53.0-dev.7

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 CHANGED
@@ -48,7 +48,7 @@ Available ruleSets:
48
48
  | `@azure-tools/typespec-azure-core/no-response-body` | Ensure that the body is set correctly for the response type. |
49
49
  | `@azure-tools/typespec-azure-core/no-rpc-path-params` | Operations defined using RpcOperation should not have path parameters. |
50
50
  | `@azure-tools/typespec-azure-core/no-openapi` | Azure specs should not be using decorators from @typespec/openapi or @azure-tools/typespec-autorest |
51
- | `@azure-tools/typespec-azure-core/prefer-csv-collection-format` | It is recommended to use "csv" for collection format of parameters. |
51
+ | [`@azure-tools/typespec-azure-core/no-header-explode`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-header-explode) | It is recommended to serialize header parameter without explode: true |
52
52
  | [`@azure-tools/typespec-azure-core/no-format`](https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/prevent-format) | Azure services should not use the `@format` decorator. |
53
53
  | `@azure-tools/typespec-azure-core/no-multiple-discriminator` | Classes should have at most one discriminator. |
54
54
  | `@azure-tools/typespec-azure-core/no-rest-library-interfaces` | Resource interfaces from the TypeSpec.Rest.Resource library are incompatible with Azure.Core. |
@@ -12,6 +12,7 @@ import { noEnumRule } from "./rules/no-enum.js";
12
12
  import { noErrorStatusCodesRule } from "./rules/no-error-status-codes.js";
13
13
  import { noExplicitRoutesResourceOps } from "./rules/no-explicit-routes-resource-ops.js";
14
14
  import { noGenericNumericRule } from "./rules/no-generic-numeric.js";
15
+ import { noHeaderExplodeRule } from "./rules/no-header-explode.js";
15
16
  import { noMultipleDiscriminatorRule } from "./rules/no-multiple-discriminator.js";
16
17
  import { noNullableRule } from "./rules/no-nullable.js";
17
18
  import { noOffsetDateTimeRule } from "./rules/no-offsetdatetime.js";
@@ -23,7 +24,6 @@ import { noRpcPathParamsRule } from "./rules/no-rpc-path-params.js";
23
24
  import { noStringDiscriminatorRule } from "./rules/no-string-discriminator.js";
24
25
  import { nonBreakingVersioningRule } from "./rules/non-breaking-versioning.js";
25
26
  import { apiVersionRule } from "./rules/operation-missing-api-version.js";
26
- import { preferCsvCollectionFormatRule } from "./rules/prefer-csv-collection-format.js";
27
27
  import { preventFormatRule } from "./rules/prevent-format.js";
28
28
  import { preventRestLibraryInterfaces } from "./rules/prevent-rest-library.js";
29
29
  import { preventUnknownType } from "./rules/prevent-unknown.js";
@@ -56,7 +56,7 @@ const rules = [
56
56
  noResponseBodyRule,
57
57
  noRpcPathParamsRule,
58
58
  noOpenAPIRule,
59
- preferCsvCollectionFormatRule,
59
+ noHeaderExplodeRule,
60
60
  preventFormatRule,
61
61
  noMultipleDiscriminatorRule,
62
62
  preventRestLibraryInterfaces,
@@ -1 +1 @@
1
- {"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,4CAA4C,EAAE,MAAM,kCAAkC,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE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IAAI;aAC7E;SACF;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const noHeaderExplodeRule: import("@typespec/compiler").LinterRuleDefinition<"no-header-explode", {
2
+ readonly default: "It is preferred to not use explode: true for header parameters";
3
+ }>;
4
+ //# sourceMappingURL=no-header-explode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-header-explode.d.ts","sourceRoot":"","sources":["../../../src/rules/no-header-explode.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB;;EAsB9B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { createRule, ignoreDiagnostics } from "@typespec/compiler";
2
+ import { getHttpOperation } from "@typespec/http";
3
+ export const noHeaderExplodeRule = createRule({
4
+ name: "no-header-explode",
5
+ description: "It is recommended to serialize header parameter without explode: true",
6
+ severity: "warning",
7
+ url: "https://azure.github.io/typespec-azure/docs/libraries/azure-core/rules/no-header-explode",
8
+ messages: {
9
+ default: `It is preferred to not use explode: true for header parameters`,
10
+ },
11
+ create(context) {
12
+ return {
13
+ operation: (operation) => {
14
+ const httpOperation = ignoreDiagnostics(getHttpOperation(context.program, operation));
15
+ for (const prop of httpOperation.parameters.properties.filter((x) => x.kind === "header")) {
16
+ if (prop.options.explode === true) {
17
+ context.reportDiagnostic({
18
+ target: prop.property,
19
+ });
20
+ }
21
+ }
22
+ },
23
+ };
24
+ },
25
+ });
26
+ //# sourceMappingURL=no-header-explode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-header-explode.js","sourceRoot":"","sources":["../../../src/rules/no-header-explode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAa,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC;IAC5C,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,uEAAuE;IACpF,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,0FAA0F;IAC/F,QAAQ,EAAE;QACR,OAAO,EAAE,gEAAgE;KAC1E;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,SAAS,EAAE,CAAC,SAAoB,EAAE,EAAE;gBAClC,MAAM,aAAa,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;gBACtF,KAAK,MAAM,IAAI,IAAI,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;oBAC1F,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;wBAClC,OAAO,CAAC,gBAAgB,CAAC;4BACvB,MAAM,EAAE,IAAI,CAAC,QAAQ;yBACtB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
package/lib/models.tsp CHANGED
@@ -89,7 +89,6 @@ model FilterParameter {
89
89
 
90
90
  @doc("Provides the standard 'orderby' query parameter for list operations.")
91
91
  model OrderByQueryParameter {
92
- #suppress "@azure-tools/typespec-azure-core/prefer-csv-collection-format" "By design"
93
92
  @query(#{ explode: true })
94
93
  @doc("Expressions that specify the order of returned results.")
95
94
  orderby?: string[];
@@ -104,7 +103,6 @@ model FilterQueryParameter {
104
103
 
105
104
  @doc("Provides the standard 'select' query parameter for list operations.")
106
105
  model SelectQueryParameter {
107
- #suppress "@azure-tools/typespec-azure-core/prefer-csv-collection-format" "By design"
108
106
  @query(#{ explode: true })
109
107
  @doc("Select the specified fields to be included in the response.")
110
108
  select?: string[];
@@ -112,7 +110,6 @@ model SelectQueryParameter {
112
110
 
113
111
  @doc("Provides the standard 'expand' query parameter for list operations.")
114
112
  model ExpandQueryParameter {
115
- #suppress "@azure-tools/typespec-azure-core/prefer-csv-collection-format" "By design"
116
113
  @query(#{ explode: true })
117
114
  @doc("Expand the indicated resources into the response.")
118
115
  expand?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-azure-core",
3
- "version": "0.53.0-dev.5",
3
+ "version": "0.53.0-dev.7",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Core library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",
@@ -21,6 +21,7 @@
21
21
  "tspMain": "lib/azure-core.tsp",
22
22
  "exports": {
23
23
  ".": {
24
+ "typespec": "./lib/azure-core.tsp",
24
25
  "types": "./dist/src/index.d.ts",
25
26
  "default": "./dist/src/index.js"
26
27
  },
@@ -1,4 +0,0 @@
1
- export declare const preferCsvCollectionFormatRule: import("@typespec/compiler").LinterRuleDefinition<"prefer-csv-collection-format", {
2
- readonly default: "It is recommended to use \"csv\" for collection format of parameters.";
3
- }>;
4
- //# sourceMappingURL=prefer-csv-collection-format.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefer-csv-collection-format.d.ts","sourceRoot":"","sources":["../../../src/rules/prefer-csv-collection-format.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B;;EAsBxC,CAAC"}
@@ -1,27 +0,0 @@
1
- import { createRule } from "@typespec/compiler";
2
- import { getHeaderFieldOptions } from "@typespec/http";
3
- import { isExcludedCoreType } from "./utils.js";
4
- export const preferCsvCollectionFormatRule = createRule({
5
- name: "prefer-csv-collection-format",
6
- description: `It is recommended to use "csv" for collection format of parameters.`,
7
- severity: "warning",
8
- messages: {
9
- default: `It is recommended to use "csv" for collection format of parameters.`,
10
- },
11
- create(context) {
12
- return {
13
- modelProperty: (property) => {
14
- if (isExcludedCoreType(context.program, property))
15
- return;
16
- const headerOptions = getHeaderFieldOptions(context.program, property);
17
- // eslint-disable-next-line @typescript-eslint/no-deprecated
18
- if (headerOptions?.format !== undefined && headerOptions?.format !== "csv") {
19
- context.reportDiagnostic({
20
- target: property,
21
- });
22
- }
23
- },
24
- };
25
- },
26
- });
27
- //# sourceMappingURL=prefer-csv-collection-format.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefer-csv-collection-format.js","sourceRoot":"","sources":["../../../src/rules/prefer-csv-collection-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC;IACtD,IAAI,EAAE,8BAA8B;IACpC,WAAW,EAAE,qEAAqE;IAClF,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,qEAAqE;KAC/E;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,aAAa,EAAE,CAAC,QAAuB,EAAE,EAAE;gBACzC,IAAI,kBAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;oBAAE,OAAO;gBAE1D,MAAM,aAAa,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBACvE,4DAA4D;gBAC5D,IAAI,aAAa,EAAE,MAAM,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,KAAK,KAAK,EAAE,CAAC;oBAC3E,OAAO,CAAC,gBAAgB,CAAC;wBACvB,MAAM,EAAE,QAAQ;qBACjB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}