Code
Speed up your API development by converting your API specification into boilerplate code to help you get started. Blackbird currently creates Go projects using templates.
You can also test and debug your APIs against production-like traffic before you promote your code to production, allowing you to inspect and troubleshoot in real-time.
Note: You must install Docker to use code run and code debug commands with Blackbird. For more information, see Get Docker.
Codegen using our Provided Template
First, download the sample petstore.yaml file to test with.
When using the provided template for Go projects, the following prompts will appear:
- ProjectName: Provide a name for your new Go project. This will also be the name for the
cmd
in your project. - GoModule: Provide a name for your new Go project's
go.mod
module. For more information, read about Using Go Modules. - GoVersion: Provide the Go version for your project. This value will also be used in
go.mod
. - enable GitHub Actions - Test module?: Generate a
.github/build.yaml
configuring CI testing for the project using GitHub Actions. - enable Readme module? [y/n]: Generate a basic
README.md
file for the project. - enable Dockerfile module? [y/n]: Generate a basic
Dockerfile
to use withblackbird code run
,blackbird code debug
, andblackbird deployment create
Using a Local Template
To generate your code using a locally available template, pass the path to the template as an argument.
Codegen without using a Template
To just generate the OpenAPI Spec-based code, pass the argument to use our go
template. This template is publicly available to view in our Github Generators Repository.
Build and run a local container with a remote server
To start debugging an API or Mock, you need to pass in the instance name as well as the path to the dockerfile and context.
Build and debug a local container with a remote server
This command is similar to the run
command, but it attaches a debugger to the container.
Securing a code instance
By default, the remote code instance server endpoints are available publicly. To secure these endpoints, you can use API keys. You can also create and set an API key on creation with the --apikey-header
flag. The following templates show the valid ways to enable an API key for code instance servers.