Skip to content

Hooks

Some hooks that can be used with @kubb/plugin-oas.
See Oas to understand how to use the Oas instance or the Oas schemas.

useOas

useOas will return the Oas instance.

tsx
import { 
useOas
} from '@kubb/plugin-oas/hooks'
function
Component
() {
const
oas
=
useOas
()
return null }

useOperation

useOperation will return the current Operation.

tsx
import { 
useOperation
} from '@kubb/plugin-oas/hooks'
function
Component
() {
const
operation
=
useOperation
()
const {
path
,
method
,
schema
,
contentType
,
getRequestBody
,
getOperationId
} =
operation
;
return null }

useOperations

useOperations will return all the Operations.

tsx
import { 
useOperations
} from '@kubb/plugin-oas/hooks'
function
Component
() {
const
operations
=
useOperations
()
return null }

useOperationManager

useOperationManager will return some helper functions that can be used to get the operation file, get the operation name.

tsx
import { 
useOperationManager
} from '@kubb/plugin-oas/hooks'
function
Component
() {
const {
getFile
,
getName
,
getSchemas
,
groupSchemasByByName
} =
useOperationManager
()
return null }

Released under the MIT License.