Content-Type Support
Industry-Leading Content-Type Coverage
liblab provides support for HTTP content types across all our SDK languages, covering 99%+ of real-world use cases. Whether you're building SDKs for TypeScript, Python, C#, Java, Go, or PHP, liblab ensures your APIs can handle virtually any content type your users need.
Common Supported Content Types
liblab SDKs supports content types that cover more than 99% of use cases. The following is a list of some common types supported by liblab SDKs in both requests and responses:
| Content Type | Description | Common Use Cases |
|---|---|---|
application/json | JSON data format | REST APIs, configuration data, structured data exchange |
application/<type>+json | JSON-based custom types | Custom JSON variants, API-specific JSON formats |
application/x-www-form-urlencoded | URL-encoded form data | HTML forms, simple key-value data |
multipart/form-data | Multipart form data | File uploads, mixed content forms |
text/plain | Plain text | Simple text responses, log files, plain messages |
text/html | HTML content | Web pages, formatted text |
text/xml | XML data | SOAP APIs, legacy systems, structured documents |
text/javascript | JavaScript code | Script delivery, dynamic code |
application/xml | XML data (alternate) | SOAP APIs, structured data |
application/octet-stream | Binary data | File downloads, arbitrary binary content |
application/pdf | PDF documents | Document generation, reports |
image/png | PNG images | Image processing, uploads |
image/jpeg | JPEG images | Photo uploads, image APIs |
image/gif | GIF images | Animation, graphics |
*/* | Wildcard (any type) | Flexible endpoints accepting multiple formats |
Content-Type in Open API Specs
Content-Types are specified under each requestBody and response. An example of application/json
inside a requestBody and response can be found below.
paths:
/users:
post:
requestBody:
required: true
content:
application/json: <---------
schema:
type: object
properties:
name:
type: string
email:
type: string
responses:
'200':
description: User created successfully
content:
application/json: <----------
schema:
type: object
properties:
id:
type: string
name:
type: string
Why Content-Type Specifications Matter
Proper content-type specifications in your API specifications are crucial for several reasons:
1. Type Safety and Validation
When your API spec clearly defines content types, liblab can generate SDKs with proper type checking and validation. This helps catch errors at development time rather than runtime:
- Strong typing: Generated code uses appropriate types for different content formats
- Automatic serialization: SDKs handle conversion between native types and wire formats
- Validation: Input validation based on expected content types
2. Developer Experience
Clear content-type specifications improve the developer experience when using your SDK:
- IntelliSense support: IDEs can provide better autocomplete and type hints
- Self-documenting code: Developers immediately understand what format to expect
- Reduced errors: Type safety prevents common mistakes like passing wrong data formats
3. Interoperability
Standardized content types ensure your API works correctly across different platforms:
- Cross-language consistency: All SDKs handle content types the same way
- Browser compatibility: Web-based integrations work seamlessly
- Tool compatibility: API testing tools and proxies handle requests correctly
4. Documentation Quality
Content-type specifications enhance your generated documentation:
- Clear examples: Documentation shows correct content type usage
- Request/response samples: Examples use appropriate formats
- Better understanding: Developers quickly grasp how to use your API
Language-Specific Support
liblab's content-type support is consistent across all supported languages:
Each language SDK handles content types idiomatically, using native language features for serialization, deserialization, and type safety.