These commands allow you to prepare a spec for SDK generation, validate the spec and generate SDKs and documentation.
|Create a new liblab config file|
|Validate your liblab config file and API spec|
|Create hooks for your SDK|
|Generate your SDK and Docs|
Initialize your SDK generation by creating a new liblab config file.
liblab init [--force]
|Overwrite an existing config file. If you already have a |
|Create a GitHub workflow file for your SDK. This will create a |
|Create a |
|The path to your API spec file. This can be a local path or a publicly reachable URL.|
Interactively validate your config file and API spec.
The liblab CLI will validate your config file and your spec. If there are any errors in the config file, these will be printed out in the terminal and the validation will stop. Fix these errors before continuing. For example, if you spelt
bearer wrong for the
You would get the following:
➜ my-api: liblab validate
› Error: The following errors were found with the config file:
› Invalid enum value. Expected 'apikey' | 'basic' | 'bearer' | 'custom', received 'bear'
If there are no errors in the config file, the spec will be validated. You will be walked through any warnings or errors in your spec one by one, with options to continue or ignore them.
➜ my-api: liblab validate
[WARNING]: "info-contact" Info object must have "contact" object.
Lines: 2 - 8
? What would you like to do for this error?
❯ Continue without changes for now
Continue without changes for all similar cases
Add this instance to the ignore list
Add all similar errors to the ignore list
For each warning or error you get the following options:
Continue without changes for now- This will continue the validation process, ignoring this instance of the warning or error only. You will be asked about this again if the validation comes across the same issue again.
Continue without changes for all similar cases- This will continue the validation process, ignoring all instances of this warning or error in the rest of the file.
Add this instance to the ignore list- This will add this specific warning or error to an ignore list in the liblab config file. You will not be asked about this issue again if you run the validation command again.
Add all similar errors to the ignore list- This will add all similar warnings or errors to the ignore list in the liblab config file. You will not be asked about this error again if you run the validation command again.
Select the option you want, or use
ctrl + c to exit the validation process to fix the issue in your spec.
The ignore list options allow you to always ignore certain warnings or errors that you may not care about. For example, if you were to add the instance of the warning above about the missing
contact object to the ignore list, you would get the following in your
You can read more about this configuration setting in our config file reference.
Once you complete the validation, the output is written to a file called
api-schema-validation.log in your current directory. This lists all warnings and errors in your spec, with details of the line number, and links with suggestions on how to fix them.
1. [Warning] Info object must have "contact" object.
Object Path: info
Line: 2 - 8,
Char: 10 - 3
It is recommended that you fix all errors and most warnings to get the highest quality SDK possible. You can learn more in our review your spec guide.
Bootstrap or remove SDK hooks to allow you to customize the API invocation lifecycle, handling before a request is sent, when a response is received and when API errors occur.
liblab hooks [add/remove] [--language=<language>]
When you add hooks, a
hooks folder is created that contains your hooks code. You can create hooks for any of the SDK languages that you are generating. Just having the
hooks folder is enough to enable hooks for your SDK, but you will need to add code to the hooks to make them do anything.
You can learn more about hooks in our hooks guide.
|Bootstrap SDK hooks. This will create a |
|Remove SDK hooks. This will delete the |
liblab hooks add
Bootstrap SDK hooks.
liblab hooks add [--language=<language>]
This will create a folder called
hooks containing boilerplate hook files for the SDK languages defined in your config file. For example, if your config file is configured to create Python and Typescript SDKs:
Then after running
liblab hooks add the
hooks folder will look like this:
|Add hooks for just the specified language. For example, run |
liblab hooks remove
Remove SDK hooks.
liblab hooks remove [--language=<language>]
This will delete the
hooks. If no language is specified, then all hooks will be deleted. If the
language is provided, then only the hooks for that language will be deleted.
|Remove hooks for just the specified language. For example, run |
Generate an SDK and Docs for your API.
liblab build [--approve-docs]
build command uses your config file to define how to build your SDK. You can learn more about the config file in the config file overview documentation.
This command will validate your config file, and do a non-interactive validation of your API spec. If there are any errors, you will be asked if you want to continue or not. If you choose to continue, the SDKs will be generated, but they may not work as expected.
Detected potential issues with the spec:
› Warning: Info object must have "contact" object.
› Error: Info "description" must be present and non-empty string.
› Warning: Operation "description" must be present and non-empty string.
› Warning: Operation tags must be defined in global tags.
Created api-schema-validation.log with the full linting results
? It is important to fix your spec before continuing with a build. Not fixing the spec may yield a subpar SDK and documentation. Would you like to attempt to build the SDK anyway? (Y/n)
Once the SDKs are generated, they are downloaded to the
output folder. Once docs are generated they will be hosted on-line and you will have the ability to preview or download them. You will also be asked to approve the docs for publishing to the liblab docs site.
✓ Java built
✓ Python built
✓ Typescript built
✓ Doc built
SDKs downloaded successfully. You can find them inside the "output" folder
? Would you like to approve and publish these docs now? (Y/n)
|Approve docs without review. This will skip the docs review process and publish the docs automatically to the liblab docs site. This is used when running |
|Skip spec validation and attempt to build the SDKs. This is not recommended - if there are warnings or errors in the spec that you want to ignore, it is best practice to add these to the config file. You can read more on ignoring validation issues in the |