OpenAPI DocumentationΒΆ
OpenAPI documentation has already been generated for our service. However, we may want to make some modifications to this document.
In this section, we will customize our OpenAPI document for the Echo service.
Refer to Reference to learn more about all available customizations.
Similar to defining HTTP bindings, you can use annotations to directly define options in the proto files or use configuration files.
documentallows you to customize the resulting OpenAPI document for this proto file. We will use it to settitleandversionhere.- Similar to the selector we defined in the HTTP bindings, this is a dotted path to the service and
~resolves to the current proto package. - Defining
external_docsin the OpenAPI document only for the HTTP endpoints that are bound to theEchogRPC method. - Similar to the selector we had to define for the service, however here we point to a message to customize
schemafor this proto message. In this case, to set custom description and include additional validation details.
- This option allows you to customize the resulting OpenAPI document for this proto file. We will use it to set
titleandversionhere. - This option allows you to customize the schema generated for this field in the resulting OpenAPI document. Here we add custom description and extra validation details.
- This option can be used to customize operation for HTTP endpoints bound to this gRPC method.
Here, defining
external_docsin the OpenAPI document only for the HTTP endpoints that are bound to theEchogRPC method.
Now you can re-generate using either Buf or protoc directly and notice the changes in the generated OpenAPI file.
That's it for our quick guide!