Style Guide #
The style guide is nearly similar to the protocol buffers style guide and follows also the google api design guidelines.
File structure #
Files should be named lower_snake_case.types.yaml.
You can put the services and types to the same folder (thematic group). You can move the files around without any effect. The resulting protos does not depend on the FIDL file names or structure, they will follow the given package definitions.
|
|
Type and field names #
package names #
Use camelCase (without an initial capital) for package names.
sample.SampleRequest
type names #
Use CamelCase (with an initial capital) for type names.
sample.SampleRequest
field names #
Use underscore_separated_names for field names for example, birth_date.
birth_date
|
|
If your field name contains a number, the number should appear after the letter instead of after the underscore. e.g., use song_name1 instead of song_name_1
Repeated fields #
Use pluralized names for repeated fields.
tags: ‘[] string:1 #Some tags.’
Services #
You should use CamelCase (with an initial capital) for both the service name and any method names:
Look at - name: FruitService , - md: ‘ListFruits: GET /…. You can find a good guide and explanation on the Standard Methods page of the cloud API design guide page.
|
|
URL Path #
Usualy the path part is a noun in plural form. Use singular nouns only on singleton ressources. Do not append a prefix like /api to your paths. Use /fruits.
TIPP: Assume that your API is a host by its own. So you will address it with api.xy.com/fruits. Having api.xy.com/api/fruits will look strange in that moment.
Adding prefixes can be done by infrastructure. The furo client libs also have the posibillity to prefix your specs according to the situation.
You will loose portability capabilities when you prefix your paths.
URL Placeholer / Query Params #
Use short names for the placeholders because they will apear on every request you make and also in the HATEOAS of every response.
Use some consonants only and use them that you can recognize the word behind, when possible. The first letter of a word is allowed to be a vovel.
Main objects of your domain should use only two or three letters. A
q is “reserved” for search query.
some examples
- fruit => frt
- example_data => exd
- support_cases spc
- support_analysis spa