Skip to content

Support wildcard content types (*/*, application/*) #2

@lanej

Description

@lanej

Many real-world APIs use wildcard content types like */* or application/* in their OpenAPI specs to indicate they accept/return any content type (typically JSON). ogen currently fails with "unsupported content type" error.

Specs Affected

  • carriers/jitsu/specs/openapi.yaml (14 occurrences of */*)
  • carriers/nshift/specs/openapi.yaml (3 occurrences of */*)

Current Error

Content type "*/*" is unsupported.

Try to create ogen.yml with:

generator:
	ignore_not_implemented: ["unsupported content types"]

to skip unsupported operations.

Example OpenAPI Spec

paths:
  /shipments:
    post:
      operationId: createShipment
      requestBody:
        required: true
        content:
          '*/*':  # Wildcard content type
            schema:
              $ref: '#/components/schemas/Shipment'
      responses:
        '201':
          description: Shipment created
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/Shipment'

Minimal Reproduction

openapi: 3.0.1
info:
  title: Wildcard Content Type Test
  version: 1.0.0
paths:
  /test:
    post:
      operationId: testWildcard
      requestBody:
        required: true
        content:
          '*/*':
            schema:
              type: object
              properties:
                name:
                  type: string
      responses:
        '200':
          description: Success
          content:
            '*/*':
              schema:
                type: object
                properties:
                  id:
                    type: string

Test: ogen --target /tmp/test --clean test.yaml

Proposed Solution

Add content type mapping in ogen.yml:

generator:
  content_types:
    # Map wildcard to specific type
    '*/*': 'application/json'
    'application/*': 'application/json'

Or implement automatic fallback:

  • If both request and response use */* → assume application/json
  • If mixed (one */*, one specific) → use the specific type
  • Allow users to configure preferred fallback type

Expected

Map */* to a specific content type (preferably application/json by default)

Actual

Generation fails unless operation is skipped via ignore_not_implemented

Impact

  • Cannot generate clients for ~15% of real-world carrier/logistics APIs
  • Workaround requires skipping entire operations, losing API coverage

OpenAPI Spec Reference

The OpenAPI 3.x spec allows wildcards in media types: https://spec.openapis.org/oas/v3.0.3#media-type-object

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions