refactor(oas31): use OpenAPI 3.1 specific component wrapper util (#8503)

This commit is contained in:
Vladimír Gorej
2023-03-23 10:55:41 +01:00
committed by GitHub
parent 16224263d1
commit e1816a5937
5 changed files with 47 additions and 34 deletions

View File

@@ -1,6 +1,7 @@
/**
* @prettier
*/
import React from "react"
export const isOAS31 = (jsSpec) => {
const oasVersion = jsSpec.get("openapi")
@@ -70,3 +71,20 @@ export const createSystemSelector =
? selectedValue(system)
: selectedValue
}
/* eslint-disable react/jsx-filename-extension */
export const createOnlyOAS31ComponentWrapper =
(Component) => (Original, system) => (props) => {
if (system.specSelectors.isOAS31()) {
return (
<Component
{...props}
originalComponent={Original}
getSystem={system.getSystem}
/>
)
}
return <Original {...props} />
}
/* eslint-enable react/jsx-filename-extension */