Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OpenAPI 3.1 support #8367

Merged
merged 30 commits into from Feb 3, 2023
Merged

feat: OpenAPI 3.1 support #8367

merged 30 commits into from Feb 3, 2023

Conversation

tim-lai
Copy link
Contributor

@tim-lai tim-lai commented Feb 3, 2023

Description

OpenAPI 3.1 Additions:

  • New top-level field - webhooks. This allows describing out-of-band webhooks that are available as part of the API.

  • New top-level field - jsonSchemaDialect. This allows defining of a default $schema value for Schema Objects

  • The Info Object has a new summary field.

  • The License Object now has a new identifier field for SPDX licenses. This identifier field is mutually exclusive with the url field. Either can be used in OpenAPI 3.1 definitions.

  • Components Object now has a new entry pathItems, to allow for reusable Path Item Objects to be defined within a valid OpenAPI document.

SwaggerUI changes

  • License and Contact components are now exported and available via getComponent
  • New version predicates and selectors for isOpenAPI30 and isOpenAPI31. This avoids needing to change the usage of isOAS3 selector.
  • New OAS3 components: Webhooks
  • New OAS3 wrapped components: Info, License
  • Increased allowable build size from 1.1 MB to 1.3 MB. This is to accommodate the new apidom dependency in swagger-client.
  • Note on version convention: In general, OpenAPI 3.1 is additive to OpenAPI 3.0, however, any updates that must be restricted to OpenAPI 3.0 is still possible. Choice of convention was made to avoid adding min-<version>, max-<version>, or only-<version> until deemed necessary. Related to this, the new webhooks and wrapped Info/License are "attached" to the existing OAS3 plugin, rather than residing within a separate OAS31 plugin.

Dependency Changes

  • apidom is now bundled with SwaggerUI via swagger-client. This has a net effect of increasing the bundle size by ~0.15 MiB.
  • downstream projects may need to note the following overrides in package.json for their CI tests/builds:
"overrides": {
    "swagger-client": {
      "@swagger-api/apidom-reference": {
        "axios": "npm:-@0.0.1"
      }
    }
  },

Motivation and Context

Add OpenAPI 3.1 support. This first PR add new "additional features" per https://github.com/OAI/OpenAPI-Specification/releases

Replaces draft PR #8361

How Has This Been Tested?

new Cypress E2E tests, including comparison checks against OpenAPI2, OpenAPI3.0, and OpenAPI3.1.

Single Jest unit test suite updated to reflect newly exported License component

Prior to merging into next branch, CI run against the master branch successfully

Screenshots (if appropriate):

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.

tim-lai and others added 30 commits December 2, 2022 13:51
* temp isOAS3 rule relaxation
* also remove the oas3.1 summary field
@tim-lai tim-lai changed the base branch from master to next February 3, 2023 22:02
@tim-lai tim-lai merged commit 4557b24 into next Feb 3, 2023
@tim-lai tim-lai mentioned this pull request Feb 3, 2023
17 tasks
swagger-bot pushed a commit that referenced this pull request Feb 14, 2023
# [4.16.0-alpha.1](v4.15.5...v4.16.0-alpha.1) (2023-02-14)

### Features

* OpenAPI 3.1 support ([#8367](#8367)) ([4557b24](4557b24))
@swagger-bot
Copy link
Contributor

🎉 This PR is included in version 4.16.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Kulikovpavel
Copy link

@tim-lai
It seems that isOAS3 helper by some reason not in master branch, and not in 4.17.0 release.
So openapi 3.1 is unusable.
Is this OK?
https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/oas3/helpers.jsx

@opqdonut
Copy link

Looks like the support won't be out until version 5. I just tried v5.0.0-alpha.0 and it worked with OpenAPI 3.1.0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants