@kubb/swagger-ts 2.0.0-beta.4 → 2.0.0-beta.6

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.
@@ -1,6 +1,7 @@
1
1
  import transformers2, { camelCase, pascalCase } from '@kubb/core/transformers';
2
2
  import { print } from '@kubb/parser';
3
3
  import * as factory2 from '@kubb/parser/factory';
4
+ import { keywordTypeNodes } from '@kubb/parser/factory';
4
5
  import { usePlugin, usePluginManager, File, createRoot } from '@kubb/react';
5
6
  import { useSchemas, useOas, useOperationFile, useOperationName, useOperation } from '@kubb/swagger/hooks';
6
7
  import { pluginName as pluginName$1, OasBuilder, OperationGenerator as OperationGenerator$1 } from '@kubb/swagger';
@@ -55,9 +56,9 @@ var __privateMethod = (obj, member, method) => {
55
56
  return method;
56
57
  };
57
58
 
58
- // ../../node_modules/.pnpm/tsup@8.0.1_ts-node@10.9.1_typescript@5.3.2/node_modules/tsup/assets/esm_shims.js
59
+ // ../../node_modules/.pnpm/tsup@8.0.1_@microsoft+api-extractor@7.38.3_ts-node@10.9.1_typescript@5.3.2/node_modules/tsup/assets/esm_shims.js
59
60
  var init_esm_shims = __esm({
60
- "../../node_modules/.pnpm/tsup@8.0.1_ts-node@10.9.1_typescript@5.3.2/node_modules/tsup/assets/esm_shims.js"() {
61
+ "../../node_modules/.pnpm/tsup@8.0.1_@microsoft+api-extractor@7.38.3_ts-node@10.9.1_typescript@5.3.2/node_modules/tsup/assets/esm_shims.js"() {
61
62
  }
62
63
  });
63
64
 
@@ -3702,6 +3703,17 @@ getBaseTypeFromSchema_fn = function(_schema, baseName) {
3702
3703
  if (schema.properties || schema.additionalProperties) {
3703
3704
  return __privateMethod(this, _getTypeFromProperties, getTypeFromProperties_fn).call(this, schema, baseName);
3704
3705
  }
3706
+ if (version === "3.1" && "const" in schema) {
3707
+ if (schema["const"]) {
3708
+ if (typeof schema["const"] === "string") {
3709
+ return factory2.createLiteralTypeNode(factory2.createStringLiteral(schema["const"]));
3710
+ } else if (typeof schema["const"] === "number") {
3711
+ return factory2.createLiteralTypeNode(factory2.createNumericLiteral(schema["const"]));
3712
+ }
3713
+ } else {
3714
+ return keywordTypeNodes.null;
3715
+ }
3716
+ }
3705
3717
  if (schema.type) {
3706
3718
  if (Array.isArray(schema.type)) {
3707
3719
  const [type, nullable] = schema.type;
@@ -3728,9 +3740,6 @@ getBaseTypeFromSchema_fn = function(_schema, baseName) {
3728
3740
  if (schema.format === "binary") {
3729
3741
  return factory2.createTypeReferenceNode("Blob", []);
3730
3742
  }
3731
- if (version === "3.1" && typeof schema["const"] === "string") {
3732
- return factory2.createLiteralTypeNode(factory2.createStringLiteral(schema["const"]));
3733
- }
3734
3743
  return factory2.keywordTypeNodes.any;
3735
3744
  };
3736
3745