Skip to content

Commit a9dfcf7

Browse files
committed
TypeSpec: new parser
1 parent fc82393 commit a9dfcf7

File tree

8 files changed

+809
-0
lines changed

8 files changed

+809
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sort=no
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Name.Space input.tsp /^namespace Name.Space;$/;" n
2+
Versions input.tsp /^enum Versions {$/;" g
3+
OpA input.tsp /^op OpA<T extends TypeSpec.Reflection.Model> is OpB<$/;" o
4+
InterfaceA input.tsp /^interface InterfaceA extends InterfaceB {$/;" i
5+
opA input.tsp /^ opA is OpA<{$/;" p interface:InterfaceA
6+
opB input.tsp /^ opB: url;$/;" p interface:InterfaceA
7+
UnionA input.tsp /^union UnionA {$/;" u
8+
ModelA input.tsp /^model ModelA {$/;" m
9+
contentA input.tsp /^ contentA: ModelB;$/;" p model:ModelA
10+
contentB input.tsp /^ contentB?: boolean;$/;" p model:ModelA
11+
AliasA input.tsp /^alias AliasA<$/;" a
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import "@typespec/http";
2+
import "./common.tsp";
3+
4+
using TypeSpec;
5+
using TypeSpec.Rest;
6+
7+
@armProviderNamespace
8+
@service(#{ title: "Name.Space" })
9+
@versioned(Versions)
10+
@armCommonTypesVersion(CommonTypes.Versions.v3)
11+
namespace Name.Space;
12+
13+
@doc("API Versions")
14+
enum Versions {
15+
@doc("May 01, 2024 Preview API Version")
16+
v2024_05_01_preview: "2024-05-01-preview",
17+
}
18+
19+
@summary("Example operation summary for demonstration purposes.")
20+
@doc("""
21+
Example
22+
multi-line
23+
documentation.
24+
""")
25+
@returnsDoc("Example return documentation")
26+
@post
27+
op OpA<T extends TypeSpec.Reflection.Model> is OpB<
28+
T & ModelA,
29+
ModelB<ModelA[]>
30+
>;
31+
32+
interface InterfaceA extends InterfaceB {
33+
opA is OpA<{
34+
@doc("The format of the HTTP payload.")
35+
@header
36+
contentType: "application/json";
37+
38+
@clientName("uri", "csharp")
39+
@doc("Example URL parameter.")
40+
opB: url;
41+
}>;
42+
43+
/**
44+
* Example operation description
45+
*/
46+
opB is OpB<
47+
ModelA,
48+
{
49+
...ModelB
50+
}
51+
>;
52+
}
53+
54+
@doc("Example union type description.")
55+
union UnionA {
56+
string,
57+
58+
@doc("Example option A description with some technical details that would be typical for this kind of documentation.")
59+
"unionA",
60+
61+
@doc("Example option B description with additional technical context that would be common in API documentation.")
62+
"unionB",
63+
}
64+
65+
@doc("Example model description.")
66+
model ModelA {
67+
@doc("Example property description.")
68+
contentA: ModelB;
69+
70+
@removed(Versions.v1_2)
71+
@doc("Example boolean property with typical documentation about its purpose and default behavior.")
72+
contentB?: boolean;
73+
74+
...ModelX;
75+
}
76+
77+
78+
alias AliasA<
79+
TParamA extends ModelX,
80+
TParamB,
81+
TParamC extends ModelX = {},
82+
TError = Error
83+
> = ModelB<TParamA, TParamB, TParamC, TError>;

main/parsers_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
TTCNParser, \
189189
Txt2tagsParser, \
190190
TypeScriptParser, \
191+
TypeSpecParser, \
191192
VParser, \
192193
VeraParser, \
193194
VerilogParser, \

0 commit comments

Comments
 (0)