gnostic icon indicating copy to clipboard operation
gnostic copied to clipboard

Register custom message as schema rather than reference

Open oxisto opened this issue 3 years ago • 2 comments

It seems that for "well known" types, such as google.protobuf.Timestamp, the generated OpenAPI 3.0 document contains a inline schema (format date-time) instead of a reference, which is a nice feature.

I was wondering, if the same is possible for custom defined messages? Background: We are using our own Timestamp implementation (which is basically a wrapper around google.protobuf.Timestamp) because we need to implement sql.Valuer and sql.Scanner on it. When I use it, it always gets generated as a separate schema with a reference, in which clients think that the field contains an object, whereas it only should contain a date-time formatted strings.

Seems somehow related to #351, although #351 refers to another "well-known" type.

oxisto avatar May 24 '22 17:05 oxisto

It sounds like you might be looking for the ability to alias your type, perhaps with a plugin option or some other annotation that says that your timestamp class should be treated as google.protobuf.Timestamp.

timburks avatar May 31 '22 23:05 timburks

It sounds like you might be looking for the ability to alias your type, perhaps with a plugin option or some other annotation that says that your timestamp class should be treated as google.protobuf.Timestamp.

Yes that would be an awesome feature. Although I must say that I did solve the problem slightly different now, so the need for that is not that pressing anymore.

oxisto avatar Jun 01 '22 06:06 oxisto