@kubb/adapter-oas 5.0.0-beta.38 → 5.0.0-beta.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/adapter-oas",
3
- "version": "5.0.0-beta.38",
3
+ "version": "5.0.0-beta.39",
4
4
  "description": "OpenAPI and Swagger adapter for Kubb. Parses and validates OAS 2.0/3.x specifications into a @kubb/ast RootNode for downstream code generation plugins.",
5
5
  "keywords": [
6
6
  "adapter",
@@ -47,7 +47,7 @@
47
47
  "oas": "^32.1.18",
48
48
  "oas-normalize": "^16.0.4",
49
49
  "swagger2openapi": "^7.0.8",
50
- "@kubb/core": "5.0.0-beta.38"
50
+ "@kubb/core": "5.0.0-beta.39"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/swagger2openapi": "^7.0.4",
package/src/factory.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path'
2
2
  import { exists, mergeDeep, URLPath } from '@internals/utils'
3
- import { diagnosticCode, DiagnosticError } from '@kubb/core'
3
+ import { Diagnostics } from '@kubb/core'
4
4
  import type { AdapterSource } from '@kubb/core'
5
5
  import { bundle, loadConfig } from '@redocly/openapi-core'
6
6
  import OASNormalize from 'oas-normalize'
@@ -78,8 +78,8 @@ export async function mergeDocuments(pathOrApi: Array<string | Document>): Promi
78
78
  const documents = await Promise.all(pathOrApi.map((p) => parseDocument(p, { enablePaths: false, canBundle: false })))
79
79
 
80
80
  if (documents.length === 0) {
81
- throw new DiagnosticError({
82
- code: diagnosticCode.inputRequired,
81
+ throw new Diagnostics.Error({
82
+ code: Diagnostics.code.inputRequired,
83
83
  severity: 'error',
84
84
  message: 'No OAS documents were provided for merging.',
85
85
  help: 'Pass at least one path or document to `input.path`.',
@@ -149,8 +149,8 @@ export async function assertInputExists(input: string): Promise<void> {
149
149
  return
150
150
  }
151
151
  if (!(await exists(input))) {
152
- throw new DiagnosticError({
153
- code: diagnosticCode.inputNotFound,
152
+ throw new Diagnostics.Error({
153
+ code: Diagnostics.code.inputNotFound,
154
154
  severity: 'error',
155
155
  message: `Cannot read the file set in \`input.path\` (or via \`kubb generate PATH\`): ${input}`,
156
156
  help: 'Check that the path exists and is readable, then set it in `input.path` or pass it as `kubb generate PATH`.',
package/src/refs.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Diagnostic, diagnosticCode, DiagnosticError, Diagnostics } from '@kubb/core'
1
+ import { type Diagnostic, Diagnostics } from '@kubb/core'
2
2
  import { isReference } from './guards.ts'
3
3
  import type { Document } from './types.ts'
4
4
 
@@ -41,7 +41,7 @@ export function resolveRef<T = unknown>(document: Document, $ref: string): T | n
41
41
 
42
42
  if (!current) {
43
43
  const diagnostic: Diagnostic = {
44
- code: diagnosticCode.refNotFound,
44
+ code: Diagnostics.code.refNotFound,
45
45
  severity: 'error',
46
46
  message: `Could not find a definition for ${origRef}.`,
47
47
  help: 'Add the schema under `components.schemas`, or fix the `$ref`. Run `kubb validate` to check the spec.',
@@ -51,7 +51,7 @@ export function resolveRef<T = unknown>(document: Document, $ref: string): T | n
51
51
  // other unresolvable ref. The build collects it and keeps going. Outside a build there is no
52
52
  // sink, so throw rather than silently returning null.
53
53
  if (!Diagnostics.report(diagnostic)) {
54
- throw new DiagnosticError(diagnostic)
54
+ throw new Diagnostics.Error(diagnostic)
55
55
  }
56
56
  return null
57
57
  }
package/src/resolvers.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { pascalCase } from '@internals/utils'
2
- import { diagnosticCode, DiagnosticError } from '@kubb/core'
2
+ import { Diagnostics } from '@kubb/core'
3
3
  import type { ast } from '@kubb/core'
4
4
  import type { ParameterObject, ServerObject } from 'oas/types'
5
5
  import { isRef } from 'oas/types'
@@ -36,8 +36,8 @@ export function resolveServerUrl(server: ServerObject, overrides?: Record<string
36
36
  }
37
37
 
38
38
  if (variable.enum?.length && !variable.enum.some((e) => String(e) === value)) {
39
- throw new DiagnosticError({
40
- code: diagnosticCode.invalidServerVariable,
39
+ throw new Diagnostics.Error({
40
+ code: Diagnostics.code.invalidServerVariable,
41
41
  severity: 'error',
42
42
  message: `Invalid server variable value '${value}' for '${key}' when resolving ${server.url}. Valid values are: ${variable.enum.join(', ')}.`,
43
43
  help: `Use one of the allowed enum values, or drop the enum on the '${key}' server variable.`,
@@ -1,4 +1,4 @@
1
- import { diagnosticCode, Diagnostics } from '@kubb/core'
1
+ import { Diagnostics } from '@kubb/core'
2
2
  import type { ast } from '@kubb/core'
3
3
  import { isHandledFormat } from './resolvers.ts'
4
4
 
@@ -25,7 +25,7 @@ function escapePointerToken(token: string): string {
25
25
  function visit(node: ast.SchemaNode, pointer: string): void {
26
26
  if (node.deprecated) {
27
27
  Diagnostics.report({
28
- code: diagnosticCode.deprecated,
28
+ code: Diagnostics.code.deprecated,
29
29
  severity: 'info',
30
30
  message: 'This schema is marked as deprecated.',
31
31
  location: { kind: 'schema', pointer },
@@ -34,7 +34,7 @@ function visit(node: ast.SchemaNode, pointer: string): void {
34
34
 
35
35
  if (typeof node.format === 'string' && !isHandledFormat(node.format)) {
36
36
  Diagnostics.report({
37
- code: diagnosticCode.unsupportedFormat,
37
+ code: Diagnostics.code.unsupportedFormat,
38
38
  severity: 'warning',
39
39
  message: `Kubb does not map the format "${node.format}" to a specific type, so it falls back to the base type.`,
40
40
  help: `Use a format Kubb supports, or handle "${node.format}" with a custom parser or plugin.`,