@typespec/protobuf 0.43.0
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/.c8rc.json +3 -0
- package/.eslintrc.cjs +7 -0
- package/.mocharc.yaml +4 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/operation/test-official/state.json +3 -0
- package/.rush/temp/package-deps_build.json +81 -0
- package/.rush/temp/package-deps_test-official.json +81 -0
- package/.rush/temp/shrinkwrap-deps.json +177 -0
- package/CHANGELOG.json +4 -0
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/coverage/cobertura-coverage.xml +2291 -0
- package/coverage/coverage-final.json +7 -0
- package/coverage/tmp/coverage-6408-1683144315012-0.json +1 -0
- package/dist/src/ast.d.ts +199 -0
- package/dist/src/ast.d.ts.map +1 -0
- package/dist/src/ast.js +60 -0
- package/dist/src/ast.js.map +1 -0
- package/dist/src/index.d.ts +62 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +197 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +134 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/proto.d.ts +62 -0
- package/dist/src/proto.d.ts.map +1 -0
- package/dist/src/proto.js +162 -0
- package/dist/src/proto.js.map +1 -0
- package/dist/src/transform/index.d.ts +7 -0
- package/dist/src/transform/index.d.ts.map +1 -0
- package/dist/src/transform/index.js +744 -0
- package/dist/src/transform/index.js.map +1 -0
- package/dist/src/write.d.ts +12 -0
- package/dist/src/write.d.ts.map +1 -0
- package/dist/src/write.js +204 -0
- package/dist/src/write.js.map +1 -0
- package/dist/test/scenarios.test.d.ts +2 -0
- package/dist/test/scenarios.test.d.ts.map +1 -0
- package/dist/test/scenarios.test.js +165 -0
- package/dist/test/scenarios.test.js.map +1 -0
- package/lib/proto.tsp +303 -0
- package/package.json +49 -0
- package/protobuf.build.log +48 -0
- package/src/ast.ts +279 -0
- package/src/index.ts +7 -0
- package/src/lib.ts +161 -0
- package/src/proto.ts +217 -0
- package/src/transform/index.ts +980 -0
- package/src/write.ts +244 -0
- package/temp/tsconfig.tsbuildinfo +1 -0
- package/test/include/foo/bar.proto +7 -0
- package/test/scenarios/addressbook/input/addressbook.tsp +27 -0
- package/test/scenarios/addressbook/input/main.tsp +13 -0
- package/test/scenarios/addressbook/output/@typespec/protobuf/addressbook.proto +26 -0
- package/test/scenarios/addressbook/output/@typespec/protobuf/main.proto +14 -0
- package/test/scenarios/anonymous-model/diagnostics.txt +1 -0
- package/test/scenarios/anonymous-model/input/main.tsp +24 -0
- package/test/scenarios/anonymous-package/input/main.tsp +19 -0
- package/test/scenarios/anonymous-package/output/@typespec/protobuf/main.proto +15 -0
- package/test/scenarios/array/input/main.tsp +22 -0
- package/test/scenarios/array/output/@typespec/protobuf/com/azure/test.proto +18 -0
- package/test/scenarios/array-nested/diagnostics.txt +1 -0
- package/test/scenarios/array-nested/input/main.tsp +20 -0
- package/test/scenarios/cross package references/input/main.tsp +27 -0
- package/test/scenarios/cross package references/output/@typespec/protobuf/A.proto +10 -0
- package/test/scenarios/cross package references/output/@typespec/protobuf/B.proto +15 -0
- package/test/scenarios/derived-scalar/input/main.tsp +24 -0
- package/test/scenarios/derived-scalar/output/@typespec/protobuf/com/azure/Test.proto +18 -0
- package/test/scenarios/enum/input/main.tsp +33 -0
- package/test/scenarios/enum/output/@typespec/protobuf/main.proto +31 -0
- package/test/scenarios/enum-nonintegral/diagnostics.txt +4 -0
- package/test/scenarios/enum-nonintegral/input/main.tsp +31 -0
- package/test/scenarios/enum-nozero/diagnostics.txt +1 -0
- package/test/scenarios/enum-nozero/input/main.tsp +25 -0
- package/test/scenarios/extern/input/main.tsp +17 -0
- package/test/scenarios/extern/output/@typespec/protobuf/main.proto +19 -0
- package/test/scenarios/illegal field reservations/diagnostics.txt +2 -0
- package/test/scenarios/illegal field reservations/input/main.tsp +16 -0
- package/test/scenarios/inferred-message-names/input/main.tsp +16 -0
- package/test/scenarios/inferred-message-names/output/@typespec/protobuf/com/azure/test.proto +18 -0
- package/test/scenarios/intrinsics/input/main.tsp +17 -0
- package/test/scenarios/intrinsics/output/@typespec/protobuf/com/azure/Test.proto +16 -0
- package/test/scenarios/map/input/main.tsp +15 -0
- package/test/scenarios/map/output/@typespec/protobuf/main.proto +13 -0
- package/test/scenarios/model-no-package/diagnostics.txt +2 -0
- package/test/scenarios/model-no-package/input/main.tsp +19 -0
- package/test/scenarios/name-collision/input/main.tsp +24 -0
- package/test/scenarios/name-collision/output/@typespec/protobuf/main.proto +24 -0
- package/test/scenarios/options/input/main.tsp +25 -0
- package/test/scenarios/options/output/@typespec/protobuf/com/azure/Test.proto +20 -0
- package/test/scenarios/options-invalid/diagnostics.txt +1 -0
- package/test/scenarios/options-invalid/input/main.tsp +25 -0
- package/test/scenarios/reserved field collisions/diagnostics.txt +5 -0
- package/test/scenarios/reserved field collisions/input/main.tsp +19 -0
- package/test/scenarios/reserved fields/input/main.tsp +16 -0
- package/test/scenarios/reserved fields/output/@typespec/protobuf/main.proto +16 -0
- package/test/scenarios/simple/input/main.tsp +22 -0
- package/test/scenarios/simple/output/@typespec/protobuf/com/azure/Test.proto +18 -0
- package/test/scenarios/simple-error/diagnostics.txt +6 -0
- package/test/scenarios/simple-error/input/main.tsp +22 -0
- package/test/scenarios/simple-no-service/input/main.tsp +22 -0
- package/test/scenarios/simple-no-service/output/@typespec/protobuf/com/azure/Test.proto +18 -0
- package/test/scenarios/streams/input/main.tsp +30 -0
- package/test/scenarios/streams/output/@typespec/protobuf/main.proto +19 -0
- package/test/scenarios/type-validation/diagnostics.txt +1 -0
- package/test/scenarios/type-validation/input/main.tsp +11 -0
- package/test/scenarios/union/diagnostics.txt +1 -0
- package/test/scenarios/union/input/main.tsp +33 -0
- package/test/scenarios.test.ts +226 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace com.azure.Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): Output;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
model Input {
|
|
14
|
+
@field(1) testInputField: string[][];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
model Output {
|
|
18
|
+
@field(1) testOutputField: int32[];
|
|
19
|
+
@field(2) secondField: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package({
|
|
6
|
+
name: "A",
|
|
7
|
+
})
|
|
8
|
+
namespace A {
|
|
9
|
+
model Output {
|
|
10
|
+
@field(1) testOutputField: int32;
|
|
11
|
+
@field(2) secondField: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@package({
|
|
16
|
+
name: "B",
|
|
17
|
+
})
|
|
18
|
+
namespace B {
|
|
19
|
+
@Protobuf.service
|
|
20
|
+
interface Service {
|
|
21
|
+
foo(...Input): A.Output;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
model Input {
|
|
25
|
+
@field(1) testInputField: string;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package({
|
|
6
|
+
name: "com.azure.Test",
|
|
7
|
+
})
|
|
8
|
+
namespace Test;
|
|
9
|
+
|
|
10
|
+
scalar MyInt32 extends int32;
|
|
11
|
+
|
|
12
|
+
@Protobuf.service
|
|
13
|
+
interface Service {
|
|
14
|
+
foo(...Input): Output;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
model Input {
|
|
18
|
+
@field(1) testInputField: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
model Output {
|
|
22
|
+
@field(1) testOutputField: MyInt32;
|
|
23
|
+
@field(2) secondField: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
package com.azure.Test;
|
|
6
|
+
|
|
7
|
+
message Input {
|
|
8
|
+
string testInputField = 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
message Output {
|
|
12
|
+
int32 testOutputField = 1;
|
|
13
|
+
string secondField = 2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
service Service {
|
|
17
|
+
rpc Foo(Input) returns (Output);
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): Output;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
model Input {
|
|
14
|
+
@field(1) testInputField: string;
|
|
15
|
+
@field(2) type: InputType;
|
|
16
|
+
@field(3) aliased: InputTypeWithAlias;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
enum InputType {
|
|
20
|
+
FOO: 0,
|
|
21
|
+
BAR: 1,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
enum InputTypeWithAlias {
|
|
25
|
+
BAZ: 0,
|
|
26
|
+
QUX: 1,
|
|
27
|
+
FUZ: 1,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
model Output {
|
|
31
|
+
@field(1) testOutputField: int32;
|
|
32
|
+
@field(2) secondField: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
enum InputType {
|
|
6
|
+
FOO = 0;
|
|
7
|
+
BAR = 1;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
enum InputTypeWithAlias {
|
|
11
|
+
option allow_alias = true;
|
|
12
|
+
|
|
13
|
+
BAZ = 0;
|
|
14
|
+
QUX = 1;
|
|
15
|
+
FUZ = 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message Input {
|
|
19
|
+
string testInputField = 1;
|
|
20
|
+
InputType type = 2;
|
|
21
|
+
InputTypeWithAlias aliased = 3;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
message Output {
|
|
25
|
+
int32 testOutputField = 1;
|
|
26
|
+
string secondField = 2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
service Service {
|
|
30
|
+
rpc Foo(Input) returns (Output);
|
|
31
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/test/main.tsp:18:1 - error @typespec/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message
|
|
2
|
+
/test/main.tsp:19:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message
|
|
3
|
+
/test/main.tsp:23:1 - error @typespec/protobuf/unconvertible-enum: enums must explicitly assign exactly one integer to each member to be used in a Protobuf message
|
|
4
|
+
/test/main.tsp:24:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): Output;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
model Input {
|
|
14
|
+
@field(1) testInputField: string;
|
|
15
|
+
@field(2) type: InputType;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
enum InputType {
|
|
19
|
+
FOO: 1,
|
|
20
|
+
BAR: "test",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
enum OutputType {
|
|
24
|
+
FOO,
|
|
25
|
+
BAR,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
model Output {
|
|
29
|
+
@field(1) testOutputField: OutputType;
|
|
30
|
+
@field(2) secondField: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/test/main.tsp:19:3 - error @typespec/protobuf/unconvertible-enum: the first variant of an enum must be set to zero to be used in a Protobuf message
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): Output;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
model Input {
|
|
14
|
+
@field(1) testInputField: string;
|
|
15
|
+
@field(2) type: InputType;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
enum InputType {
|
|
19
|
+
FOO: 1,
|
|
20
|
+
BAR: 2,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
model Output {
|
|
24
|
+
@field(2) secondField: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...MyExtern): WellKnown.Empty;
|
|
11
|
+
|
|
12
|
+
bar(@field(1) empty: WellKnown.Empty): {
|
|
13
|
+
@field(1) myExtern: MyExtern;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
model MyExtern is Extern<"foo/bar.proto", "foo.Bar">;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
import "foo/bar.proto";
|
|
6
|
+
import "google/protobuf/empty.proto";
|
|
7
|
+
|
|
8
|
+
message BarRequest {
|
|
9
|
+
google.protobuf.Empty empty = 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
message BarResponse {
|
|
13
|
+
foo.Bar myExtern = 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
service Service {
|
|
17
|
+
rpc Foo(foo.Bar) returns (google.protobuf.Empty);
|
|
18
|
+
rpc Bar(BarRequest) returns (BarResponse);
|
|
19
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/test/.tsp/lib/lib.tsp:81:1 - error @typespec/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range
|
|
2
|
+
/test/.tsp/lib/lib.tsp:51:1 - error @typespec/protobuf/illegal-reservation: reservation value must be a string literal, uint32 literal, or a tuple of two uint32 literals denoting a range
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@reserve(2, 15, [9, 11], "foo", string, uint32)
|
|
14
|
+
model Input {
|
|
15
|
+
@field(1) testInputField: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package({
|
|
6
|
+
name: "com.azure.test",
|
|
7
|
+
})
|
|
8
|
+
namespace Test;
|
|
9
|
+
|
|
10
|
+
@Protobuf.service
|
|
11
|
+
interface Service {
|
|
12
|
+
foo(@field(1) testInputField: string): {
|
|
13
|
+
@field(1) testOutputField: int32;
|
|
14
|
+
@field(2) secondField: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
package com.azure.test;
|
|
6
|
+
|
|
7
|
+
message FooRequest {
|
|
8
|
+
string testInputField = 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
message FooResponse {
|
|
12
|
+
int32 testOutputField = 1;
|
|
13
|
+
string secondField = 2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
service Service {
|
|
17
|
+
rpc Foo(FooRequest) returns (FooResponse);
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package({
|
|
6
|
+
name: "com.azure.Test",
|
|
7
|
+
})
|
|
8
|
+
namespace Test;
|
|
9
|
+
|
|
10
|
+
@Protobuf.service
|
|
11
|
+
interface Service {
|
|
12
|
+
foo(...Input): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
model Input {
|
|
16
|
+
@field(1) testInputField: unknown;
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
package com.azure.Test;
|
|
6
|
+
|
|
7
|
+
import "google/protobuf/any.proto";
|
|
8
|
+
import "google/protobuf/empty.proto";
|
|
9
|
+
|
|
10
|
+
message Input {
|
|
11
|
+
google.protobuf.Any testInputField = 1;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
service Service {
|
|
15
|
+
rpc Foo(Input) returns (google.protobuf.Empty);
|
|
16
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/test/main.tsp:14:12 - error @typespec/protobuf/model-not-in-package: model Input is not in a namespace that uses the '@Protobuf.package' decorator
|
|
2
|
+
/test/main.tsp:17:13 - error @typespec/protobuf/model-not-in-package: model Input is not in a namespace that uses the '@Protobuf.package' decorator
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
model Input {
|
|
6
|
+
@field(1) name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@package
|
|
10
|
+
namespace Test {
|
|
11
|
+
@Protobuf.service
|
|
12
|
+
interface Service {
|
|
13
|
+
// Reference a message type that isn't in this package.
|
|
14
|
+
example(@field(1) input: Input): WellKnown.Empty;
|
|
15
|
+
|
|
16
|
+
// Spread input directly
|
|
17
|
+
example2(...Input): WellKnown.Any;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
model ExampleRequest {
|
|
9
|
+
@field(1) test: uint32;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
model ExampleResponse {
|
|
13
|
+
@field(1) test: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Protobuf.service
|
|
17
|
+
interface Service {
|
|
18
|
+
// invalid field index
|
|
19
|
+
example(@field(1) test: string): {
|
|
20
|
+
@field(1) test: uint32;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
example2(...ExampleRequest): ExampleResponse;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
message ExampleRequest {
|
|
6
|
+
uint32 test = 1;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
message ExampleResponse {
|
|
10
|
+
string test = 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message ExampleRequest {
|
|
14
|
+
string test = 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message ExampleResponse {
|
|
18
|
+
uint32 test = 1;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
service Service {
|
|
22
|
+
rpc Example(ExampleRequest) returns (ExampleResponse);
|
|
23
|
+
rpc Example2(ExampleRequest) returns (ExampleResponse);
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package({
|
|
6
|
+
name: "com.azure.Test",
|
|
7
|
+
options: {
|
|
8
|
+
java_package: "com.azure.test",
|
|
9
|
+
},
|
|
10
|
+
})
|
|
11
|
+
namespace Test;
|
|
12
|
+
|
|
13
|
+
@Protobuf.service
|
|
14
|
+
interface Service {
|
|
15
|
+
foo(...Input): Output;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
model Input {
|
|
19
|
+
@field(1) testInputField: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
model Output {
|
|
23
|
+
@field(1) testOutputField: int32;
|
|
24
|
+
@field(2) secondField: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
package com.azure.Test;
|
|
6
|
+
|
|
7
|
+
option java_package = "com.azure.test";
|
|
8
|
+
|
|
9
|
+
message Input {
|
|
10
|
+
string testInputField = 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
message Output {
|
|
14
|
+
int32 testOutputField = 1;
|
|
15
|
+
string secondField = 2;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
service Service {
|
|
19
|
+
rpc Foo(Input) returns (Output);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/test/main.tsp:5:10 - error invalid-argument: Argument '(anonymous model)' is not assignable to parameter of type 'TypeSpec.Protobuf.PackageDetails'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package({
|
|
6
|
+
name: "com.azure.Test",
|
|
7
|
+
options: {
|
|
8
|
+
java_package: {},
|
|
9
|
+
},
|
|
10
|
+
})
|
|
11
|
+
namespace Test;
|
|
12
|
+
|
|
13
|
+
@Protobuf.service
|
|
14
|
+
interface Service {
|
|
15
|
+
foo(...Input): Output;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
model Input {
|
|
19
|
+
@field(1) testInputField: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
model Output {
|
|
23
|
+
@field(1) testOutputField: int32;
|
|
24
|
+
@field(2) secondField: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/test/main.tsp:15:13 - error @typespec/protobuf/field-name: field name 'foo' was reserved by a call to @reserve on this model
|
|
2
|
+
/test/main.tsp:16:10 - error @typespec/protobuf/field-index: field index 2 was reserved by a call to @reserve on this model
|
|
3
|
+
/test/main.tsp:17:10 - error @typespec/protobuf/field-index: field index 9 falls within a range reserved by a call to @reserve on this model
|
|
4
|
+
/test/main.tsp:18:10 - error @typespec/protobuf/field-index: field index 11 falls within a range reserved by a call to @reserve on this model
|
|
5
|
+
/test/main.tsp:18:14 - error @typespec/protobuf/field-name: field name 'bar' was reserved by a call to @reserve on this model
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@reserve(2, 15, [9, 11], "foo", "bar")
|
|
14
|
+
model Input {
|
|
15
|
+
@field(1) foo: string;
|
|
16
|
+
@field(2) field2: int32;
|
|
17
|
+
@field(9) field9: uint32;
|
|
18
|
+
@field(11) bar: sint32;
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package
|
|
6
|
+
namespace Test;
|
|
7
|
+
|
|
8
|
+
@Protobuf.service
|
|
9
|
+
interface Service {
|
|
10
|
+
foo(...Input): {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@reserve(2, 15, [9, 11], "foo", "bar")
|
|
14
|
+
model Input {
|
|
15
|
+
@field(1) testInputField: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
message Input {
|
|
6
|
+
reserved 2, 15, 9 to 11;
|
|
7
|
+
reserved "foo", "bar";
|
|
8
|
+
|
|
9
|
+
string testInputField = 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
message FooResponse {}
|
|
13
|
+
|
|
14
|
+
service Service {
|
|
15
|
+
rpc Foo(Input) returns (FooResponse);
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "@typespec/protobuf";
|
|
2
|
+
|
|
3
|
+
using TypeSpec.Protobuf;
|
|
4
|
+
|
|
5
|
+
@package({
|
|
6
|
+
name: "com.azure.Test",
|
|
7
|
+
})
|
|
8
|
+
namespace Test;
|
|
9
|
+
|
|
10
|
+
@Protobuf.service
|
|
11
|
+
interface Service {
|
|
12
|
+
foo(...Input): Output;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
model Input {
|
|
16
|
+
@field(1) testInputField: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
model Output {
|
|
20
|
+
@field(1) testOutputField: int32;
|
|
21
|
+
@field(2) secondField: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Generated by Microsoft TypeSpec */
|
|
2
|
+
|
|
3
|
+
syntax = "proto3";
|
|
4
|
+
|
|
5
|
+
package com.azure.Test;
|
|
6
|
+
|
|
7
|
+
message Input {
|
|
8
|
+
string testInputField = 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
message Output {
|
|
12
|
+
int32 testOutputField = 1;
|
|
13
|
+
string secondField = 2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
service Service {
|
|
17
|
+
rpc Foo(Input) returns (Output);
|
|
18
|
+
}
|