Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update protoc-gen-openapi to handle "unnamed" path parameters, json n…
…aming, google.protobuf.Struct and google.protobuf.Empty (#261) * Update protoc-gen-openapi to handle "unnamed" path parameters Paths like this: `/v1/users/{user_id}/messages/{message_id}` is now being parsed into path parameters instead of query paramaters. * Add support for protobuf.Struct and protobuf.Empty Struct will be converted to type object. Empty will caused the field to be completely ignored. * Add support for protobuf.Struct as response Will return an empty JSON object * Add support for Struct and Empty requestBody and responseBody Also better support for some google.protoby.* array types * Enable flag for chosing json naming (camelCase) - output raw protobuf names as default - enable json naming with a flag - use names from json_name options, json naming is enabled - set version with a flag - minor cleanup according to go vet json naming and version is set with standard protoc key, values: `--openapi_out=json=true,version=1.2.3:.` Each test now also has a test with json naming enabled and a version set. Testing was simplified a bit to utilize table-driven tests with sub tests. * Use tags for grouping + add title and description as config params A new tag is created per services and added to each of it's operations. The title and description has been added as standard params and can be set as key value params with either --openapi_out or --openapi_opt. E.g.: --openapi_opt=title=API,description="testing testing",version=1.2.3 --openapi_out=json=true:. Title and description of the document is handled a bit differently: - A service's name now becomes it's tag - Comments will be used for description instead of summary - If doc title and description is set, it is never overwritten - If only one service is being parsed: - If doc has no title, use the service's tag name + " API" - If doc has no description, use service tag description - Remove the tag description * Sort tags * Replace all instances of "googleapis/gnostic" with "google/gnostic" * Rename openapi.json.yaml test files to openapi_json.yaml * Change JSONNames parameter to Naming and make json default This enables different naming schemes. Initially supports json and proto with json as default. json format is camelCase, which seems to be the unofficial standard throughout proto + json projects like Envoy, gRPC Gateway, etc. * Adjust "json-style" naming in protoc-gen-openapi to capitalize schema names. This aligns protoc-gen-openapi output with the Google API Discovery Document convention of capitalizing schema names. This capitalization is also in OpenAPI descriptions translated from Discovery Docs, for example: https://github.com/APIs-guru/openapi-directory/blob/16231c13a2041427a3f799a4d8053cb6cb9be4a8/APIs/googleapis.com/translate/v3/openapi.yaml#L742 (a very minor typo is also fixed in this commit) Co-authored-by: Tim Burks <timburks@google.com>
- Loading branch information