@typespec/json-schema 0.68.0-dev.3 → 0.68.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 CHANGED
@@ -131,7 +131,7 @@ Set the base URI for any schemas emitted from types within this namespace.
131
131
 
132
132
  | Name | Type | Description |
133
133
  | ------- | ---------------- | ------------------------------------------------------------------------ |
134
- | baseUri | `valueof string` | the base URI. Schema IDs inside this namespace are relative to this URI. |
134
+ | baseUri | `valueof string` | The base URI. Schema IDs inside this namespace are relative to this URI. |
135
135
 
136
136
  #### `@contains`
137
137
 
@@ -186,7 +186,7 @@ Specify the content type of content stored in a string.
186
186
 
187
187
  | Name | Type | Description |
188
188
  | ----- | ---------------- | ------------------------------------- |
189
- | value | `valueof string` | the media type of the string contents |
189
+ | value | `valueof string` | The media type of the string contents |
190
190
 
191
191
  #### `@contentSchema`
192
192
 
@@ -205,11 +205,11 @@ media type and encoding.
205
205
 
206
206
  | Name | Type | Description |
207
207
  | ----- | --------- | --------------------------------- |
208
- | value | `unknown` | the schema of the string contents |
208
+ | value | `unknown` | The schema of the string contents |
209
209
 
210
210
  #### `@extension`
211
211
 
212
- Specify a custom property to add to the emitted schema. Useful for adding custom keywords
212
+ Specify a custom property to add to the emitted schema. This is useful for adding custom keywords
213
213
  and other vendor-specific extensions. Scalar values need to be specified using `typeof` to be converted to a schema.
214
214
 
215
215
  For example, `@extension("x-schema", typeof "foo")` will emit a JSON schema value for `x-schema`,
@@ -217,9 +217,9 @@ whereas `@extension("x-schema", "foo")` will emit the raw code `"foo"`.
217
217
 
218
218
  The value will be treated as a raw value if any of the following are true:
219
219
 
220
- 1. The value is a scalar value (e.g. string, number, boolean, etc.)
221
- 2. The value is wrapped in the `Json<Data>` template
222
- 3. The value is provided using the value syntax (e.g. `#{}`, `#[]`)
220
+ - The value is a scalar value (e.g. string, number, boolean, etc.)
221
+ - The value is wrapped in the `Json<Data>` template
222
+ - The value is provided using the value syntax (e.g. `#{}`, `#[]`)
223
223
 
224
224
  For example, `@extension("x-schema", { x: "value" })` will emit a JSON schema value for `x-schema`,
225
225
  whereas `@extension("x-schema", #{x: "value"})` and `@extension("x-schema", Json<{x: "value"}>)`
@@ -237,8 +237,8 @@ will emit the raw JSON code `{x: "value"}`.
237
237
 
238
238
  | Name | Type | Description |
239
239
  | ----- | ------------------------------ | ------------------------------------------------------------- |
240
- | key | `valueof string` | the name of the keyword of vendor extension, e.g. `x-custom`. |
241
- | value | `unknown` \| `valueof unknown` | the value of the keyword. |
240
+ | key | `valueof string` | The name of the keyword of vendor extension, e.g. `x-custom`. |
241
+ | value | `unknown` \| `valueof unknown` | The value of the keyword. |
242
242
 
243
243
  #### `@id`
244
244
 
@@ -259,7 +259,7 @@ By default, the id will be constructed based on the declaration's name.
259
259
 
260
260
  | Name | Type | Description |
261
261
  | ---- | ---------------- | ----------------------------------------------- |
262
- | id | `valueof string` | the id of the JSON schema for this declaration. |
262
+ | id | `valueof string` | The id of the JSON schema for this declaration. |
263
263
 
264
264
  #### `@jsonSchema`
265
265
 
@@ -285,8 +285,8 @@ you can provide the id.
285
285
 
286
286
  #### `@maxContains`
287
287
 
288
- Specify that the array must contain at most some number of the types provided
289
- by the contains decorator.
288
+ Used in conjunction with the `@contains` decorator,
289
+ specifies that the array must contain at most a certain number of the types provided by the `@contains` decorator.
290
290
 
291
291
  ```typespec
292
292
  @TypeSpec.JsonSchema.maxContains(value: valueof int32)
@@ -322,8 +322,8 @@ Specify the maximum number of properties this object can have.
322
322
 
323
323
  #### `@minContains`
324
324
 
325
- Specify that the array must contain at least some number of the types provided
326
- by the contains decorator.
325
+ Used in conjunction with the `@contains` decorator,
326
+ specifies that the array must contain at least a certain number of the types provided by the `@contains` decorator.
327
327
 
328
328
  ```typespec
