Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Releases: chrusty/protoc-gen-jsonschema

New option to create consts for ENUM values

09 Nov 03:45
c8aad7b
Compare
Choose a tag to compare

Const values are a part of the draft-06 JSONSchema spec which we are using here alongside ENUMs to provide a bit of additional context.

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "enum": [
        "VALUE_0",
        0,
        "VALUE_1",
        1,
        "VALUE_2",
        2,
        "VALUE_3",
        3
    ],
    "oneOf": [
        {"const": "VALUE_0", "description": "Zero"},
        {"const": "VALUE_1", "description": "One"},
        {"const": "VALUE_2", "description": "Two"},
        {"const": "VALUE_3", "description": "Three"},
        {"const": 0, "description": "Zero"},
        {"const": 1, "description": "One"},
        {"const": 2, "description": "Two"},
        {"const": 3, "description": "Three"}
    ]
}

Functionally this is no different from using straight ENUMs, but it does allow us to include code comments from the original proto files in the description fields.

This functionality is controlled with two new proto options.

Correcting the spelling of "extension"

07 Oct 20:13
74c8a1d
Compare
Choose a tag to compare

The file option "extension" was spelled incorrectly. This release fixes that (hopefully before anyone actually used that new proto option).

Thanks @Yowgf for pointing this out!

Custom proto options

01 Oct 07:36
7b33fbb
Compare
Choose a tag to compare

This release introduces some more custom proto options which allow fine-grained control over the generators behaviour.

See README.md for details and examples.

Changing default file extention

01 Oct 02:04
57fbd5b
Compare
Choose a tag to compare

As @grant points out, .json makes a more sensible choice for the generated schema files.

This version changes the default, but also introduces an option allowing users to specify whatever file extention they prefer (see README.md).

Updating to the new Google protobuf repo

30 Sep 19:56
Compare
Choose a tag to compare

The old one was deprecated and giving compile-time warnings.

Rendering google.protobuf.Struct properly

29 Sep 23:39
f8da8a9
Compare
Choose a tag to compare

As pointed out by @grant this should generate an OBJECT.

Using $ref across the board

29 Sep 21:51
3469322
Compare
Choose a tag to compare

This release brings some bigger changes. Functinoally the schemas will perform the same, but structurally they may be quite different:

  • Previously most nested messages were reproduced inline. Now their schemas are generated and added to the list of definitions, linked to using a $ref. This means that you will now know exactly which proto message your schema components were generated from.
  • The root schema is also a $ref now, which facilitates edge-cases like recursive self-references (yes this is a thing)

Renamed field-options

23 Sep 21:43
82b76ee
Compare
Choose a tag to compare

I've secured an extention to our options range, which means that we can use it for things other than just FieldOptions (MessageOptions, FileOptions, EnumOptions etc). These will be used to offer fine-grained control over the schema generated behaviour.

    string hidden1  = 3 [(protoc.gen.jsonschema.field_options).ignore = true];
  string query = 1 [(protoc.gen.jsonschema.field_options).required = true];

Custom FieldOptions

21 Sep 03:09
cf9fe3e
Compare
Choose a tag to compare

We now have an officially registered custom options number, and have built it into options.proto.

  • "ignore": Fields tagged with this will be skipped / omitted from generated schemas
  • "required": Fields tagged with this will be marked as "required" in generated schemas

Another bug with OneOf and AllFieldsRequired

20 Sep 10:03
65eca57
Compare
Choose a tag to compare