-
Notifications
You must be signed in to change notification settings - Fork 58
Open
dpup/protoc-gen-grpc-gateway-ts
#20Description
Description
When a protobuf service consists of several files, and some files have special chars in their names like . or -, the generated TS code has invalid import instructions.
Affected version
https://github.com/grpc-ecosystem/protoc-gen-grpc-gateway-ts/releases/tag/v1.1.2
Reproduce steps
- Prepare the env
git clone git@github.com:grpc-ecosystem/protoc-gen-grpc-gateway-ts.git && \
cd protoc-gen-grpc-gateway-ts && \
git checkout v1.1.2 && \
go install . && \
mkdir -p tmp/generated && \
cd tmp- Create a new proto service with files files
service.protoandproduct-models.proto.
// src: ./service.proto
syntax = "proto3";
package myservice;
import "google/api/annotations.proto";
import "product-models.proto";
service MyService {
rpc GetProducts(GetProductReuest) returns (GetProductResponse) {
option (google.api.http) = {
post: "/products"
body: "*"
};
}
}
message GetProductReuest {
repeated int64 ids = 1;
}
message GetProductResponse {
repeated Product products = 1;
}// src: ./product-models.proto
syntax = "proto3";
package myservice;
message Product {
string name = 1;
string description = 2;
}- Generate TS
protoc --grpc-gateway-ts_out=./generated \
--grpc-gateway-ts_opt=use_proto_names=true,logtostderr=true,loglevel=debug \
-I . \
-I ../integration_tests \
*.proto- Observe invalid import name
MyserviceProduct-modelsintmp/generated/service.pb.ts:
/* eslint-disable */
// @ts-nocheck
/*
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
*/
import * as fm from "./fetch.pb"
import * as MyserviceProduct-models from "./product-models.pb"
export type GetProductReuest = {
ids?: string[]
}
export type GetProductResponse = {
products?: MyserviceProduct-models.Product[]
}
export class MyService {
static GetProducts(req: GetProductReuest, initReq?: fm.InitReq): Promise<GetProductResponse> {
return fm.fetchReq<GetProductReuest, GetProductResponse>(`/products`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
}
}anatolym, SidneyNemzer and cthill
Metadata
Metadata
Assignees
Labels
No labels