Packages

Packages #

Packages are not optional in FIDLs. Even when you are in the same µType file, you have to write at least the deepest package name to address another type from the same package.

Packages in µType are defined in the type field. The package for the type below will be auth.

1
2
3
4
5
- type: 'auth.Credentials #Credentials type for login.'
  fields:
    password: '* string:1 #The password.'
    username: '* string:2 #The username or email, or something to identify.'    

Packages in µServices will be defined on the package field.

1
2
3
4
5
6
7
- name: Authsession
  description: Login with credentials. The service should set a auth cookie on login and delete it on logout
  package: auth
  target: authservice.proto
  services:
    - md: 'Create: POST /auth auth.Credentials , google.protobuf.Empty #Login with credentials #Nimmt die Credentials für die Anmeldung entgegen'
    - md: 'Delete: DELETE /auth google.protobuf.Empty , google.protobuf.Empty #Logout.'

Packages in the specs (types and services) are defined in the field __proto.package .

Note: The fieldname __proto is due to historical reasons, proto was just an extension in the early days of the furo specs.
1
2
__proto:
    package: auth

type spec example #

This will result in following spec type, using this config :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Credentials
type: Credentials
description: Credentials type for login.
__proto:
    package: auth
    targetfile: auth.proto
    imports: []
    options:
        go_package: github.com/veith/doit-specs/dist/pb/auth;authpb
        java_multiple_files: "true"
        java_outer_classname: AuthProto
        java_package: com.furo.baseauth
fields:
    password:
        type: string
        description: The password.
        __proto:
            number: 1
            oneof: ""
        __ui: null
        meta:
            default: ""
            hint: ""
            label: auth.Credentials.password.label
            options:
                flags: []
                list: []
            readonly: false
            repeated: false
            typespecific: null
        constraints:
            required:
                is: "true"
                message: password is required
    username:
        type: string
        description: The username or email, or something to identify.
        __proto:
            number: 2
            oneof: ""
        __ui: null
        meta:
            default: ""
            hint: ""
            label: auth.Credentials.username.label
            options:
                flags: []
                list: []
            readonly: false
            repeated: false
            typespecific: null
        constraints:
            required:
                is: "true"
                message: username is required  

proto example #

The resulting proto will look like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// Code generated by furo. DO NOT EDIT.
syntax = "proto3";
package auth;
option go_package = "github.com/veith/doit-specs/dist/pb/auth;authpb";
option java_multiple_files = true;
option java_outer_classname = "AuthProto";
option java_package = "com.furo.baseauth";



// Credentials type for login.
message Credentials {  

    // The password.
    string password = 1;

    // The username or email, or something to identify.
    string username = 2;
    
}

Packages and Name Resolution #

Like in protobuf the type name resolution works like C++: first the innermost scope is searched, then the next-innermost, and so on, with each package considered to be “inner” to its parent package. A leading ‘.’ (for example, .foo.bar.Baz) means to start from the outermost scope instead.

Packages in µSpes #

By translating µSpecs to specs, furo will refer to the .furo configuration file for your packages. The java and golang packages are added as corresponding option to the specs. Once setted, Furo will not change them again.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
spectools: "1.18.1"
module: "github.com/veith/doit-specs"
version: "v1.0.0"
specDir: "./specs"
specFormat: "yaml" #set to yaml or json
dependencies:
  - "git@github.com:theNorstroem/furoBaseSpecs.git v1.11.8" # The importer looks for all **/*.type.spec files recursive The importer looks for all **/*.service.spec files recursive
dependenciesDir: dependencies
muSpec:
  types:
    - "./muspecs/**/*types.yaml"
    - "./muspecs/*types.yaml"
  services:
    - "./muspecs/**/*services.yaml"
    - "./muspecs/*services.yaml"
  goPackageBase: "github.com/veith/doit-specs/dist/pb/" #this is used to prefix the go package option
  javaPackagePrefix: "com.furo.base"
  dir: "muspecs"