Skip to content

feat(oas31/style): array items label to schema name (#10794)#10795

Open
adrianodpdiaz wants to merge 8 commits intoswagger-api:masterfrom
adrianodpdiaz:feat/array-items-label-to-schema-name
Open

feat(oas31/style): array items label to schema name (#10794)#10795
adrianodpdiaz wants to merge 8 commits intoswagger-api:masterfrom
adrianodpdiaz:feat/array-items-label-to-schema-name

Conversation

@adrianodpdiaz
Copy link
Copy Markdown
Contributor

Description

In the OAS 3.1 model viewer, when a schema has an array property whose items points to a $ref, the label for the items entry was hardcoded to Items regardless of the referenced schema name. This change makes it display the actual referenced schema name (e.g. User) instead, bringing it in line with the OAS 3.0 UI.

Motivation and Context

#10794

How Has This Been Tested?

  • Added unit tests for makeGetTitle covering all relevant cases (test/unit/core/plugins/oas31/json-schema-2020-12-extensions/fn.js)
  • Added Cypress E2E tests verifying the label renders the referenced schema name in the browser (test/e2e-cypress/e2e/features/oas31-array-items-label.cy.js)
  • Manually verified in the development server (npm run dev) with an OAS 3.1 spec containing array properties with $ref items — the label now shows the schema name instead of Items
  • Verified that array properties with anonymous inline items schemas still show Items as fallback

Screenshots:

BEFORE:
list_items_oas31

AFTER:
list_items_oas31_after

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@adrianodpdiaz adrianodpdiaz changed the title Feat/array items label to schema name feat(oas31/style): array items label to schema name Apr 2, 2026
@adrianodpdiaz adrianodpdiaz changed the title feat(oas31/style): array items label to schema name feat(oas31/style): array items label to schema name (#10794) Apr 2, 2026
Comment thread src/core/plugins/oas31/json-schema-2020-12-extensions/fn.js
lukaszzazulak
lukaszzazulak previously approved these changes Apr 17, 2026
@lukaszzazulak lukaszzazulak self-requested a review April 17, 2026 13:18
@lukaszzazulak
Copy link
Copy Markdown
Contributor

@adrianodpdiaz apparently, it is not that simple, see here #9540

@lukaszzazulak lukaszzazulak removed their request for review April 17, 2026 13:21
@adrianodpdiaz
Copy link
Copy Markdown
Contributor Author

adrianodpdiaz commented Apr 27, 2026

@adrianodpdiaz apparently, it is not that simple, see here #9540

Thanks for this link, it is more interesting than I thought!

I see the concern about OAS 3.1 refs not having the same identity semantics as OAS 3.0 Reference Objects. For this PR, I was looking at a narrower UI case: array items labels. If items points to #/components/schemas/User, showing User is much more useful than the generic Items label.

That said, after reading the discussion, I agree this should probably only happen when the referencing Schema Object has a single $ref keyword and directly references a schema from components.schemas. In other cases, especially when there are sibling keywords, the label could imply more than it should.

Right now Swagger UI only gets $$ref from the resolved schema, which tells us where it came from, but not whether the original referencing schema was a plain $ref or a $ref with siblings. So I opened a feature request in swagger-client for that missing metadata: swagger-api/swagger-js#4201

I think the safer path is to get that resolver metadata first, then update this PR to render the array item model name only for the clear single $ref / direct components.schemas case.

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.

show referenced schema name instead of "Items" for array items with OAS 3.1.x UI

2 participants