@@ -39,25 +39,7 @@ dec discriminator(target: Model | Union, propertyName: string)
39
39
#### Parameters
40
40
| Name | Type | Description |
41
41
| ------| ------| -------------|
42
- | propertyName | ` scalar string ` | |
43
-
44
- #### Examples
45
-
46
- ``` typespec
47
- @discriminator("kind")
48
- union Pet{ cat: Cat, dog: Dog }
49
-
50
- model Cat {kind: "cat", meow: boolean}
51
- model Dog {kind: "dog", bark: boolean}
52
- ```
53
-
54
- ``` typespec
55
- @discriminator("kind")
56
- model Pet{ kind: string }
57
-
58
- model Cat extends Pet {kind: "cat", meow: boolean}
59
- model Dog extends Pet {kind: "dog", bark: boolean}
60
- ```
42
+ | propertyName | ` scalar string ` | The property name to use for discrimination |
61
43
62
44
63
45
### ` @doc ` {#@doc }
@@ -141,11 +123,12 @@ dec friendlyName(target: unknown, name: string, formatArgs?: unknown)
141
123
| Name | Type | Description |
142
124
| ------| ------| -------------|
143
125
| name | ` scalar string ` | name the template instance should take |
144
- | formatArgs | ` (intrinsic) unknown ` | |
126
+ | formatArgs | ` (intrinsic) unknown ` | Model with key value used to interpolate the name |
145
127
146
128
147
129
### ` @inspectType ` {#@inspectType }
148
130
131
+ A debugging decorator used to inspect a type.
149
132
150
133
``` typespec
151
134
dec inspectType(target: unknown, text: string)
@@ -158,11 +141,12 @@ dec inspectType(target: unknown, text: string)
158
141
#### Parameters
159
142
| Name | Type | Description |
160
143
| ------| ------| -------------|
161
- | text | ` scalar string ` | |
144
+ | text | ` scalar string ` | Custom text to log |
162
145
163
146
164
147
### ` @inspectTypeName ` {#@inspectTypeName }
165
148
149
+ A debugging decorator used to inspect a type name.
166
150
167
151
``` typespec
168
152
dec inspectTypeName(target: unknown, text: string)
@@ -175,7 +159,7 @@ dec inspectTypeName(target: unknown, text: string)
175
159
#### Parameters
176
160
| Name | Type | Description |
177
161
| ------| ------| -------------|
178
- | text | ` scalar string ` | |
162
+ | text | ` scalar string ` | Custom text to log |
179
163
180
164
181
165
### ` @key ` {#@key }
@@ -193,15 +177,7 @@ dec key(target: ModelProperty, altName?: string)
193
177
#### Parameters
194
178
| Name | Type | Description |
195
179
| ------| ------| -------------|
196
- | altName | ` scalar string ` | |
197
-
198
- #### Examples
199
-
200
- ``` typespec
201
- model Pet {
202
- @key id: string;
203
- }
204
- ```
180
+ | altName | ` scalar string ` | Name of the property. If not specified, the decorated property name is used. |
205
181
206
182
207
183
### ` @knownValues ` {#@knownValues }
@@ -531,24 +507,12 @@ dec visibility(target: ModelProperty, ...visibilities: string[])
531
507
#### Parameters
532
508
| Name | Type | Description |
533
509
| ------| ------| -------------|
534
- | visibilities | ` model string[] ` | |
535
-
536
- #### Examples
537
-
538
- ``` typespec
539
- model Dog {
540
- // the service will generate an ID, so you don't need to send it.
541
- @visibility("read") id: int32;
542
- // the service will store this secret name, but won't ever return it
543
- @visibility("create", "update") secretName: string;
544
- // the regular name is always present
545
- name: string;
546
- }
547
- ```
510
+ | visibilities | ` model string[] ` | List of visibilities which apply to this property. |
548
511
549
512
550
513
### ` @withDefaultKeyVisibility ` {#@withDefaultKeyVisibility }
551
514
515
+ Set the visibility of key properties in a model if not already set.
552
516
553
517
``` typespec
554
518
dec withDefaultKeyVisibility(target: Model, visibility: unknown)
@@ -561,11 +525,12 @@ dec withDefaultKeyVisibility(target: Model, visibility: unknown)
561
525
#### Parameters
562
526
| Name | Type | Description |
563
527
| ------| ------| -------------|
564
- | visibility | ` (intrinsic) unknown ` | |
528
+ | visibility | ` (intrinsic) unknown ` | The desired default visibility value. If a key property already has a ` visibility ` decorator then the default visibility is not applied. |
565
529
566
530
567
531
### ` @withoutDefaultValues ` {#@withoutDefaultValues }
568
532
533
+ Returns the model with any default values removed.
569
534
570
535
``` typespec
571
536
dec withoutDefaultValues(target: Model)
581
546
582
547
### ` @withoutOmittedProperties ` {#@withoutOmittedProperties }
583
548
549
+ Returns the model with the given properties omitted.
584
550
585
551
``` typespec
586
552
dec withoutOmittedProperties(target: Model, omit: string | Union)
@@ -593,11 +559,12 @@ dec withoutOmittedProperties(target: Model, omit: string | Union)
593
559
#### Parameters
594
560
| Name | Type | Description |
595
561
| ------| ------| -------------|
596
- | omit | ` union string \| Union ` | |
562
+ | omit | ` union string \| Union ` | List of properties to omit |
597
563
598
564
599
565
### ` @withUpdateableProperties ` {#@withUpdateableProperties }
600
566
567
+ Returns the model with non-updateable properties removed.
601
568
602
569
``` typespec
603
570
dec withUpdateableProperties(target: Model)
@@ -634,34 +601,6 @@ dec withVisibility(target: Model, ...visibilities: string[])
634
601
#### Parameters
635
602
| Name | Type | Description |
636
603
| ------| ------| -------------|
637
- | visibilities | ` model string[] ` | |
638
-
639
- #### Examples
640
-
641
- ``` typespec
642
- model Dog {
643
- @visibility("read") id: int32;
644
- @visibility("create", "update") secretName: string;
645
- name: string;
646
- }
647
-
648
- // The spread operator will copy all the properties of Dog into DogRead,
649
- // and @withVisibility will then remove those that are not visible with
650
- // create or update visibility.
651
- //
652
- // In this case, the id property is removed, and the name and secretName
653
- // properties are kept.
654
- @withVisibility("create", "update")
655
- model DogCreateOrUpdate {
656
- ...Dog;
657
- }
658
-
659
- // In this case the id and name properties are kept and the secretName property
660
- // is removed.
661
- @withVisibility("read")
662
- model DogRead {
663
- ...Dog;
664
- }
665
- ```
604
+ | visibilities | ` model string[] ` | List of visibilities which apply to this property. |
666
605
667
606
0 commit comments