Skip to content

Commit

Permalink
Fixed: Prevent invalid JSDoc names when generating service methods, see
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Nov 27, 2017
1 parent 6229799 commit db2dd49
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ function buildService(ref, service) {
push("");
pushComment([
method.comment || "Calls " + method.name + ".",
"@function " + util.safeProp(lcName),
"@function " + lcName,
"@memberof " + exportName(service),
"@instance",
"@param {" + exportName(method.resolvedRequestType, !config.forceMessage) + "} request " + method.resolvedRequestType.name + " message or plain object",
Expand Down
2 changes: 2 additions & 0 deletions scripts/gentests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var fs = require("fs"),
{ file: "tests/data/package.proto", flags: [] },
{ file: "tests/data/rpc.proto", flags: [ "es6" ] },
{ file: "tests/data/rpc.proto", flags: [] },
{ file: "tests/data/rpc-reserved.proto", flags: [] },
{ file: "tests/data/test.proto", flags: [] },
{ file: "bench/data/bench.proto", flags: ["no-create", "no-verify", "no-delimited", "no-convert", "no-comments"], out: "bench/data/static_pbjs.js" }
]
Expand Down Expand Up @@ -50,6 +51,7 @@ process.stdout.write("\n");
{ file: "tests/data/package.js" },
{ file: "tests/data/rpc.js" },
{ file: "tests/data/rpc-es6.js" },
{ file: "tests/data/rpc-reserved.js" },
{ file: "tests/data/test.js" },
{ file: "ext/descriptor/index.js", ext: true }
]
Expand Down
2 changes: 1 addition & 1 deletion tests/data/rpc-es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const MyService = $root.MyService = (() => {

/**
* Calls MyMethod.
* @function .myMethod
* @function myMethod
* @memberof MyService
* @instance
* @param {IMyRequest} request MyRequest message or plain object
Expand Down
49 changes: 49 additions & 0 deletions tests/data/rpc-reserved.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import * as $protobuf from "../..";

export class MyService extends $protobuf.rpc.Service {
constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean);
public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): MyService;
public delete(request: IMyRequest, callback: MyService.DeleteCallback): void;
public delete(request: IMyRequest): Promise<MyResponse>;
}

export namespace MyService {

type DeleteCallback = (error: (Error|null), response?: MyResponse) => void;
}

export interface IMyRequest {
path?: (string|null);
}

export class MyRequest implements IMyRequest {
constructor(properties?: IMyRequest);
public path: string;
public static create(properties?: IMyRequest): MyRequest;
public static encode(message: IMyRequest, writer?: $protobuf.Writer): $protobuf.Writer;
public static encodeDelimited(message: IMyRequest, writer?: $protobuf.Writer): $protobuf.Writer;
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): MyRequest;
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): MyRequest;
public static verify(message: { [k: string]: any }): (string|null);
public static fromObject(object: { [k: string]: any }): MyRequest;
public static toObject(message: MyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any };
public toJSON(): { [k: string]: any };
}

export interface IMyResponse {
status?: (number|null);
}

export class MyResponse implements IMyResponse {
constructor(properties?: IMyResponse);
public status: number;
public static create(properties?: IMyResponse): MyResponse;
public static encode(message: IMyResponse, writer?: $protobuf.Writer): $protobuf.Writer;
public static encodeDelimited(message: IMyResponse, writer?: $protobuf.Writer): $protobuf.Writer;
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): MyResponse;
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): MyResponse;
public static verify(message: { [k: string]: any }): (string|null);
public static fromObject(object: { [k: string]: any }): MyResponse;
public static toObject(message: MyResponse, options?: $protobuf.IConversionOptions): { [k: string]: any };
public toJSON(): { [k: string]: any };
}
Loading

0 comments on commit db2dd49

Please sign in to comment.