Is there a way to set up openapi examples from protobuf?
I am using gnostic to output openapiv3 yaml files from protobuf. Furthermore, I am setting up a Mock server from openapiv3 using Prism, but I want to use the response from the examples specified. Is there a way to set up examples in protobuf and output them to openapiv3 in a format that can be used with prism's mock?
I want to output openapi yaml like this from protobuf.
responses:
'200':
description: OK
content:
application/json:
schema:
'$ref': '#/components/schemas/Pet'
examples:
cat:
summary: An example of a cat
value:
id: 2
name: Fluffy
dog:
summary: An example of a dog
value:
id: 1
name: Spot
@daiki-sone have you tried using the options? You can see an example here: https://github.com/google/gnostic/blob/main/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto#L63
The MediaType message has an examples property so I think you can set it that way
https://github.com/google/gnostic/blob/main/openapiv3/OpenAPIv3.proto#L252
Have you solved it? I have the same need
@daiki-sone have you tried using the options? You can see an example here: https://github.com/google/gnostic/blob/main/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto#L63
The MediaType message has an
examplesproperty so I think you can set it that way https://github.com/google/gnostic/blob/main/openapiv3/OpenAPIv3.proto#L252
#417 I want to set example for the field to display by mock, but above advice can not work