swagger-api / swagger-api/apidom

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

Open Beginner friendly
#5,120 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement OpenAPI 3.2
Dominant language
TypeScript
Stars
100
Forks
26
Avg merge
14h 36m
Merged PRs (30d)
22

Description

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: https://github.com/swagger-api/apidom/pull/5110#discussion_r2846071887

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.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open packages/apidom-ns-openapi-3-2/src/refractor/plugins/replace-empty-element.ts and inspect the NCE schema section around line 505, comparing neighboring entries such as ComponentsPathItemsElement and WebhooksElement. Verify the expected element mapping for components/mediaTypes against the OAS 3.2 specification, then confirm that empty-node replacement is covered for ComponentsMediaTypesElement.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.