kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
0157870fcf
commit
ea4b96be45
|
@ -1,2 +1,3 @@
|
|||
export * from './redocly-config'
|
||||
export type * from './types'
|
||||
export * from './validate-openapi-spec'
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import {
|
||||
type Config as RedoclyConfig,
|
||||
createConfig
|
||||
} from '@redocly/openapi-core'
|
||||
|
||||
// Cache the default Redocly config to avoid re-creating it on every call
|
||||
let _defaultRedoclyConfig: RedoclyConfig | undefined
|
||||
|
||||
export async function getDefaultRedoclyConfig(): Promise<RedoclyConfig> {
|
||||
if (!_defaultRedoclyConfig) {
|
||||
_defaultRedoclyConfig = await createConfig(
|
||||
{
|
||||
rules: {
|
||||
// throw error on duplicate operationIds
|
||||
'operation-operationId-unique': { severity: 'error' }
|
||||
}
|
||||
},
|
||||
{ extends: ['minimal'] }
|
||||
)
|
||||
}
|
||||
|
||||
return _defaultRedoclyConfig
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
export type Logger = Pick<Console, 'debug' | 'info' | 'warn' | 'error'>
|
||||
|
||||
// OpenAPI types are taken from https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/types.ts
|
||||
// These loose OpenAPI types are taken from https://github.com/openapi-ts/openapi-typescript/blob/main/packages/openapi-typescript/src/types.ts
|
||||
|
||||
// Note: these OpenAPI types are meant only for internal use, not external
|
||||
// consumption. Some formatting may be better in other libraries meant for
|
||||
|
|
|
@ -3,7 +3,6 @@ import {
|
|||
BaseResolver,
|
||||
bundle,
|
||||
type Config as RedoclyConfig,
|
||||
createConfig,
|
||||
type Document,
|
||||
lintDocument,
|
||||
type NormalizedProblem,
|
||||
|
@ -11,6 +10,7 @@ import {
|
|||
} from '@redocly/openapi-core'
|
||||
|
||||
import type { Logger, LooseOpenAPI3Spec } from './types'
|
||||
import { getDefaultRedoclyConfig } from './redocly-config'
|
||||
|
||||
/**
|
||||
* Validates an OpenAPI spec and bundles it into a single, normalized schema.
|
||||
|
@ -32,15 +32,7 @@ export async function validateOpenAPISpec(
|
|||
} = {}
|
||||
): Promise<LooseOpenAPI3Spec> {
|
||||
if (!redoclyConfig) {
|
||||
redoclyConfig = await createConfig(
|
||||
{
|
||||
rules: {
|
||||
// throw error on duplicate operationIds
|
||||
'operation-operationId-unique': { severity: 'error' }
|
||||
}
|
||||
},
|
||||
{ extends: ['minimal'] }
|
||||
)
|
||||
redoclyConfig = await getDefaultRedoclyConfig()
|
||||
}
|
||||
|
||||
const resolver = new BaseResolver(redoclyConfig.resolve)
|
||||
|
|
Ładowanie…
Reference in New Issue