@furo/specs v1.24.0
furo spec builder
Prequisits
If you have Go installed
simple-generator has to be installed. Quick installation: go get github.com/theNorstroem/simple-generator .
if not: https://golang.org/doc/install
go get -u google.golang.org/grpc
GRPC Gateway Installation
More about grpc-gateway, gRPC to JSON proxy generator following the gRPC HTTP spec.
First you need to install ProtocolBuffers 3.0.0-beta-3 or later.
mkdir tmp
cd tmp
git clone https://github.com/google/protobuf
cd protobuf
./autogen.sh
./configure
make
make check
sudo make installThen, go get -u as usual the following packages:
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-goQuickstart template for spec projects
Use the template repository from https://github.com/theNorstroem/template-furo-spec-project to create a spec project for your specs. More about using template repositorys can be found here.
run npm install to install the tools.
Install your additional spec types and register them in the furo.spec.conf.json.
To edit the specs, you can use a json editor or you can use the api designer.
Manual Installation
- mkdir my-spec-project
- cd my-spec-project
- npm init
- Run
npm install --save-dev @furo/specsto install the tools. - Add a
furo.spec.conf.jsonto the root folder of your spec project. An example of a config file can be found in the~/node_modules/@furo/spec/folder.
TIPP copy the example file, remove the packages, add your packages.
Usage of spec builder
To quickly add types and services for a package, just add them in the packages section of the conf.
Then run
npm initto generate a initial structure for a spec. This consists of the minimal type, a minimal service definition, a default entity spec and a default collection spec
To build the furo data_environment.js, the swagger docs, the golang files for the grpc-gateway and the java interfaces run.
npm buildPreinstalled base types
Following base types are available by default:
- furo.link The default link type for HATEOAS links
- furo.meta Meta information for the single fields
- furo.type.reference A type to set a reference to another entity
- google.protobuf.any The any type, can be any type you make
- google.type.date A type for handling dates (not datetime)
- google.type.money A type for handling money
protobuf.empty A empty type which contains nothing
TIPP Add the scripts to your package.json so you can run
npm run init,npm run build,...{ "scripts": { "build": "node ./node_modules/@furo/specs/_scripts/build.js", "init": "node ./node_modules/@furo/specs/_scripts/init.js" } }Config
initThis section is used to configure the init processinit.packagesThe name of the packages you use. This will be used for the protoc, swagger, specs folderstructure,... If your specs already exist, the init scripts wont touch them.init.excludesThe name of the packages you will skip.ìnit.default_type_for_identitiesSet here the identity type you want. Default value if not set: stringpath_to_simplegeneratorSet the path to your simple-generator binary if you don't have a local environment e.g. ./bin/spec_dirPath to your spec directory.custom_template_dirIf you want to use your own templates, set the path to your template directory relative from your project root. You have to supply all templates if you use this feature flag.swaggerGenerate swagger out when truejavaGenerate java stubs.grpc_gatewayNot yet implementedbuild_output_dirSpecify the directory for the build output.bundledOptions for the bundled buildbuildSet to true to generate and build a bundled version.package_nameThe name will be used as package name for the bundled build.service_nameName for your bundled service.proto_optionsIndividual declarations in a .proto file can be annotated here. more aboutimportsAdd your imports for the service.proto and messages.proto
singleOptions for the multifile build.buildSet to true to generate a multifile version
protoc_IAdditional protoc IMPORT_PATHsprotoc_MDeclares that furo/link.proto is associated with Go package ../furo. Add additional assocs here.
Example config
{
"init": {
"packages": [
"person",
"project",
"task",
"tree",
"experiment"
],
"excludes": [],
"default_type_for_identities": "string"
},
"spec_dir": "./specs",
"__custom_tepmplate_dir": "./path/to/your/tpldir",
"swagger": true,
"grpc_gateway": true,
"java": true,
"build_output_dir": "./build",
"furo_env_name": "data_environment.js",
"bundled": {
"build": true,
"package_name": "taskmanager",
"service_name": "BundledService",
"proto_options": {
"csharp_namespace": "Google.Protobuf.WellKnownTypes",
"go_package": "taskmanager",
"java_package": "taskmanager",
"java_outer_classname": "AnyProto",
"java_multiple_files": true,
"objc_class_prefix": "GPB"
},
"imports": [
"google/protobuf/empty.proto",
"google/protobuf/any.proto",
"google/type/money.proto",
"google/type/date.proto",
"furo/link.proto",
"furo/meta.proto",
"furo/reference.proto"
]
},
"protoc_I": [
"/usr/local/include",
"$GOPATH/src",
"$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis"
],
"protoc_M": [
]
}Usage of ui builder (ui.spec.conf.json)
TIPP Add the scripts to your package.json so you can run
npm run init_ui_spec,npm run build_ui_components,...{ "scripts": { "form_init": "node ./node_modules/@furo/specs/_scripts/init-ui-specs.js", "form_build": "node ./node_modules/@furo/specs/_scripts/build-ui-components.js" } }Config
path_to_simplegeneratorSet the path to your simple-generator binary if you don't have a local environment e.g. ./bin/spec_dirPath to your spec directory.custom_template_dirIf you want to use your own templates, set the path to your template directory relative from your project root. You have to supply all templates if you use this feature flag.forms_spec_outOutput path for your form specsbuild_output_dirBuild output path
Example furo.ui.spec.conf.json
{
"spec_dir": "./specs",
"ui_spec_out": "./ui_specs",
"_custom_tepmplate_dir": "./_scripts/templates",
"build_output_dir": "./build/ui"
}4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago