@typespec/http-specs 0.37.2 → 0.38.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.
Files changed (60) hide show
  1. package/dist/specs/encode/duration/mockapi.js +6 -0
  2. package/dist/specs/encode/duration/mockapi.js.map +1 -1
  3. package/dist/specs/special-words/mockapi.js +1 -1
  4. package/dist/specs/special-words/mockapi.js.map +1 -1
  5. package/package.json +17 -16
  6. package/specs/authentication/api-key/main.tsp +2 -1
  7. package/specs/authentication/http/custom/main.tsp +1 -0
  8. package/specs/authentication/oauth2/main.tsp +2 -1
  9. package/specs/authentication/union/main.tsp +2 -1
  10. package/specs/encode/bytes/main.tsp +2 -8
  11. package/specs/encode/datetime/main.tsp +2 -7
  12. package/specs/encode/duration/main.tsp +2 -6
  13. package/specs/encode/duration/mockapi.ts +14 -0
  14. package/specs/encode/numeric/main.tsp +2 -4
  15. package/specs/parameters/basic/main.tsp +2 -5
  16. package/specs/parameters/body-optionality/main.tsp +2 -4
  17. package/specs/parameters/collection-format/main.tsp +2 -5
  18. package/specs/parameters/spread/main.tsp +2 -5
  19. package/specs/payload/json-merge-patch/main.tsp +2 -1
  20. package/specs/payload/media-type/main.tsp +2 -4
  21. package/specs/payload/multipart/main.tsp +2 -1
  22. package/specs/payload/xml/main.tsp +15 -25
  23. package/specs/routes/main.tsp +2 -1
  24. package/specs/serialization/encoded-name/json/main.tsp +2 -2
  25. package/specs/server/endpoint/not-defined/main.tsp +2 -1
  26. package/specs/server/path/multiple/main.tsp +2 -1
  27. package/specs/server/path/single/main.tsp +2 -1
  28. package/specs/server/versions/not-versioned/main.tsp +2 -1
  29. package/specs/server/versions/versioned/main.tsp +2 -3
  30. package/specs/special-headers/conditional-request/main.tsp +2 -2
  31. package/specs/special-headers/repeatability/main.tsp +2 -2
  32. package/specs/special-words/main.tsp +2 -6
  33. package/specs/special-words/mockapi.ts +1 -1
  34. package/specs/type/array/main.tsp +15 -39
  35. package/specs/type/dictionary/main.tsp +15 -36
  36. package/specs/type/enum/extensible/main.tsp +2 -1
  37. package/specs/type/enum/fixed/main.tsp +2 -2
  38. package/specs/type/model/empty/main.tsp +2 -1
  39. package/specs/type/model/inheritance/enum-discriminator/main.tsp +2 -2
  40. package/specs/type/model/inheritance/nested-discriminator/main.tsp +2 -1
  41. package/specs/type/model/inheritance/not-discriminated/main.tsp +2 -1
  42. package/specs/type/model/inheritance/recursive/main.tsp +2 -1
  43. package/specs/type/model/inheritance/single-discriminator/main.tsp +2 -1
  44. package/specs/type/model/templated/main.tsp +2 -2
  45. package/specs/type/model/usage/main.tsp +2 -1
  46. package/specs/type/model/visibility/main.tsp +2 -1
  47. package/specs/type/property/additional-properties/main.tsp +15 -57
  48. package/specs/type/property/nullable/main.tsp +31 -54
  49. package/specs/type/property/optionality/main.tsp +31 -63
  50. package/specs/type/property/value-types/main.tsp +15 -56
  51. package/specs/type/scalar/main.tsp +34 -62
  52. package/specs/type/union/main.tsp +5 -18
  53. package/specs/versioning/added/main.tsp +2 -1
  54. package/specs/versioning/madeOptional/main.tsp +2 -1
  55. package/specs/versioning/removed/main.tsp +2 -1
  56. package/specs/versioning/renamedFrom/main.tsp +2 -1
  57. package/specs/versioning/returnTypeChangedFrom/main.tsp +2 -1
  58. package/specs/versioning/typeChangedFrom/main.tsp +2 -1
  59. package/temp/.tsbuildinfo +1 -1
  60. package/specs/type/property/nullable/client.tsp +0 -21
