-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Support empty media type objects (no schema, no examples)
Summary
OpenAPI specs with completely empty media type objects (application/json: {}) fail generation with "empty schema not implemented" error. This is a valid OpenAPI pattern for responses where the structure is unknown, unspecified, or intentionally flexible.
Specs Affected
carriers/jitsu/specs/openapi.yaml- 19 locations with empty response content- Common in real-world APIs for default error responses or flexible success responses
Current Behavior
Minimal Reproduction
openapi: 3.0.1
info:
title: Empty Media Type Test
version: 1.0.0
paths:
/shipments:
post:
operationId: createShipment
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
tracking_number:
type: string
responses:
default:
description: Default response
content:
application/json: {}
'200':
description: Success
content:
application/json: {}Error Output
Feature "empty schema" is not implemented yet.
ignore_not_implemented: ["empty schema"]
to skip unsupported operations.
Impact
- Cannot generate complete clients for APIs with unspecified response structures
- Requires using
ignore_not_implemented: ["empty schema"]workaround - Skips entire operations rather than generating them with
anytype responses
Expected Behavior
When encountering application/json: {} (empty media type object):
-
Generate as
anytype:type CreateShipmentOK any type CreateShipmentDefault any
-
Or use empty struct for zero-schema responses:
type CreateShipmentOK struct{} type CreateShipmentDefault struct{}
-
Allow configuration:
generator: empty_schema_handling: "any" # or "empty_struct" or "skip"
Use Cases
Empty media type objects are valid in OpenAPI 3.x for:
- Default error responses: Structure varies or is vendor-specific
- Flexible success responses: API returns different shapes based on context
- Legacy APIs: Documentation incomplete but API functional
- Passthrough endpoints: Proxy/gateway patterns
Real-World Example (Jitsu API)
paths:
/v3/parcels/{id}:
delete:
operationId: deleteParcel
responses:
default:
description: default response
content:
application/json: {} # Error structure unspecified
2XX:
description: default response
content:
application/json: {} # Success - may be empty or varyComparison with Upstream
Checked ogen-go/ogen - this pattern also fails there. This is a general OpenAPI spec handling gap.
Proposed Solution
Option 1: Generate as interface{}/any (Recommended)
- Treat
{}media type as schema-less response - Generate Go type as
any(Go 1.18+) orinterface{} - Allows clients to decode arbitrary JSON
Option 2: Generate as empty struct
- For responses with no expected body
- Matches semantics of HTTP 204 No Content
Option 3: Make configurable
generator:
empty_media_type_handling:
mode: "any" # or "empty_struct" or "skip"
# Optional: per-status-code rules
status_rules:
default: "any"
2XX: "empty_struct"Workaround (Current)
Add to ogen.yml:
generator:
ignore_not_implemented:
- "empty schema"Limitation: This skips the entire operation, preventing client generation for that endpoint.
OpenAPI Spec Compliance
Per OpenAPI 3.0.3 Media Type Object:
schemafield is OPTIONALexamplesfield is OPTIONAL- Empty media type object
{}is valid - means content is present but structure is unspecified
Test Command
ogen --target /tmp/test --clean empty-media-type-test.yamlExpected: Generate client with any typed responses
Actual: Fails with "empty schema not implemented"