Skip to main content

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 TypeDescriptionCommon Use Cases
application/jsonJSON data formatREST APIs, configuration data, structured data exchange
application/<type>+jsonJSON-based custom typesCustom JSON variants, API-specific JSON formats
application/x-www-form-urlencodedURL-encoded form dataHTML forms, simple key-value data
multipart/form-dataMultipart form dataFile uploads, mixed content forms
text/plainPlain textSimple text responses, log files, plain messages
text/htmlHTML contentWeb pages, formatted text
text/xmlXML dataSOAP APIs, legacy systems, structured documents
text/javascriptJavaScript codeScript delivery, dynamic code
application/xmlXML data (alternate)SOAP APIs, structured data
application/octet-streamBinary dataFile downloads, arbitrary binary content
application/pdfPDF documentsDocument generation, reports
image/pngPNG imagesImage processing, uploads
image/jpegJPEG imagesPhoto uploads, image APIs
image/gifGIF imagesAnimation, 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.