@@ -2,7 +2,8 @@ import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
  import "@typespec/versioning";
4
4
 
5
- using TypeSpec.Http;
5
+ using Http;
6
+ using SpecLib;
6
7
  using TypeSpec.Versioning;
7
8
 
8
9
  /**
@@ -30,13 +31,11 @@ enum Versions {
30
31
  /**
31
32
  * The version 2022-12-01-preview.
32
33
  */
33
- @useDependency(global.Azure.Core.Versions.v1_0_Preview_2)
34
34
  v2021_01_01_preview: "2021-01-01-preview",
35
35
 
36
36
  /**
37
37
  * The version 2022-12-01-preview.
38
38
  */
39
- @useDependency(global.Azure.Core.Versions.v1_0_Preview_2)
40
39
  v2022_12_01_preview: "2022-12-01-preview",
41
40
  }
42
41
 
@@ -2,11 +2,11 @@ import "@typespec/http";
2
2
  import "@typespec/versioning";
3
3
  import "@typespec/spec-lib";
4
4
 
5
- using TypeSpec.Http;
5
+ using Http;
6
+ using SpecLib;
6
7
  using TypeSpec.Versioning;
7
8
 
8
9
  @doc("Illustrates conditional request headers")
9
- @supportedBy("dpg")
10
10
  @scenarioService("/special-headers/conditional-request")
11
11
  namespace SpecialHeaders.ConditionalRequest;
12
12
 
@@ -2,11 +2,11 @@ import "@typespec/http";
2
2
  import "@typespec/versioning";
3
3
  import "@typespec/spec-lib";
4
4
 
5
- using TypeSpec.Http;
5
+ using Http;
6
+ using SpecLib;
6
7
  using TypeSpec.Versioning;
7
8
 
8
9
  @doc("Illustrates OASIS repeatability headers")
9
- @supportedBy("dpg")
10
10
  @scenarioService("/special-headers/repeatability")
11
11
  namespace SpecialHeaders.Repeatability;
12
12
 
@@ -2,8 +2,8 @@ import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
  import "./dec.js";
4
4
 
5
- using TypeSpec.Http;
6
- using Azure.ClientGenerator.Core;
5
+ using Http;
6
+ using SpecLib;
7
7
 
8
8
  /**
9
9
  * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately.
@@ -52,7 +52,6 @@ namespace SpecialWords;
52
52
  * Test reserved words as operation name.
53
53
  */
54
54
  @route("/operations")
