Skip to content

Instantly share code, notes, and snippets.

@crazybob
Last active March 28, 2019 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crazybob/71db05a47ef0379c1f5b5374a3b39cb6 to your computer and use it in GitHub Desktop.
Save crazybob/71db05a47ef0379c1f5b5374a3b39cb6 to your computer and use it in GitHub Desktop.
Protobuf vs. Swagger
Protobuf:
service PetService {
// Finds pets by IDs
rpc findById(FindByIdRequest) returns (FindByIdResponse);
}
message FindByIdRequest {
// IDs to look up
repeated string ids = 1;
}
message FindByIdResponse {
// Found pets
repeated PetResponse pets = 1;
}
Swagger (YAML):
get:
description: Returns pets based on ID
summary: Find pets by ID
operationId: getPetsById
responses:
'200':
description: pet response
content:
'*/*' :
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: error payload
content:
'text/html':
schema:
$ref: '#/components/schemas/ErrorModel'
parameters:
- name: id
in: path
description: ID of pet to use
required: true
schema:
type: array
style: simple
items:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment