Skip to content

Support RFC 6839 +json suffix for vendor MIME types #133

Description

@szhajdu

Problem

The generator only supports a hardcoded list of content types (application/json, application/vnd.api+json, application/xml, application/x-www-form-urlencoded). Many APIs return vendor-specific JSON MIME types that follow the RFC 6839 structured syntax suffix convention, such as:

  • application/vnd.sdmx.data+json (European Central Bank API)
  • application/hal+json (HAL)
  • application/ld+json (JSON-LD)
  • application/problem+json (RFC 7807)

Currently, using these content types in an OpenAPI spec results in:

Error on mapping operationName: Response content-type ["application/vnd.sdmx.data+json"] is not currently supported.

Reproduction

responses:
  "200":
    description: Success
    content:
      application/vnd.sdmx.data+json:
        schema:
          $ref: "#/components/schemas/MySchema"

Proposed Solution

Per https://datatracker.ietf.org/doc/html/rfc6839, MIME types with a +json suffix indicate JSON-based formats. The generator should:

  1. Accept +json suffixed types during generation (src/Entity/Request.php, src/Entity/Response.php)
  2. Fall back to JSON serializer at runtime for any +json type (src/Output/Copy/Serializer/BodySerializer.php)
  3. Auto-register JSON serializer when any +json type is detected (src/Generator/ServiceProviderGenerator.php)

This approach is:

  • RFC compliant
  • Backwards compatible
  • Requires no configuration
  • Automatically supports all vendor JSON formats

I'm happy to submit a PR for this if the approach sounds reasonable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions