Skip to content

fix: render arrays with boolean false item schemas#10922

Open
cyphercodes wants to merge 1 commit into
swagger-api:masterfrom
cyphercodes:fix/oas31-tuple-items-false
Open

fix: render arrays with boolean false item schemas#10922
cyphercodes wants to merge 1 commit into
swagger-api:masterfrom
cyphercodes:fix/oas31-tuple-items-false

Conversation

@cyphercodes

Copy link
Copy Markdown

Description

Guard the array item schema type lookup so JSON Schema boolean schemas such as items: false do not throw while rendering nested array parameters.

Adds a regression test for an OpenAPI 3.1-style tuple schema using prefixItems with items: false.

Motivation and Context

Fixes #10921.

OpenAPI 3.1 uses JSON Schema 2020-12, where tuple schemas can disallow additional items with items: false. Rendering the parameter form reached schemaItems?.get("type"); because boolean schemas do not implement get, the endpoint details crashed instead of rendering.

How Has This Been Tested?

  • npm run test:unit -- --runTestsByPath test/unit/core/plugins/json-schema-5/components/json-schema-form.jsx --runInBand
  • ./node_modules/.bin/eslint --quiet src/core/plugins/json-schema-5/components/json-schema-components.jsx test/unit/core/plugins/json-schema-5/components/json-schema-form.jsx
  • git diff --check

Screenshots (if appropriate):

N/A

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.

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.

OpenAPI 3.1.x schema with tuple restrictions on additional items throws an error and does not render.

1 participant