-
Notifications
You must be signed in to change notification settings - Fork 635
TypeSpec: new parser #4243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
TypeSpec: new parser #4243
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Name.Space input.tsp /^namespace Name.Space;$/;" n | ||
Inner input.tsp /^namespace Inner {$/;" n namespace:Name.Space | ||
Versions input.tsp /^ enum Versions {$/;" g namespace:Name.Space.Inner | ||
OpA input.tsp /^ op OpA<T extends TypeSpec.Reflection.Model> is OpB<$/;" o namespace:Name.Space.Inner | ||
InterfaceA input.tsp /^ interface InterfaceA extends InterfaceB {$/;" i namespace:Name.Space.Inner | ||
opA input.tsp /^ opA is OpA<{$/;" p interface:Name.Space.Inner.InterfaceA | ||
opB input.tsp /^ opB is OpB<$/;" p interface:Name.Space.Inner.InterfaceA | ||
UnionA input.tsp /^ union UnionA {$/;" u namespace:Name.Space.Inner | ||
ModelA input.tsp /^model ModelA {$/;" m namespace:Name.Space | ||
contentA input.tsp /^ contentA: ModelB;$/;" p model:Name.Space.ModelA | ||
contentB input.tsp /^ contentB?: boolean;$/;" p model:Name.Space.ModelA | ||
ModelB input.tsp /^model ModelB extends ModelA {$/;" m namespace:Name.Space | ||
AliasA input.tsp /^alias AliasA<$/;" a namespace:Name.Space |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import "@typespec/http"; | ||
import "./common.tsp"; | ||
|
||
using TypeSpec; | ||
using TypeSpec.Rest; | ||
|
||
@armProviderNamespace | ||
@service(#{ title: "Name.Space" }) | ||
@versioned(Versions) | ||
@armCommonTypesVersion(CommonTypes.Versions.v3) | ||
namespace Name.Space; | ||
|
||
namespace Inner { | ||
@doc("API Versions") | ||
@added(a()) | ||
enum Versions { | ||
@doc("May 01, 2024 Preview API Version") | ||
v2024_05_01_preview: "2024-05-01-preview", | ||
} | ||
|
||
@summary("Example operation summary for demonstration purposes.") | ||
@doc(""" | ||
Example | ||
multi-line | ||
documentation. | ||
""") | ||
@returnsDoc("Example return documentation") | ||
@post | ||
op OpA<T extends TypeSpec.Reflection.Model> is OpB< | ||
T & ModelA, | ||
ModelB<ModelA[]> | ||
>; | ||
|
||
// single line comment | ||
interface InterfaceA extends InterfaceB { | ||
opA is OpA<{ | ||
@doc("The format of the HTTP payload.") | ||
@header | ||
contentType: "application/json"; | ||
|
||
@clientName("uri", "c\\sharp") | ||
@doc("Example URL parameter.") | ||
opB: url; | ||
}>; | ||
|
||
/** | ||
* Example operation description | ||
*/ | ||
opB is OpB< | ||
ModelA, | ||
{ | ||
...ModelB | ||
} | ||
>; | ||
} | ||
|
||
@doc("Example union type description.") | ||
union UnionA { | ||
string, | ||
|
||
@doc("Example option A description with some technical details that would be typical for this kind of documentation.") | ||
"unionA", | ||
|
||
@doc("Example option B description with additional technical context that would be common in API documentation.") | ||
"unionB", | ||
} | ||
} | ||
|
||
@doc("Example model description.") | ||
model ModelA { | ||
@doc("Example property description.") | ||
contentA: ModelB; | ||
|
||
@removed(Versions.v1_2) | ||
@doc("Example boolean property with typical documentation about its purpose and default behavior.") | ||
contentB?: boolean; | ||
|
||
...ModelX; | ||
} | ||
|
||
@doc("Example model description.") | ||
model ModelB extends ModelA { | ||
...ModelX; | ||
} | ||
|
||
|
||
alias AliasA< | ||
TParamA extends ModelX, | ||
TParamB, | ||
TParamC extends ModelX = {}, | ||
TError = Error | ||
> = ModelB<TParamA, TParamB, TParamC, TError>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested in extracting
import
ed items andusing
ed items.I will work on them after merging this pull request.
#3906
#2428