chrusty / protoc-gen-jsonschema

Protobuf to JSON-Schema compiler
Apache License 2.0
496 stars 101 forks source link

Using detached-leading-comments as title field #110

Closed chrusty closed 2 years ago

chrusty commented 2 years ago

In response to an issue raised by @mrozycki-tink, this PR introduces new behaviour which uses the first line of protobuf comments to populate the JSONSchema title field (but only if there are more than one comments).

In this example the title would be "Thing":

// Thing

// This is a thing.
message Thing {
  ...
}

The protobuf library describes this as being a "detached" comment, which to me seems like a good way to pick a title.

jcchavezs commented 2 years ago

As mentioned in https://github.com/chrusty/protoc-gen-jsonschema/issues/108#issuecomment-1019875419 I think we should consider the cases where the description is just one line so the title and the description are the same.

yudintsevegor commented 2 years ago

Hey, this would solve what we are looking for! Cant wait to use it!

jcchavezs commented 2 years ago

I left another comment about this approach in https://github.com/chrusty/protoc-gen-jsonschema/issues/108#issuecomment-1020535489. Could we please hold this PR until we discuss the approach in the issue?

chrusty commented 2 years ago

I left another comment about this approach in #108 (comment). Could we please hold this PR until we discuss the approach in the issue?

Hey @jcchavezs thanks for your investigations. Would you be able to let me know if the PR in its current state could work for your use case (with "detached comments" providing the title)?