329
329
  @TypeSpec.JsonSchema.minContains(value: valueof int32)
@@ -407,7 +407,7 @@ Specify that the target array must begin with the provided types.
407
407
 
408
408
  | Name | Type | Description |
409
409
  | ----- | ----------- | --------------------------------------------------------------------------- |
410
- | value | `unknown[]` | a tuple containing the types that must be present at the start of the array |
410
+ | value | `unknown[]` | A tuple containing the types that must be present at the start of the array |
411
411
 
412
412
  #### `@uniqueItems`
413
413
 
@@ -12,7 +12,7 @@ export type JsonSchemaDecorator = (context: DecoratorContext, target: Type, base
12
12
  /**
13
13
  * Set the base URI for any schemas emitted from types within this namespace.
14
14
  *
15
- * @param baseUri the base URI. Schema IDs inside this namespace are relative to this URI.
15
+ * @param baseUri The base URI. Schema IDs inside this namespace are relative to this URI.
16
16
  */
17
17
  export type BaseUriDecorator = (context: DecoratorContext, target: Namespace, baseUri: string) => void;
18
18
  /**
@@ -21,7 +21,7 @@ export type BaseUriDecorator = (context: DecoratorContext, target: Namespace, ba
21
21
  *
22
22
  * By default, the id will be constructed based on the declaration's name.
23
23
  *
24
- * @param id the id of the JSON schema for this declaration.
24
+ * @param id The id of the JSON schema for this declaration.
25
25
  */
26
26
  export type IdDecorator = (context: DecoratorContext, target: Type, id: string) => void;
27
27
  /**
@@ -42,15 +42,15 @@ export type MultipleOfDecorator = (context: DecoratorContext, target: Scalar | M
42
42
  */
43
43
  export type ContainsDecorator = (context: DecoratorContext, target: Type | ModelProperty, value: Type) => void;
44
44
  /**
45
- * Specify that the array must contain at least some number of the types provided
46
- * by the contains decorator.
45
+ * Used in conjunction with the `@contains` decorator,
46
+ * specifies that the array must contain at least a certain number of the types provided by the `@contains` decorator.
47
47
  *
48
48
  * @param value The minimum number of instances the array must contain
49
49
  */
50
50
  export type MinContainsDecorator = (context: DecoratorContext, target: Type | ModelProperty, value: number) => void;
51
51
  /**
52
- * Specify that the array must contain at most some number of the types provided
53
- * by the contains decorator.
52
+ * Used in conjunction with the `@contains` decorator,
53
+ * specifies that the array must contain at most a certain number of the types provided by the `@contains` decorator.
54
54
  *
55
55
  * @param value The maximum number of instances the array must contain
56
56
  */
@@ -82,40 +82,40 @@ export type ContentEncodingDecorator = (context: DecoratorContext, target: Scala
82
82
  /**
83
83
  * Specify that the target array must begin with the provided types.
84
84
  *
85
- * @param value a tuple containing the types that must be present at the start of the array
85
+ * @param value A tuple containing the types that must be present at the start of the array
86
86
  */
87
87
  export type PrefixItemsDecorator = (context: DecoratorContext, target: Type | ModelProperty, value: Type) => void;
88
88
  /**
89
89
  * Specify the content type of content stored in a string.
90
90
  *
91
- * @param value the media type of the string contents
91
+ * @param value The media type of the string contents
92
92
  */
93
93
  export type ContentMediaTypeDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: string) => void;
94
94
  /**
95
95
  * Specify the schema for the contents of a string when interpreted according to the content's
96
96
  * media type and encoding.
97
97
  *
98
- * @param value the schema of the string contents
98
+ * @param value The schema of the string contents
99
99
  */
100
100
  export type ContentSchemaDecorator = (context: DecoratorContext, target: Scalar | ModelProperty, value: Type) => void;
101
101
  /**
102
- * Specify a custom property to add to the emitted schema. Useful for adding custom keywords
102
+ * Specify a custom property to add to the emitted schema. This is useful for adding custom keywords
103
103
  * and other vendor-specific extensions. Scalar values need to be specified using `typeof` to be converted to a schema.
104
104
  *
105
105
  * For example, `@extension("x-schema", typeof "foo")` will emit a JSON schema value for `x-schema`,
106
106
  * whereas `@extension("x-schema", "foo")` will emit the raw code `"foo"`.
107
107
  *
108
108
  * The value will be treated as a raw value if any of the following are true:
109
- * 1. The value is a scalar value (e.g. string, number, boolean, etc.)
110
- * 2. The value is wrapped in the `Json<Data>` template
111
- * 3. The value is provided using the value syntax (e.g. `#{}`, `#[]`)
109
+ * - The value is a scalar value (e.g. string, number, boolean, etc.)
110
+ * - The value is wrapped in the `Json<Data>` template
111
+ * - The value is provided using the value syntax (e.g. `#{}`, `#[]`)
112
112
  *
113
113
  * For example, `@extension("x-schema", { x: "value" })` will emit a JSON schema value for `x-schema`,
114
114
  * whereas `@extension("x-schema", #{x: "value"})` and `@extension("x-schema", Json<{x: "value"}>)`
115
115
  * will emit the raw JSON code `{x: "value"}`.
116
116
  *
117
- * @param key the name of the keyword of vendor extension, e.g. `x-custom`.
118
- * @param value the value of the keyword.
117
+ * @param key The name of the keyword of vendor extension, e.g. `x-custom`.
118
+ * @param value The value of the keyword.
119
119
  */
120
120
  export type ExtensionDecorator = (context: DecoratorContext, target: Type, key: string, value: Type | unknown) => void;
121
121
  export type TypeSpecJsonSchemaDecorators = {
package/dist/src/lib.d.ts CHANGED
@@ -20,14 +20,14 @@ export interface JSONSchemaEmitterOptions {
20
20
  */
21
21
  "file-type"?: FileType;
22
22
  /**
23
- * How to handle 64 bit integers on the wire. Options are:
23
+ * How to handle 64-bit integers on the wire. Options are:
24
24
  *
25
- * * string: serialize as a string (widely interoperable)
26
- * * number: serialize as a number (not widely interoperable)
25
+ * - string: Serialize as a string (widely interoperable)
26
+ * - number: Serialize as a number (not widely interoperable)
27
27
  */
28
28
  "int64-strategy"?: Int64Strategy;
29
29
  /**
30
- * When provided, bundle all the schemas into a single json schema document
30
+ * When provided, bundle all the schemas into a single JSON Schema document
31
31
  * with schemas under $defs. The provided id is the id of the root document
32
32
  * and is also used for the file name.
33
33
  */
@@ -38,7 +38,7 @@ export interface JSONSchemaEmitterOptions {
38
38
  */
39
39
  emitAllModels?: boolean;
40
40
  /**
41
- * When true, emit all references as json schema files, even if the referenced
41
+ * When true, emit all references as JSON Schema files, even if the referenced
42
42
  * type does not have the `@jsonSchema` decorator or is not within a namespace
43
43
  * with the `@jsonSchema` decorator.
44
44
  */
package/lib/main.tsp CHANGED
@@ -16,7 +16,7 @@ extern dec jsonSchema(target: unknown, baseUri?: valueof string);
16
16
  /**
17
17
  * Set the base URI for any schemas emitted from types within this namespace.
18
18
  *
19
- * @param baseUri the base URI. Schema IDs inside this namespace are relative to this URI.
19
+ * @param baseUri The base URI. Schema IDs inside this namespace are relative to this URI.
20
20
  */
21
21
  extern dec baseUri(target: Reflection.Namespace, baseUri: valueof string);
22
22
 
@@ -26,7 +26,7 @@ extern dec baseUri(target: Reflection.Namespace, baseUri: valueof string);
26
26
  *
27
27
  * By default, the id will be constructed based on the declaration's name.
28
28
  *
29
- * @param id the id of the JSON schema for this declaration.
29
+ * @param id The id of the JSON schema for this declaration.
30
30
  */
31
31
  extern dec id(target: unknown, id: valueof string);
32
32
 
@@ -51,16 +51,16 @@ extern dec multipleOf(target: numeric | Reflection.ModelProperty, value: valueof
51
51
  extern dec contains(target: unknown[] | Reflection.ModelProperty, value: unknown);
52
52
 
53
53
  /**
54
- * Specify that the array must contain at least some number of the types provided
55
- * by the contains decorator.
54
+ * Used in conjunction with the `@contains` decorator,
55
+ * specifies that the array must contain at least a certain number of the types provided by the `@contains` decorator.
56
56
  *
57
57
  * @param value The minimum number of instances the array must contain
58
58
  */
59
59
  extern dec minContains(target: unknown[] | Reflection.ModelProperty, value: valueof int32);
60
60
 
61
61
  /**
62
- * Specify that the array must contain at most some number of the types provided
63
- * by the contains decorator.
62
+ * Used in conjunction with the `@contains` decorator,
63
+ * specifies that the array must contain at most a certain number of the types provided by the `@contains` decorator.
64
64
  *
65
65
  * @param value The maximum number of instances the array must contain
66
66
  */
@@ -94,14 +94,14 @@ extern dec contentEncoding(target: string | Reflection.ModelProperty, value: val
94
94
  /**
95
95
  * Specify that the target array must begin with the provided types.
96
96
  *
97
- * @param value a tuple containing the types that must be present at the start of the array
97
+ * @param value A tuple containing the types that must be present at the start of the array
98
98
  */
99
99
  extern dec prefixItems(target: unknown[] | Reflection.ModelProperty, value: unknown[]);
100
100
 
101
101
  /**
102
102
  * Specify the content type of content stored in a string.
103
103
  *
104
- * @param value the media type of the string contents
104
+ * @param value The media type of the string contents
105
105
  *
106
106
  */
107
107
  extern dec contentMediaType(target: string | Reflection.ModelProperty, value: valueof string);
@@ -110,28 +110,28 @@ extern dec contentMediaType(target: string | Reflection.ModelProperty, value: va
110
110
  * Specify the schema for the contents of a string when interpreted according to the content's
111
111
  * media type and encoding.
112
112
  *
113
- * @param value the schema of the string contents
113
+ * @param value The schema of the string contents
114
114
  */
115
115
  extern dec contentSchema(target: string | Reflection.ModelProperty, value: unknown);
116
116
 
117
117
  /**
118
- * Specify a custom property to add to the emitted schema. Useful for adding custom keywords
118
+ * Specify a custom property to add to the emitted schema. This is useful for adding custom keywords
119
119
  * and other vendor-specific extensions. Scalar values need to be specified using `typeof` to be converted to a schema.
120
120
  *
121
121
  * For example, `@extension("x-schema", typeof "foo")` will emit a JSON schema value for `x-schema`,
122
122
  * whereas `@extension("x-schema", "foo")` will emit the raw code `"foo"`.
123
123
  *
124
124
  * The value will be treated as a raw value if any of the following are true:
125
- * 1. The value is a scalar value (e.g. string, number, boolean, etc.)
126
- * 2. The value is wrapped in the `Json<Data>` template
127
- * 3. The value is provided using the value syntax (e.g. `#{}`, `#[]`)
125
+ * - The value is a scalar value (e.g. string, number, boolean, etc.)
126
+ * - The value is wrapped in the `Json<Data>` template
127
+ * - The value is provided using the value syntax (e.g. `#{}`, `#[]`)
128
128
 
129
129
  * For example, `@extension("x-schema", { x: "value" })` will emit a JSON schema value for `x-schema`,
130
130
  * whereas `@extension("x-schema", #{x: "value"})` and `@extension("x-schema", Json<{x: "value"}>)`
131
131
  * will emit the raw JSON code `{x: "value"}`.
132
132
  *
133
- * @param key the name of the keyword of vendor extension, e.g. `x-custom`.
134
- * @param value the value of the keyword.
133
+ * @param key The name of the keyword of vendor extension, e.g. `x-custom`.
134
+ * @param value The value of the keyword.
135
135
  */
136
136
  extern dec extension(target: unknown, key: valueof string, value: (valueof unknown) | unknown);
137
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/json-schema",
3
- "version": "0.68.0-dev.3",
3
+ "version": "0.68.0-dev.4",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec library for emitting TypeSpec to JSON Schema and converting JSON Schema to TypeSpec",
6
6
  "homepage": "https://github.com/microsoft/typespec",
@@ -40,11 +40,11 @@
40
40
  "!dist/test/**"
41
41
  ],
42
42
  "peerDependencies": {
43
- "@typespec/compiler": "^0.67.1 || >=0.68.0-dev <0.68.0"
43
+ "@typespec/compiler": "^0.67.2 || >=0.68.0-dev <0.68.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "~22.13.11",
47
- "@typespec/compiler": "^0.67.1 || >=0.68.0-dev <0.68.0",
47
+ "@typespec/compiler": "^0.67.2 || >=0.68.0-dev <0.68.0",
48
48
  "@typespec/internal-build-utils": "^0.67.1 || >=0.68.0-dev <0.68.0",
49
49
  "@typespec/library-linter": "^0.67.1 || >=0.68.0-dev <0.68.0",
50
50
  "@vitest/coverage-v8": "^3.0.9",