This repository contains API specifications and codegen for Insolar Explorer.
Latest tagged images:
- public
docker run -d -p "80:80" registry.insolar.io/spec-insolar-block-explorer-v1-openapi:latest
Just add it as a Go module to your project—specify some tag as a Go dependency.
-
Install all the prerequisites:
- Go 1.12
- Docker
- Make
-
Run
make hook
just once.
This command prepares your local Git pre-commit hook.
Every time you commit changes to a specification, the hook automatically:
- Rebuilds corresponding Go modules.
- Puts them next to the specification.
- Adds the generated files to your commit.
Thus, we gain a single point of truth for our documentation, implementation code, and test code.
You cannot commit if the hook didn't generate the module successfully.
If you are using a JetBrains IDE (GoLand or similar), disable gofmt
to commit.
You can build all clients and servers manually. Just run make <command>
:
build-clients build all clients
build-external-call-api-client build only client of external-call-api
build-external-call-api-server build only server of external-call-api
build-heavy-replica-api-client build only client of heavy-replica-api
build-heavy-replica-api-server build only server of heavy-replica-api
build-servers build all servers
build build all modules
help display help screen
hook add pre-commit git hook file
open open all index.html files
Just add a new tag.
CI automatically:
- Starts a job described in
.github/workflows/
that prepares a docker container with API documentation in an HTML file. - Pushes the container to our internal docker registry.
You can verify the container:
- Run
docker run -it -p 8080:80 registry.insolar.io/spec-insolar-block-explorer-api-<spec-directory>:<last-tag>
. - Open
http://localhost:8080/
in your browser.
.github
— contains actions for GitHub..indirect
— some scripts for the project.external-call-api
,internal-call-api
,heavy-replica-api
,node-join-api
— main folders by serviceclient
— client generated from OpenAPI.server
- server generated from OpenAPI.html
- generated OpenAPI documentation.openapi
- specification sources.indirect
- some service-specific scripts.
Git hooks are scripts that Git executes before or after events such as: commit, push, and receive. Git hooks are a built-in feature — no need to download anything. Git hooks are run locally. Pre-commit starts before finishing your commit in Git.
Every Git repository has a .git/hooks
folder with a script for each hook you can bind to.
The make hook
command creates .git/hooks/pre-commit
and makes it call .indirect/pre-commit.sh
.
The latter script, in turn:
- Detects directories with the
openapi
name. - If the content in at least one changed, the hook generates clients, servers, documentations and appends that to your commit.