Skip to content

Latest commit

 

History

History
306 lines (162 loc) · 11.1 KB

options.md

File metadata and controls

306 lines (162 loc) · 11.1 KB

Protocol Documentation

Table of Contents

Top

jsonschema.proto

ArrayKeywords

Field Type Label Description
min_items uint32 optional
max_items uint32 optional
unique_items bool optional

EnumOptions

Field Type Label Description
mapping_type EnumOptions.MappingType
title string
description string

EnumValueOptions

Field Type Label Description
custom_value google.protobuf.Any

FieldOptions

Field Type Label Description
visibility_level uint32 WIP: visibility_level is used to determine which message should be generated. Currently not work.
title string
description string
nullable bool
default google.protobuf.Any
array ArrayKeywords
numeric NumericKeywords
string StringKeywords

FileOptions

Field Type Label Description
visibility_level uint32 WIP: visibility_level is used to determine which message should be generated. Currently not work.
entrypoint_message string entrypoint_message is used which message should be entrypoint object of schema. default: inherit from PluginOptions.entrypoint_message
title string
description string

MessageOptions

Field Type Label Description
visibility_level uint32 WIP: visibility_level is used to determine which message should be generated. Currently not work.
title string
description string
object ObjectKeywords

NumericKeywords

Field Type Label Description
inclusive_minimum double
exclusive_minimum double
inclusive_maximum double
exclusive_maximum double
multiple_of int32 optional

ObjectKeywords

Field Type Label Description
additional_properties bool optional
min_properties uint32 optional repeated JsonSchema additional_properties = 10;
max_properties uint32 optional

PluginOptions

Not extendable, just define structure Plugin wide options

Field Type Label Description
visibility_level uint32 WIP: visibility_level is used to determine which message should be generated. Currently not work.
entrypoint_message string entrypoint_message is used which message should be entrypoint object of schema.

default: null or empty example: - --jsonschema_opt=entrypoint_message=MyMessage | | output_file_suffix | string | | output_file_suffix is used to determine output file name suffix. Values should end with '.json' or '.yaml' or '.yml'.

default: .schema.json example: - --jsonschema_opt=output_file_suffix=.schema.json - --jsonschema_opt=output_file_suffix=.schema.yaml | | pretty_json_output | bool | | pretty_json_output is used to determine output json should be pretty printed. This option is only used when output_file_suffix is '.json'.

default: true example: - --jsonschema_opt=pretty_json_output=true - --jsonschema_opt=pretty_json_output=false | | draft | Draft | | draft is used to determine which draft version should be used. The value should be one of Draft04, Draft05, Draft06, Draft07, Draft201909, Draft202012.

default: Draft202012 example: - --jsonschema_opt=draft=Draft202012 | | mandatory_nullable | bool | | mandatory_nullable determines whether this plugin should treat optional field as nullable. Many programming languages do not differentiate between undefined and null. However, scripting languages like JavaScript and TypeScript can distinguish between them. By default, optional field is treated as nullable and undefined.

default: false example: - --jsonschema_opt=mandatory_nullable=true - --jsonschema_opt=mandatory_nullable=false | | int64_as_string | bool | | int64_as_string determines whether int64 field treat as string. Depends on Javascript specification, The JS stores integer to only 53bits. So, if you want to use int64 field in JS, you should use string type. References:

default: false example: - --jsonschema_opt=int64_as_string=true - --jsonschema_opt=int64_as_string=false | | preserve_proto_field_names | bool | | preserve_proto_field_names is used to determine if output json field names should be identical to the proto field names. Otherwise field names either use the value of the json_name field option or they are automatically converted to lowerCamelCase. This default behaviour mirrors the behaviour of Protobuf's canonical JSON format (ProtoJSON).

default: false example: - --jsonschema_opt=preserve_proto_field_names=true - --jsonschema_opt=preserve_proto_field_names=false |

StringKeywords

Field Type Label Description
min_length uint32 optional
max_length uint32 optional
pattern string
format string

Draft

Name Number Description
DraftDefault 0
Draft04 1
Draft05 2
Draft06 3
Draft07 4
Draft201909 5
Draft202012 6

EnumOptions.MappingType

Name Number Description
MapToString 0
MapToNumber 1
MapToCustom 2

File-level Extensions

Extension Type Base Number Description
enum EnumOptions .google.protobuf.EnumOptions 11344
enum_value EnumValueOptions .google.protobuf.EnumValueOptions 11345
field FieldOptions .google.protobuf.FieldOptions 11343
file FileOptions .google.protobuf.FileOptions 11341
message MessageOptions .google.protobuf.MessageOptions 11342

Scalar Value Types

.proto Type Notes C++ Java Python Go C# PHP Ruby
double double double float float64 double float Float
float float float float float32 float float Float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int int32 int integer Bignum or Fixnum (as required)
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long int64 long integer/string Bignum
uint32 Uses variable-length encoding. uint32 int int/long uint32 uint integer Bignum or Fixnum (as required)
uint64 Uses variable-length encoding. uint64 long int/long uint64 ulong integer/string Bignum or Fixnum (as required)
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int int32 int integer Bignum or Fixnum (as required)
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long int64 long integer/string Bignum
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int uint32 uint integer Bignum or Fixnum (as required)
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long uint64 ulong integer/string Bignum
sfixed32 Always four bytes. int32 int int int32 int integer Bignum or Fixnum (as required)
sfixed64 Always eight bytes. int64 long int/long int64 long integer/string Bignum
bool bool boolean boolean bool bool boolean TrueClass/FalseClass
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode string string string String (UTF-8)
bytes May contain any arbitrary sequence of bytes. string ByteString str []byte ByteString string String (ASCII-8BIT)