protoc-gen-flowtypes

command
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 12 Imported by: 0

README

protoc-gen-flowtypes

Generate flowtype type definitions for proto3 messages and enums.

Contributions welcome.

$ cat simple.proto
syntax = "proto3";

// Well-known type that should be handled
import "google/protobuf/timestamp.proto";

// optional to specify optional fields and nullable values.
import "github.com/foolin/grpcutil/protoc-gen-flowtypes/opts/opts.proto";

message SearchRequest {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
  enum Corpus {
    UNIVERSAL = 0;
    WEB = 1;
    IMAGES = 2;
    LOCAL = 3;
    NEWS = 4;
    PRODUCTS = 5;
    VIDEO = 6;
  }
  Corpus corpus = 4;
  google.protobuf.Timestamp sent_at = 5;
  int64 example_required = 6 [(opts.field) = {required : true}];
  int64 example_nullable = 7 [(opts.field) = {nullable : true}];
  int64 example_required_and_nullable = 8 [(opts.field) = {required : true, nullable : true}];
}

message SearchResponse {
  repeated string results = 1;
  int32 num_results = 2;
  SearchRequest original_request = 3;
}

example use:

$ protoc -I. -I${GOPATH}/src --flowtypes_out=. simple.proto
$ cat simple_types.js

simple.js:

/* @flow */
/* eslint-disable */
// Code generated by protoc-gen-flowtypes DO NOT EDIT.
// InputID: 822c6d2f6d088526d5feaf738395a465d3f002b9

export type SearchRequestCorpus = "WEB" | "IMAGES" | "LOCAL" | "NEWS" | "PRODUCTS" | "VIDEO";

export type SearchRequest = {
  query?: string,
  page_number?: number,
  result_per_page?: number,
  corpus?: SearchRequestCorpus,
  sent_at?: string,
  example_required: number,
  example_nullable?: ?number,
  example_required_and_nullable: ?number
};

export type SearchResponse = {
  results?: Array<string>,
  num_results?: number,
  original_request?: SearchRequest
};

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package genflowtypes provides a code generator for flow types.
Package genflowtypes provides a code generator for flow types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL