Skip to content

fix(openapi-3-2): add missing [ComponentsMediaTypesElement.primaryClass] query to replace-empty-element plugin #5120

@robert-hebel-sb

Description

@robert-hebel-sb

Description

In packages/apidom-ns-openapi-3-2/src/refractor/plugins/replace-empty-element.ts, the ComponentsMediaTypesElement NCE (Non-Concrete Element) — new in OAS 3.2 — is correctly imported and referenced in the ComponentsElement section (line 345). However, unlike other NCE elements, there is no corresponding [ComponentsMediaTypesElement.primaryClass] entry in the dynamic key-based NCE schema section.

Expected Behavior

A [ComponentsMediaTypesElement.primaryClass] entry should exist in the NCE section (alongside [ComponentsPathItemsElement.primaryClass], [WebhooksElement.primaryClass], etc.) to handle empty-node replacement for this element type.

Actual Behavior

ComponentsMediaTypesElement only appears at:

  • Line 78: import
  • Line 345: used inside ComponentsElement block

There is no [ComponentsMediaTypesElement.primaryClass] entry in the NCE section (around line 505+).

Reference

Raised in PR #5110, comment: #5110 (comment)

Suggested Fix

Add the following entry to the NCE section of the schema (after [ComponentsPathItemsElement.primaryClass]):

[ComponentsMediaTypesElement.primaryClass]: {
  '[key: *]': function key(...args: any[]) {
    return new MediaTypeElement(...args);
  },
},

(The element type mapped by [key: *] should be verified against the OAS 3.2 spec for the components/mediaTypes field.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions