@kubb/swagger
Advanced tools
Comparing version 2.0.0-beta.12 to 2.0.0-beta.13
import { createRequire } from 'module'; | ||
import './chunk-PUSDFDIP.js'; | ||
import { useApp, usePlugin, usePluginManager, useFile } from '@kubb/react'; | ||
@@ -3,0 +4,0 @@ |
import { createRequire } from 'module'; | ||
import { getSchemas, isReference, isOpenApiV3Document, convertSwagger2ToOpenApi } from './chunk-AWEHKPOS.js'; | ||
import { __privateAdd, __privateSet, __privateGet, __privateMethod } from './chunk-PUSDFDIP.js'; | ||
import path, { resolve } from 'path'; | ||
@@ -9,85 +11,6 @@ import { createPlugin, Generator } from '@kubb/core'; | ||
import OASNormalize from 'oas-normalize'; | ||
import swagger2openapi from 'swagger2openapi'; | ||
import transformers from '@kubb/core/transformers'; | ||
import { findSchemaDefinition } from 'oas/utils'; | ||
import { isRef } from 'oas/types'; | ||
createRequire(import.meta.url); | ||
var __accessCheck = (obj, member, msg) => { | ||
if (!member.has(obj)) | ||
throw TypeError("Cannot " + msg); | ||
}; | ||
var __privateGet = (obj, member, getter) => { | ||
__accessCheck(obj, member, "read from private field"); | ||
return getter ? getter.call(obj) : member.get(obj); | ||
}; | ||
var __privateAdd = (obj, member, value) => { | ||
if (member.has(obj)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
member instanceof WeakSet ? member.add(obj) : member.set(obj, value); | ||
}; | ||
var __privateSet = (obj, member, value, setter) => { | ||
__accessCheck(obj, member, "write to private field"); | ||
setter ? setter.call(obj, value) : member.set(obj, value); | ||
return value; | ||
}; | ||
var __privateMethod = (obj, member, method) => { | ||
__accessCheck(obj, member, "access private method"); | ||
return method; | ||
}; | ||
// src/utils/getSchemas.ts | ||
function getSchemas({ | ||
oas, | ||
contentType, | ||
includes = ["schemas", "requestBodies", "responses"] | ||
}) { | ||
const components = oas.getDefinition().components; | ||
let schemas = {}; | ||
if (includes.includes("schemas")) { | ||
schemas = { | ||
...schemas, | ||
...components?.schemas || {} | ||
}; | ||
} | ||
const requestBodies = components?.requestBodies || {}; | ||
if (includes.includes("responses")) { | ||
const responses = components?.responses || {}; | ||
Object.entries(responses).forEach(([name, response]) => { | ||
if (response.content && !schemas[name]) { | ||
const firstContentType = Object.keys(response.content)[0] || "application/json"; | ||
schemas[name] = response.content?.[contentType || firstContentType]?.schema; | ||
} | ||
}); | ||
} | ||
if (includes.includes("requestBodies")) { | ||
Object.entries(requestBodies).forEach(([name, request]) => { | ||
if (request.content && !schemas[name]) { | ||
const firstContentType = Object.keys(request.content)[0] || "application/json"; | ||
schemas[name] = request.content?.[contentType || firstContentType]?.schema; | ||
} | ||
}); | ||
} | ||
return schemas; | ||
} | ||
function convertSwagger2ToOpenApi(document) { | ||
const options = { anchors: true }; | ||
return new Promise((resolve2, reject) => { | ||
swagger2openapi.convertObj(document, options, (err, value) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve2(value.openapi); | ||
} | ||
}); | ||
}); | ||
} | ||
// src/utils/isOpenApiV3Document.ts | ||
function isOpenApiV3Document(doc) { | ||
return doc && "openapi" in doc; | ||
} | ||
// src/OasManager.ts | ||
var _options, _oas; | ||
@@ -259,7 +182,2 @@ var _OasManager = class _OasManager { | ||
_context = new WeakMap(); | ||
function isReference(obj) { | ||
return !!obj && isRef(obj); | ||
} | ||
// src/OperationGenerator.ts | ||
var _getOptions, getOptions_fn, _getParametersSchema, getParametersSchema_fn, _getResponseSchema, getResponseSchema_fn, _getRequestSchema, getRequestSchema_fn, _methods, methods_get; | ||
@@ -266,0 +184,0 @@ var OperationGenerator = class extends Generator { |
import { createRequire } from 'module'; | ||
import swagger2openapi from 'swagger2openapi'; | ||
export { convertSwagger2ToOpenApi, getSchemas, isOpenApiV3Document, isReference } from './chunk-AWEHKPOS.js'; | ||
import './chunk-PUSDFDIP.js'; | ||
import transformers from '@kubb/core/transformers'; | ||
@@ -9,17 +10,5 @@ import { URLPath, renderTemplate, FunctionParams } from '@kubb/core/utils'; | ||
import { LogLevel } from '@kubb/core/logger'; | ||
import { isSchema, isRef } from 'oas/types'; | ||
import { isSchema } from 'oas/types'; | ||
createRequire(import.meta.url); | ||
function convertSwagger2ToOpenApi(document) { | ||
const options = { anchors: true }; | ||
return new Promise((resolve, reject) => { | ||
swagger2openapi.convertObj(document, options, (err, value) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(value.openapi); | ||
} | ||
}); | ||
}); | ||
} | ||
function getComments(operation) { | ||
@@ -125,37 +114,2 @@ return [ | ||
} | ||
// src/utils/getSchemas.ts | ||
function getSchemas({ | ||
oas, | ||
contentType, | ||
includes = ["schemas", "requestBodies", "responses"] | ||
}) { | ||
const components = oas.getDefinition().components; | ||
let schemas = {}; | ||
if (includes.includes("schemas")) { | ||
schemas = { | ||
...schemas, | ||
...components?.schemas || {} | ||
}; | ||
} | ||
const requestBodies = components?.requestBodies || {}; | ||
if (includes.includes("responses")) { | ||
const responses = components?.responses || {}; | ||
Object.entries(responses).forEach(([name, response]) => { | ||
if (response.content && !schemas[name]) { | ||
const firstContentType = Object.keys(response.content)[0] || "application/json"; | ||
schemas[name] = response.content?.[contentType || firstContentType]?.schema; | ||
} | ||
}); | ||
} | ||
if (includes.includes("requestBodies")) { | ||
Object.entries(requestBodies).forEach(([name, request]) => { | ||
if (request.content && !schemas[name]) { | ||
const firstContentType = Object.keys(request.content)[0] || "application/json"; | ||
schemas[name] = request.content?.[contentType || firstContentType]?.schema; | ||
} | ||
}); | ||
} | ||
return schemas; | ||
} | ||
function isJSONSchema(obj) { | ||
@@ -165,10 +119,2 @@ return !!obj && isSchema(obj); | ||
// src/utils/isOpenApiV3Document.ts | ||
function isOpenApiV3Document(doc) { | ||
return doc && "openapi" in doc; | ||
} | ||
function isReference(obj) { | ||
return !!obj && isRef(obj); | ||
} | ||
// src/utils/isRequired.ts | ||
@@ -193,4 +139,4 @@ function isRequired(schema) { | ||
export { convertSwagger2ToOpenApi, getASTParams, getComments, getGroupedByTagFiles, getParams, getSchemaFactory, getSchemas, isJSONSchema, isOpenApiV3Document, isOpenApiV3_1Document, isParameterObject, isReference, isRequired, refsSorter }; | ||
export { getASTParams, getComments, getGroupedByTagFiles, getParams, getSchemaFactory, isJSONSchema, isOpenApiV3_1Document, isParameterObject, isRequired, refsSorter }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@kubb/swagger", | ||
"version": "2.0.0-beta.12", | ||
"version": "2.0.0-beta.13", | ||
"description": "Generator swagger", | ||
@@ -62,4 +62,4 @@ "keywords": [ | ||
"swagger2openapi": "^7.0.8", | ||
"@kubb/core": "2.0.0-beta.12", | ||
"@kubb/react": "2.0.0-beta.12" | ||
"@kubb/core": "2.0.0-beta.13", | ||
"@kubb/react": "2.0.0-beta.13" | ||
}, | ||
@@ -78,3 +78,3 @@ "devDependencies": { | ||
"peerDependencies": { | ||
"@kubb/react": "2.0.0-beta.12" | ||
"@kubb/react": "2.0.0-beta.13" | ||
}, | ||
@@ -81,0 +81,0 @@ "packageManager": "pnpm@8.3.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62
226562
2840
6
+ Added@kubb/core@2.0.0-beta.13(transitive)
+ Added@kubb/parser@2.0.0-beta.13(transitive)
+ Added@kubb/react@2.0.0-beta.13(transitive)
+ Added@kubb/types@2.0.0-beta.13(transitive)
+ Addedchange-case@5.4.4(transitive)
+ Addedfind-up@7.0.0(transitive)
+ Addedlocate-path@7.2.0(transitive)
+ Addedp-limit@4.0.0(transitive)
+ Addedp-locate@6.0.0(transitive)
+ Addedpath-exists@5.0.0(transitive)
+ Addedunicorn-magic@0.1.0(transitive)
+ Addedyocto-queue@1.1.1(transitive)
- Removed@kubb/core@2.0.0-beta.12(transitive)
- Removed@kubb/parser@2.0.0-beta.12(transitive)
- Removed@kubb/react@2.0.0-beta.12(transitive)
- Removed@kubb/types@2.0.0-beta.12(transitive)
Updated@kubb/core@2.0.0-beta.13
Updated@kubb/react@2.0.0-beta.13