55
- @operationGroup
56
55
  interface Operations {
57
56
  @opNameScenario("and") and(): void;
58
57
  @opNameScenario("as") as(): void;
@@ -93,7 +92,6 @@ interface Operations {
93
92
  * Verify reserved words as parameter name.
94
93
  */
95
94
  @route("/parameters")
96
- @operationGroup
97
95
  interface Parameters {
98
96
  @paramNameScenario("and") withAnd(@query and: string): void;
99
97
  @paramNameScenario("as") withAs(@query as: string): void;
@@ -139,7 +137,6 @@ interface Parameters {
139
137
  * Verify model names
140
138
  */
141
139
  @route("/models")
142
- @operationGroup
143
140
  namespace Models {
144
141
  model Base {
145
142
  name: string;
@@ -217,7 +214,6 @@ namespace Models {
217
214
  * Verify model names
218
215
  */
219
216
  @route("/model-properties")
220
- @operationGroup
221
217
  namespace ModelProperties {
222
218
  model SameAsModel {
223
219
  SameAsModel: string;
@@ -2,7 +2,7 @@ import { MockRequest, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"
2
2
 
3
3
  export const Scenarios: Record<string, ScenarioMockApi> = {};
4
4
 
5
- Scenarios.Special_Words_Model_Properties_Same_As_Model = passOnSuccess({
5
+ Scenarios.SpecialWords_ModelProperties_sameAsModel = passOnSuccess({
6
6
  uri: "/special-words/model-properties/same-as-model",
7
7
  method: "post",
8
8
  request: {
@@ -1,85 +1,67 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
5
- using Azure.ClientGenerator.Core;
4
+ using Http;
5
+ using SpecLib;
6
6
 
7
7
  @doc("Illustrates various types of arrays.")
8
8
  @scenarioService("/type/array")
9
9
  namespace Type.Array;
10
10
 
11
11
  @doc("Template to have Array operations")
12
- interface ArrayOperations<TArr, TDoc extends string> {
12
+ interface ArrayOperations<TArr, TDoc extends valueof string> {
13
13
  @scenario
14
- @scenarioDoc(
15
- """
16
- Expected Array response body:
17
- ```json
18
- {doc}
19
- ```
20
- """,
21
- {
22
- doc: TDoc,
23
- }
24
- )
14
+ @scenarioDoc("""
15
+ Expected Array response body:
16
+ ```json
17
+ ${TDoc}
18
+ ```
19
+ """)
25
20
  @get
26
21
  get(): TArr;
27
22
 
28
23
  @scenario
29
- @scenarioDoc(
30
- """
31
- Expected Array input body:
32
- ```json
33
- {doc}
34
- ```
35
- """,
36
- {
37
- doc: TDoc,
38
- }
39
- )
24
+ @scenarioDoc("""
25
+ Expected Array input body:
26
+ ```json
27
+ ${TDoc}
28
+ ```
29
+ """)
40
30
  @put
41
31
  put(@body body: TArr): void;
42
32
  }
43
33
 
44
34
  @doc("Array of int32 values")
45
35
  @route("/int32")
46
- @operationGroup
47
36
  interface Int32Value extends ArrayOperations<int32[], "[1, 2]"> {}
48
37
 
49
38
  @doc("Array of int64 values")
50
39
  @route("/int64")
51
- @operationGroup
52
40
  interface Int64Value
53
41
  extends ArrayOperations<int64[], "[0x7FFFFFFFFFFFFFFF, -0x7FFFFFFFFFFFFFFF]"> {}
54
42
 
55
43
  @doc("Array of boolean values")
56
44
  @route("/boolean")
57
- @operationGroup
58
45
  interface BooleanValue extends ArrayOperations<boolean[], "[true, false]"> {}
59
46
 
60
47
  @doc("Array of string values")
61
48
  @route("/string")
62
- @operationGroup
63
49
  interface StringValue extends ArrayOperations<string[], "['hello', '']"> {}
64
50
 
65
51
  @doc("Array of float values")
66
52
  @route("/float32")
67
- @operationGroup
68
53
  interface Float32Value extends ArrayOperations<float32[], "[43.125]"> {}
69
54
 
70
55
  @doc("Array of datetime values")
71
56
  @route("/datetime")
72
- @operationGroup
73
57
  interface DatetimeValue extends ArrayOperations<utcDateTime[], "['2022-08-26T18:38:00Z']"> {}
74
58
 
75
59
  @doc("Array of duration values")
76
60
  @route("/duration")
77
- @operationGroup
78
61
  interface DurationValue extends ArrayOperations<duration[], "['P123DT22H14M12.011S']"> {}
79
62
 
80
63
  @doc("Array of unknown values")
81
64
  @route("/unknown")
82
- @operationGroup
83
65
  interface UnknownValue extends ArrayOperations<unknown[], "[1, 'hello', 'k3': null]"> {}
84
66
 
85
67
  @doc("Array inner model")
@@ -92,39 +74,33 @@ model InnerModel {
92
74
 
93
75
  @doc("Array of model values")
94
76
  @route("/model")
95
- @operationGroup
96
77
  interface ModelValue
97
78
  extends ArrayOperations<InnerModel[], "[{'property': 'hello'}, {'property': 'world'}]"> {}
98
79
 
99
80
  alias NullableFloat = float32 | null;
100
81
  @doc("Array of nullable float values")
101
82
  @route("/nullable-float")
102
- @operationGroup
103
83
  interface NullableFloatValue extends ArrayOperations<NullableFloat[], "[1.25, null, 3.0]"> {}
104
84
 
105
85
  alias NullableInt32 = int32 | null;
106
86
  @doc("Array of nullable int32 values")
107
87
  @route("/nullable-int32")
108
- @operationGroup
109
88
  interface NullableInt32Value extends ArrayOperations<NullableInt32[], "[1, null, 3]"> {}
110
89
 
111
90
  alias NullableBoolean = boolean | null;
112
91
  @doc("Array of nullable boolean values")
113
92
  @route("/nullable-boolean")
114
- @operationGroup
115
93
  interface NullableBooleanValue extends ArrayOperations<NullableBoolean[], "[true, null, false]"> {}
116
94
 
117
95
  alias NullableString = string | null;
118
96
  @doc("Array of nullable string values")
119
97
  @route("/nullable-string")
120
- @operationGroup
121
98
  interface NullableStringValue
122
99
  extends ArrayOperations<NullableString[], "['hello', null, 'world']"> {}
123
100
 
124
101
  alias NullableModel = InnerModel | null;
125
102
  @doc("Array of nullable model values")
126
103
  @route("/nullable-model")
127
- @operationGroup
128
104
  interface NullableModelValue
129
105
  extends ArrayOperations<
130
106
  NullableModel[],
@@ -1,54 +1,42 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
5
- using Azure.ClientGenerator.Core;
4
+ using Http;
5
+ using SpecLib;
6
6
 
7
7
  @doc("Illustrates various of dictionaries.")
8
8
  @scenarioService("/type/dictionary")
9
9
  namespace Type.Dictionary;
10
10
 
11
11
  @doc("Template to have dictionary operations")
12
- interface DictionaryOperations<TDict, TDoc extends string> {
12
+ interface DictionaryOperations<TDict, TDoc extends valueof string> {
13
13
  @scenario
14
- @scenarioDoc(
15
- """
16
- Expected dictionary response body:
17
- ```json
18
- {doc}
19
- ```
20
- """,
21
- {
22
- doc: TDoc,
23
- }
24
- )
14
+ @scenarioDoc("""
15
+ Expected dictionary response body:
16
+ ```json
17
+ ${TDoc}
18
+ ```
19
+ """)
25
20
  @get
26
21
  get(): TDict;
27
22
 
28
23
  @scenario
29
- @scenarioDoc(
30
- """
31
- Expected dictionary input body:
32
- ```json
33
- {doc}
34
- ```
35
- """,
36
- {
37
- doc: TDoc,
38
- }
39
- )
24
+ @scenarioDoc("""
25
+ Expected dictionary input body:
26
+ ```json
27
+ ${TDoc}
28
+ ```
29
+ """)
40
30
  @put
41
31
  put(@body body: TDict): void;
42
32
  }
43
33
 
44
34
  @doc("Dictionary of int32 values")
45
35
  @route("/int32")
46
- @operationGroup
47
36
  interface Int32Value extends DictionaryOperations<Record<int32>, "{'k1': 1, 'k2': 2}"> {}
48
37
 
49
38
  @doc("Dictionary of int64 values")
50
39
  @route("/int64")
51
- @operationGroup
52
40
  interface Int64Value
53
41
  extends DictionaryOperations<
54
42
  Record<int64>,
@@ -57,34 +45,28 @@ interface Int64Value
57
45
 
58
46
  @doc("Dictionary of boolean values")
59
47
  @route("/boolean")
60
- @operationGroup
61
48
  interface BooleanValue extends DictionaryOperations<Record<boolean>, "{'k1': true, 'k2': false}"> {}
62
49
 
63
50
  @doc("Dictionary of string values")
64
51
  @route("/string")
65
- @operationGroup
66
52
  interface StringValue extends DictionaryOperations<Record<string>, "{'k1': 'hello', 'k2': ''}"> {}
67
53
 
68
54
  @doc("Dictionary of float values")
69
55
  @route("/float32")
70
- @operationGroup
71
56
  interface Float32Value extends DictionaryOperations<Record<float32>, "{'k1': 43.125}"> {}
72
57
 
73
58
  @doc("Dictionary of datetime values")
74
59
  @route("/datetime")
75
- @operationGroup
76
60
  interface DatetimeValue
77
61
  extends DictionaryOperations<Record<utcDateTime>, "{'k1': '2022-08-26T18:38:00Z'}"> {}
78
62
 
79
63
  @doc("Dictionary of duration values")
80
64
  @route("/duration")
81
- @operationGroup
82
65
  interface DurationValue
83
66
  extends DictionaryOperations<Record<duration>, "{'k1': 'P123DT22H14M12.011S'}"> {}
84
67
 
85
68
  @doc("Dictionary of unknown values")
86
69
  @route("/unknown")
87
- @operationGroup
88
70
  interface UnknownValue
89
71
  extends DictionaryOperations<Record<unknown>, "{'k1': 1, 'k2': 'hello', 'k3': null}"> {}
90
72
 
@@ -98,7 +80,6 @@ model InnerModel {
98
80
 
99
81
  @doc("Dictionary of model values")
100
82
  @route("/model")
101
- @operationGroup
102
83
  interface ModelValue
103
84
  extends DictionaryOperations<
104
85
  Record<InnerModel>,
@@ -107,7 +88,6 @@ interface ModelValue
107
88
 
108
89
  @doc("Dictionary of model values")
109
90
  @route("/model/recursive")
110
- @operationGroup
111
91
  interface RecursiveModelValue
112
92
  extends DictionaryOperations<
113
93
  Record<InnerModel>,
@@ -117,6 +97,5 @@ interface RecursiveModelValue
117
97
  alias NullableFloat = float32 | null;
118
98
  @doc("Dictionary of nullable float values")
119
99
  @route("/nullable-float")
120
- @operationGroup
121
100
  interface NullableFloatValue
122
101
  extends DictionaryOperations<Record<NullableFloat>, "{'k1': 1.25, 'k2': 0.5, 'k3': null}"> {}
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  @scenarioService("/type/enum/extensible")
7
8
  namespace Type.Enum.Extensible;
@@ -1,8 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using Azure.Core;
5
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
6
6
 
7
7
  @scenarioService("/type/enum/fixed")
8
8
  namespace Type.Enum.Fixed;
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  @doc("Illustrates usage of empty model used in operation's parameters and responses.")
7
8
  @scenarioService("/type/model/empty")
@@ -1,8 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
5
- using Azure.Core;
4
+ using Http;
5
+ using SpecLib;
6
6
 
7
7
  @doc("Illustrates inheritance with enum discriminator.")
8
8
  @scenarioService("/type/model/inheritance/enum-discriminator")
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  @doc("Illustrates multiple level inheritance with multiple discriminators.")
7
8
  @scenarioService("/type/model/inheritance/nested-discriminator")
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  @doc("Illustrates not-discriminated inheritance model.")
7
8
  @scenarioService("/type/model/inheritance/not-discriminated")
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  @doc("Illustrates inheritance recursion")
7
8
  @scenarioService("/type/model/inheritance/recursive")
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  @doc("Illustrates inheritance with single discriminator.")
7
8
  @scenarioService("/type/model/inheritance/single-discriminator")
@@ -1,8 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
5
- using Azure.ClientGenerator.Core;
4
+ using Http;
5
+ using SpecLib;
6
6
 
7
7
  /**
8
8
  * Illustrates the model templated cases. There is a base templated type and an instantiated type extending from it.
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  /**
7
8
  * Those tests are meant to test different behavior of records if they are used as input, output or both.
@@ -1,7 +1,8 @@
1
1
  import "@typespec/http";
2
2
  import "@typespec/spec-lib";
3
3
 
4
- using TypeSpec.Http;
4
+ using Http;
5
+ using SpecLib;
5
6
 
6
7
  @doc("Illustrates models with visibility properties.")
7
8
  @scenarioService("/type/model/visibility")