-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
After writing this sample proto
item.proto
syntax = "proto3";
package name;
// libraries
import "google/api/annotations.proto";
import "protobuf_pydantic_gen/pydantic.proto";
// dtos
import "item_dto.proto";
service ItemService {
rpc GetItem (GetItemRequest) returns (GetItemResponse) {
option (google.api.http) = {
get: "/api/v1/item/{id}"
};
};
}
message GetItemRequest {
int32 id = 1 [(pydantic.field) = {
description: "The ID of the item to retrieve",
required: true
}];
}
message GetItemResponse {
string message = 1 [(pydantic.field) = {
description: "The message returned in the response",
default: ""
}];
Item item = 2 [(pydantic.field) = {
description: "The item returned in the response",
required: true
}];
}
item_dto.proto
syntax = "proto3";
package name;
import "protobuf_pydantic_gen/pydantic.proto";
message Item {
int32 id = 1 [(pydantic.field) = {description: "Name of the item"}];
string name = 2 [(pydantic.field) = {description: "Name of the item"}];
}
and compiled the proto with:
poetry run python -m grpc_tools.protoc \
-I ./proto \
--plugin=protoc-gen-custom=protobuf_pydantic_gen/main.py \
--python_out=./app/pb \
--pyi_out=./app/pb \
--grpc_python_out=./app/pb \
--pydantic_out=./app/pb \
./proto/*.proto
the accepted url for the controller gets: /api/v1/item/{id}?id=1
but it should be: /api/v1/item/1
Metadata
Metadata
Assignees
Labels
No labels