SDK structure and documentation
When creating new SDKs, liblab generates a folder for each language you've chosen to create an SDK for. Understanding the structure of these generated folders is critical to making the most of your SDKs. Whether you're helping end users integrate seamlessly with your API or using the SDK in your own development, knowing how everything is organized will ensure smoother implementation.
This guide provides an overview of the common elements across all SDKs created by liblab, along with language-specific details for each supported programming language.
Common SDK structure
liblab-generated SDKs follow a consistent structure across different programming languages, making it easier to work with multiple SDKs. Each SDK includes the following key components:
LICENSE
The LICENSE
file outlines the SDK's licensing terms and usage guidelines, ensuring that users understand their rights and obligations when using the software.
README
The README.md
file is the starting point for integrating the SDK. It provides guidance on how to get up and running with the SDK and the API it wraps. The content is customized for each SDK’s programming language, ensuring that the examples and instructions follow best practices. Typically, this file includes:
- Installation Instructions: Step-by-step guidance on how to install the SDK in your target environment.
- Authentication Setup: Instructions on setting up authentication to securely access the API.
- Sample Usage: Code snippets that show how to interact with the API, helping users quickly grasp and implement key functionality.
- Documentation Overview: Links to in-depth documentation within the SDK covering services and models that provide detailed insights into the available API resources and operations. The services documentation also features SDK code snippets for each endpoint, enabling users to quickly integrate and start using the SDK.
Documentation folder
The documentation
folder is a crucial part of each SDK, containing detailed Markdown files that cover the resources and methods defined in the API specification. These files are linked from the README.md
to offer basic documentation for interacting with the API via the SDK. This structure is especially beneficial when hosting your SDK on platforms like GitHub, where Markdown files are rendered for easy navigation and accessibility. The folder includes the following subfolders:
models
: Contains the API resources, representing the data structures defined in the API specification.services
: Provides detailed documentation of the methods and operations available for each resource, guiding users on how to interact with API endpoints. This section includes SDK code snippets for every endpoint, enabling users to quickly integrate and execute API requests using the SDK.snippets
: An optional folder that contains SDK code snippets for every API endpoint call, designed for easy integration into your existing API documentation. Depending on your configuration, this folder may include the snippets as multiple Markdown files or a single JSON file. It is generated if you configure liblab to include SDK snippets in the documentation.
Example folder
Each SDK includes an examples
(or Example
) folder to help you quickly get started. Inside, you'll find a simple, runnable example code demonstrating how to use the SDK to call an API endpoint. This allows you to test the SDK without having to build an application yourself.
Source Code Organization (src)
Most SDKs include a src
folder or one named after the sdkName
value in your liblab configuration file. This folder holds the core implementation of the SDK, organized into the following subfolders:
models
: Contains classes that represent the data structures defined in the API spec (e.g.,Pet
,Category
).services
: Contains classes with methods to interact with the API endpoints, aligning with the operations specified in the API spec.
The SDK's structure makes it easier to find and work with different SDK parts, whether adding new features or debugging existing ones.
Common SDK structures
A separate folder will be generated for each SDK language specified in your liblab configuration file. The liblab configuration file provides the following languages as examples:
- C#
- Python
- TypeScript
- GO
csharp
├── documentation
│ ├── models
│ │ ├── ApiResponse.md
│ │ ├── Category.md
│ │ ├── FindPetByStatusStatus.md
│ │ ├── Order.md
│ │ ├── Pet.md
│ │ ├── Tag.md
│ │ ├── UpdatePetWithFormRequest.md
│ │ └── UploadFileRequest.md
│ │ └── User.md
│ ├── services
│ │ ├── PetService.md
│ │ ├── StoreService.md
│ │ └── UserService.md
│ └── snippets
│ └── snippets.json
├── Example
│ ├── Example.csproj
│ └── Program.cs
├── MyEx1Sdk
│ ├── ...
│ ├── Models
│ └── Services
├── .manifest.json
├── install.sh
├── LICENSE
└── README.md
python
├── documentation
│ ├── models
│ │ ├── ApiResponse.md
│ │ ├── Category.md
│ │ ├── FindPetByStatusStatus.md
│ │ ├── Order.md
│ │ ├── Pet.md
│ │ ├── Tag.md
│ │ ├── UpdatePetWithFormRequest.md
│ │ └── UploadFileRequest.md
│ │ └── User.md
│ ├── services
│ │ ├── PetService.md
│ │ ├── StoreService.md
│ │ └── UserService.md
│ └── snippets
│ └── snippets.json
├── examples
│ ├── install.cmd
│ ├── install.sh
│ └── sample.py
└── src
└── my_ex1_sdk
├── models
├── ...
└── services
├── .manifest.json
├── install.cmd
├── install.sh
├── LICENSE
├── pyproject.toml
└── README.md
typescript
├── documentation
│ ├── models