Skip to content

feat: support OpenAPI 3.2 itemSchema (SSE/streaming)#2683

Open
dkachur1 wants to merge 2 commits intoopenapi-ts:mainfrom
dkachur1:feat/support-openapi-itemSchema
Open

feat: support OpenAPI 3.2 itemSchema (SSE/streaming)#2683
dkachur1 wants to merge 2 commits intoopenapi-ts:mainfrom
dkachur1:feat/support-openapi-itemSchema

Conversation

@dkachur1
Copy link

@dkachur1 dkachur1 commented Mar 13, 2026

This adds support for the itemSchema field introduced in OpenAPI 3.2, which defines the shape of individual items in streaming responses like text/event-stream.

What changed

  • MediaTypeObject now recognizes itemSchema. When present, it takes precedence over schema for type generation.
  • Upgraded @redocly/openapi-core to v2 to support OAS 3.2 parsing.

Example

OpenAPI 3.2

  "200":
    content:
      text/event-stream:
        itemSchema:
          oneOf:
            - type: object
              properties:
                type: { type: string, enum: [content] }
                text: { type: string }
              required: [type, text]
            - type: object
              properties:
                type: { type: string, enum: [done] }
              required: [type]

Generates:

  "text/event-stream": {
      type: "content";
      text: string;
  } | {
      type: "done";
  };

What's supported

  • itemSchema with objects, primitives, arrays, enums, oneOf, allOf
  • itemSchema with $ref to component schemas
  • Mixed responses (application/json with schema + text/event-stream with itemSchema)
  • Backward compatible — specs without itemSchema work exactly as before

Test plan

  • Unit tests for transformMediaTypeObject (precedence, fallback, backward compat)
  • Integration tests through response and request body transforms
  • E2E test with $ref resolution in itemSchema
  • E2E test with a full OpenAPI 3.2 YAML fixture covering SSE endpoints with oneOf, enums, and POST request bodies

This is my first open source contribution — I'm a student, so any feedback is very welcome!

@dkachur1 dkachur1 requested a review from a team as a code owner March 13, 2026 21:43
@dkachur1 dkachur1 requested a review from gzm0 March 13, 2026 21:43
@netlify
Copy link

netlify bot commented Mar 13, 2026

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit d745f04

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: d745f04

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openapi-typescript Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant