Skip to content

feat: add support for mediaTypes in OAS 3.2#2524

Merged
n0rahh merged 13 commits intomainfrom
feat/add-support-for-media-types
Feb 6, 2026
Merged

feat: add support for mediaTypes in OAS 3.2#2524
n0rahh merged 13 commits intomainfrom
feat/add-support-for-media-types

Conversation

@n0rahh
Copy link
Contributor

@n0rahh n0rahh commented Jan 30, 2026

What/Why/How?

Added bundling support for OpenAPI 3.2 components/mediaTypes references used in request and response content.

Reference

OpenAPI 3.2 support
openapi-docs changes

Testing

Screenshots (optional)

Check yourself

  • Code changed? - Tested with Redoc/Realm/Reunite (internal)
  • All new/updated code is covered by tests
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

🦋 Changeset detected

Latest commit: a1f0cbb

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

This PR includes changesets to release 3 packages
Name Type
@redocly/openapi-core Minor
@redocly/cli Minor
@redocly/respect-core 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

@n0rahh n0rahh added the snapshot Create experimental release PR label Jan 30, 2026
@github-actions
Copy link
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1769775283 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1769775283
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1769775283
# or
npm install @redocly/respect-core@0.0.0-snapshot.1769775283

⚠️ Note: This is a development build and may contain unstable features.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.6% (🎯 78%) 6137 / 7807
🔵 Statements 78.04% (🎯 78%) 6343 / 8127
🔵 Functions 82.34% (🎯 82%) 1250 / 1518
🔵 Branches 70.34% (🎯 70%) 4191 / 5958
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/visitors.ts 92.94% 90.12% 90% 92.5% 556, 593, 596, 617, 649, 663
packages/core/src/bundle/bundle-visitor.ts 68.59% 63.84% 100% 68.59% 24, 28-36, 43-51, 58, 67, 75, 80-101, 166-178, 195-196, 209-210, 247
packages/core/src/decorators/oas3/remove-unused-components.ts 97.61% 88.88% 100% 100% 90
packages/core/src/rules/oas3/no-unused-components.ts 95% 70% 100% 100% 29
packages/core/src/types/oas3_2.ts 57.14% 0% 0% 57.14% 67-154
packages/core/src/utils/oas-has-component.ts 100% 100% 100% 100%
Generated in workflow #8522 for commit a1f0cbb by the Vitest Coverage Report Action

@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.597s ± 0.065s ▓ 1.00x (Fastest)
cli-next 3.615s ± 0.030s ▓ 1.00x

@n0rahh n0rahh marked this pull request as ready for review February 2, 2026 13:13
@n0rahh n0rahh requested review from a team as code owners February 2, 2026 13:13
@n0rahh n0rahh requested a review from tatomyr February 4, 2026 08:39
Copy link
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of minor comments.

@n0rahh n0rahh requested a review from tatomyr February 5, 2026 08:42
Copy link
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more round, and we're good to go, I believe.

});
expect(parsed.paths?.['/pets']?.get?.responses?.['200']?.content).toEqual({
$ref: '#/components/mediaTypes/JsonPets',
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really challenging to read those expects. Could you use inline snapshots instead? Same in other places.

Comment on lines 1 to 17
openapi: 3.2.0
components:
mediaTypes:
JsonPets:
'application/json':
schema:
type: object
properties:
id:
type: integer
name:
type: string
examples:
example1:
value:
id: 1
name: John
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to wrap it into OpenAPI, it could be literally what you need:

      application/json:
        schema:
          type: object
          properties:
            id:
              type: integer
        examples:
          Test:
            value:
              id: 1

description: OK
content:
$ref: ./media-types.yaml#/components/mediaTypes/JsonPets
components:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you need components for? Please keep your tests minimal so it's easier to read them and understand the purpose. Avoid unnecessary fields (like summary and operationId since they are not needed for this particular test), and don't use strange naming like 'pets', just stick to foo, bar, test, user, etc., or some other general names.
This also applies to other test samples.

@n0rahh n0rahh requested a review from tatomyr February 6, 2026 08:38
Copy link
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much cleaner, thank you!

@n0rahh n0rahh merged commit 8bf9c4c into main Feb 6, 2026
40 checks passed
@n0rahh n0rahh deleted the feat/add-support-for-media-types branch February 6, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot Create experimental release PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants