@orval/core 6.25.0 → 6.26.0

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/README.md CHANGED
@@ -26,3 +26,4 @@ You can find below some samples
26
26
  - [react app with swr](https://github.com/anymaniax/orval/tree/master/samples/react-app-with-swr)
27
27
  - [nx fastify react](https://github.com/anymaniax/orval/tree/master/samples/nx-fastify-react)
28
28
  - [angular app](https://github.com/anymaniax/orval/tree/master/samples/angular-app)
29
+ - [hono](https://github.com/anymaniax/orval/tree/master/samples/hono)
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import * as openapi3_ts_oas30 from 'openapi3-ts/oas30';
3
3
  import { InfoObject, OperationObject, OpenAPIObject, ResponsesObject, ReferenceObject, RequestBodyObject, ParameterObject, SchemaObject, ComponentsObject, SchemasObject, PathItemObject, ResponseObject, ExampleObject } from 'openapi3-ts/oas30';
4
4
  import swagger2openapi from 'swagger2openapi';
5
5
  import { allLocales } from '@faker-js/faker';
6
+ import { ValueIteratee } from 'lodash';
6
7
  import { CompareOperator } from 'compare-versions';
7
8
  import debug from 'debug';
8
9
 
@@ -81,6 +82,7 @@ type NormalizedOverrideOutput = {
81
82
  suffix: string;
82
83
  };
83
84
  };
85
+ hono: NormalizedHonoOptions;
84
86
  query: NormalizedQueryOptions;
85
87
  angular: Required<AngularOptions>;
86
88
  swr: SwrOptions;
@@ -104,15 +106,13 @@ type NormalizedOperationOptions = {
104
106
  transformer?: OutputTransformer;
105
107
  mutator?: NormalizedMutator;
106
108
  mock?: {
107
- data?: MockProperties;
109
+ data?: MockData;
108
110
  properties?: MockProperties;
109
111
  };
110
112
  contentType?: OverrideOutputContentType;
111
113
  query?: NormalizedQueryOptions;
112
114
  angular?: Required<AngularOptions>;
113
- swr?: {
114
- options?: any;
115
- };
115
+ swr?: SwrOptions;
116
116
  operationName?: (operation: OperationObject, route: string, verb: Verbs) => string;
117
117
  formData?: boolean | NormalizedMutator;
118
118
  formUrlEncoded?: boolean | NormalizedMutator;
@@ -172,6 +172,7 @@ declare const OutputClient: {
172
172
  readonly VUE_QUERY: "vue-query";
173
173
  readonly SWR: "swr";
174
174
  readonly ZOD: "zod";
175
+ readonly HONO: "hono";
175
176
  };
176
177
  type OutputClient = (typeof OutputClient)[keyof typeof OutputClient];
177
178
  declare const OutputMode: {
@@ -208,11 +209,18 @@ type MockOptions = Omit<OverrideMockOptions, 'properties'> & {
208
209
  properties: Record<string, unknown>;
209
210
  }>;
210
211
  };
211
- type MockProperties = {
212
+ type MockPropertiesObject = {
212
213
  [key: string]: unknown;
213
- } | ((specs: OpenAPIObject) => {
214
+ };
215
+ type MockPropertiesObjectFn = (specs: OpenAPIObject) => MockPropertiesObject;
216
+ type MockProperties = MockPropertiesObject | MockPropertiesObjectFn;
217
+ type MockDataObject = {
214
218
  [key: string]: unknown;
215
- });
219
+ };
220
+ type MockDataObjectFn = (specs: OpenAPIObject) => MockDataObject;
221
+ type MockDataArray = unknown[];
222
+ type MockDataArrayFn = (specs: OpenAPIObject) => MockDataArray;
223
+ type MockData = MockDataObject | MockDataObjectFn | MockDataArray | MockDataArrayFn;
216
224
  type OutputTransformerFn = (verb: GeneratorVerbOptions) => GeneratorVerbOptions;
217
225
  type OutputTransformer = string | OutputTransformerFn;
218
226
  type MutatorObject = {
@@ -257,6 +265,7 @@ type OverrideOutput = {
257
265
  suffix?: string;
258
266
  };
259
267
  };
268
+ hono?: HonoOptions;
260
269
  query?: QueryOptions;
261
270
  swr?: SwrOptions;
262
271
  angular?: AngularOptions;
@@ -273,6 +282,12 @@ type OverrideOutputContentType = {
273
282
  include?: string[];
274
283
  exclude?: string[];
275
284
  };
285
+ type NormalizedHonoOptions = {
286
+ handlers?: string;
287
+ };
288
+ type HonoOptions = {
289
+ handlers?: string;
290
+ };
276
291
  type NormalizedQueryOptions = {
277
292
  useQuery?: boolean;
278
293
  useSuspenseQuery?: boolean;
@@ -309,9 +324,10 @@ type AngularOptions = {
309
324
  provideIn?: 'root' | 'any' | boolean;
310
325
  };
311
326
  type SwrOptions = {
312
- options?: any;
313
327
  useInfinite?: boolean;
314
328
  swrOptions?: any;
329
+ swrMutationOptions?: any;
330
+ swrInfiniteOptions?: any;
315
331
  };
316
332
  type InputTransformerFn = (spec: OpenAPIObject) => OpenAPIObject;
317
333
  type InputTransformer = string | InputTransformerFn;
@@ -322,7 +338,7 @@ type OperationOptions = {
322
338
  transformer?: OutputTransformer;
323
339
  mutator?: Mutator;
324
340
  mock?: {
325
- data?: MockProperties;
341
+ data?: MockData;
326
342
  properties?: MockProperties;
327
343
  };
328
344
  query?: QueryOptions;
@@ -470,6 +486,8 @@ type GeneratorOperation = {
470
486
  };
471
487
  type GeneratorVerbOptions = {
472
488
  verb: Verbs;
489
+ route: string;
490
+ pathRoute: string;
473
491
  summary?: string;
474
492
  doc: string;
475
493
  tags: string[];
@@ -519,6 +537,11 @@ type GeneratorMutator = {
519
537
  bodyTypeName?: string;
520
538
  };
521
539
  type ClientBuilder = (verbOptions: GeneratorVerbOptions, options: GeneratorOptions, outputClient: OutputClient | OutputClientFunc, output?: NormalizedOutputOptions) => GeneratorClient | Promise<GeneratorClient>;
540
+ type ClientFileBuilder = {
541
+ path: string;
542
+ content: string;
543
+ };
544
+ type ClientExtraFilesBuilder = (verbOptions: Record<string, GeneratorVerbOptions>, output: NormalizedOutputOptions, context: ContextSpecs) => Promise<ClientFileBuilder[]>;
522
545
  type ClientHeaderBuilder = (params: {
523
546
  title: string;
524
547
  isRequestOptions: boolean;
@@ -527,6 +550,10 @@ type ClientHeaderBuilder = (params: {
527
550
  isGlobalMutator: boolean;
528
551
  provideIn: boolean | 'root' | 'any';
529
552
  hasAwaitedType: boolean;
553
+ output: NormalizedOutputOptions;
554
+ verbOptions: Record<string, GeneratorVerbOptions>;
555
+ tag?: string;
556
+ clientImplementation: string;
530
557
  }) => string;
531
558
  type ClientFooterBuilder = (params: {
532
559
  noFunction?: boolean | undefined;
@@ -547,6 +574,7 @@ interface ClientGeneratorsBuilder {
547
574
  dependencies?: ClientDependenciesBuilder;
548
575
  footer?: ClientFooterBuilder;
549
576
  title?: ClientTitleBuilder;
577
+ extraFiles?: ClientExtraFilesBuilder;
550
578
  }
551
579
  type GeneratorClients = Record<OutputClient, ClientGeneratorsBuilder>;
552
580
  type GetterResponse = {
@@ -573,6 +601,7 @@ type GetterBody = {
573
601
  formData?: string;
574
602
  formUrlEncoded?: string;
575
603
  contentType: string;
604
+ isOptional: boolean;
576
605
  };
577
606
  type GetterParameters = {
578
607
  query: {
@@ -664,11 +693,13 @@ type ResReqTypesValue = ScalarValue & {
664
693
  type WriteSpecsBuilder = {
665
694
  operations: GeneratorOperations;
666
695
  schemas: Record<string, GeneratorSchema[]>;
696
+ verbOptions: Record<string, GeneratorVerbOptions>;
667
697
  title: GeneratorClientTitle;
668
698
  header: GeneratorClientHeader;
669
699
  footer: GeneratorClientFooter;
670
700
  imports: GeneratorClientImports;
671
701
  importsMock: GenerateMockImports;
702
+ extraFiles: ClientFileBuilder[];
672
703
  info: InfoObject;
673
704
  target: string;
674
705
  };
@@ -681,6 +712,7 @@ type WriteModeProps = {
681
712
  needSchema: boolean;
682
713
  };
683
714
  type GeneratorApiOperations = {
715
+ verbOptions: Record<string, GeneratorVerbOptions>;
684
716
  operations: GeneratorOperations;
685
717
  schemas: GeneratorSchema[];
686
718
  };
@@ -703,6 +735,9 @@ type GeneratorClientHeader = (data: {
703
735
  hasAwaitedType: boolean;
704
736
  titles: GeneratorClientExtra;
705
737
  output: NormalizedOutputOptions;
738
+ verbOptions: Record<string, GeneratorVerbOptions>;
739
+ tag?: string;
740
+ clientImplementation: string;
706
741
  }) => GeneratorClientExtra;
707
742
  type GeneratorClientFooter = (data: {
708
743
  outputClient: OutputClient | OutputClientFunc;
@@ -744,6 +779,7 @@ type GeneratorApiBuilder = GeneratorApiOperations & {
744
779
  footer: GeneratorClientFooter;
745
780
  imports: GeneratorClientImports;
746
781
  importsMock: GenerateMockImports;
782
+ extraFiles: ClientFileBuilder[];
747
783
  };
748
784
 
749
785
  declare const generalJSTypes: string[];
@@ -854,11 +890,12 @@ declare const generateParameterDefinition: (parameters: ComponentsObject['parame
854
890
  */
855
891
  declare const generateSchemasDefinition: (schemas: SchemasObject | undefined, context: ContextSpecs, suffix: string) => GeneratorSchema[];
856
892
 
857
- declare const generateVerbsOptions: ({ verbs, input, output, route, context, }: {
893
+ declare const generateVerbsOptions: ({ verbs, input, output, route, pathRoute, context, }: {
858
894
  verbs: PathItemObject;
859
895
  input: NormalizedInputOptions;
860
896
  output: NormalizedOutputOptions;
861
897
  route: string;
898
+ pathRoute: string;
862
899
  context: ContextSpecs;
863
900
  }) => Promise<GeneratorVerbsOptions>;
864
901
  declare const _filteredVerbs: (verbs: PathItemObject, filters: NormalizedInputOptions['filters']) => [string, any][];
@@ -978,7 +1015,7 @@ declare const getRefInfo: ($ref: ReferenceObject['$ref'], context: ContextSpecs)
978
1015
  declare const getResReqTypes: (responsesOrRequests: Array<[
979
1016
  string,
980
1017
  ResponseObject | ReferenceObject | RequestBodyObject
981
- ]>, name: string, context: ContextSpecs, defaultType?: string) => ResReqTypesValue[];
1018
+ ]>, name: string, context: ContextSpecs, defaultType?: string, uniqueKey?: ValueIteratee<ResReqTypesValue>) => ResReqTypesValue[];
982
1019
 
983
1020
  declare const getResponse: ({ responses, operationName, context, contentType, }: {
984
1021
  responses: ResponsesObject;
@@ -1060,10 +1097,20 @@ interface DebuggerOptions {
1060
1097
  }
1061
1098
  declare function createDebugger(ns: string, options?: DebuggerOptions): debug.Debugger['log'];
1062
1099
 
1063
- declare function jsDoc({ description, deprecated, summary, }: {
1100
+ declare function jsDoc({ description, deprecated, summary, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minItems, maxItems, nullable, pattern, }: {
1064
1101
  description?: string[] | string;
1065
1102
  deprecated?: boolean;
1066
1103
  summary?: string;
1104
+ minLength?: number;
1105
+ maxLength?: number;
1106
+ minimum?: number;
1107
+ maximum?: number;
1108
+ exclusiveMinimum?: boolean;
1109
+ exclusiveMaximum?: boolean;
1110
+ minItems?: number;
1111
+ maxItems?: number;
1112
+ nullable?: boolean;
1113
+ pattern?: string;
1067
1114
  }, tryOneLine?: boolean): string;
1068
1115
 
1069
1116
  declare const dynamicImport: <T>(toImport: string | T, from?: string, takeDefault?: boolean) => Promise<T>;
@@ -1258,4 +1305,4 @@ declare const generateTarget: (builder: WriteSpecsBuilder, options: NormalizedOu
1258
1305
 
1259
1306
  declare const generateTargetForTags: (builder: WriteSpecsBuilder, options: NormalizedOutputOptions) => Record<string, GeneratorTarget>;
1260
1307
 
1261
- export { type AngularOptions, BODY_TYPE_NAME, type ClientBuilder, type ClientDependenciesBuilder, type ClientFooterBuilder, type ClientGeneratorsBuilder, type ClientHeaderBuilder, type ClientMockBuilder, type ClientTitleBuilder, type Config, type ConfigExternal, type ConfigFn, type ContextSpecs, type GenerateMockImports, type GeneratorApiBuilder, type GeneratorApiOperations, type GeneratorApiResponse, type GeneratorClient, type GeneratorClientExtra, type GeneratorClientFooter, type GeneratorClientHeader, type GeneratorClientImports, type GeneratorClientTitle, type GeneratorClients, type GeneratorDependency, type GeneratorImport, type GeneratorMutator, type GeneratorMutatorParsingInfo, type GeneratorOperation, type GeneratorOperations, type GeneratorOptions, type GeneratorSchema, type GeneratorTarget, type GeneratorTargetFull, type GeneratorVerbOptions, type GeneratorVerbsOptions, type GetterBody, type GetterParam, type GetterParameters, type GetterParams, type GetterProp, GetterPropType, type GetterProps, type GetterQueryParam, type GetterResponse, type GlobalMockOptions, type GlobalOptions, type Hook, type HookCommand, type HookFunction, type HookOption, type HooksOptions, type ImportOpenApi, type InputOptions, type InputTransformerFn, type LogLevel, LogLevels, type LogOptions, type LogType, type Logger, type LoggerOptions, type MockOptions, type MockProperties, type Mutator, type MutatorObject, type NormalizedConfig, type NormalizedHookCommand, type NormalizedHookOptions, type NormalizedInputOptions, type NormalizedMutator, type NormalizedOperationOptions, type NormalizedOptions, type NormalizedOutputOptions, type NormalizedOverrideOutput, type NormalizedParamsSerializerOptions, type NormalizedQueryOptions, type OperationOptions, type Options, type OptionsExport, type OptionsFn, OutputClient, type OutputClientFunc, OutputMockType, OutputMode, type OutputOptions, type OverrideInput, type OverrideMockOptions, type OverrideOutput, type OverrideOutputContentType, type PackageJson, type ParamsSerializerOptions, type QueryOptions, RefComponentSuffix, type RefInfo, type ResReqTypesValue, type ResolverValue, type ScalarValue, SchemaType, type SwaggerParserOptions, type SwrOptions, type TsConfigTarget, type Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, type WriteModeProps, type WriteSpecsBuilder, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, count, createDebugger, createLogger, createSuccessMessage, dynamicImport, escape, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, generateFormDataAndUrlEncodedFunction, generateImports, generateModelInline, generateModelsInline, generateMutator, generateMutatorConfig, generateMutatorImports, generateMutatorRequestOptions, generateOptions, generateParameterDefinition, generateQueryParamsAxiosConfig, generateSchemasDefinition, generateTarget, generateTargetForTags, generateVerbImports, generateVerbsOptions, getArray, getBody, getEnum, getEnumImplementation, getExtension, getFileInfo, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getRoute, getRouteAsArray, getScalar, ibmOpenapiValidator, ibmOpenapiValidatorErrors, ibmOpenapiValidatorWarnings, isBoolean, isDirectory, isFunction, isModule, isNull, isNumber, isNumeric, isObject, isReference, isRootKey, isSchema, isString, isSyntheticDefaultImportsAllow, isUndefined, isUrl, isVerb, jsDoc, jsStringEscape, kebab, loadFile, log, logError, mergeDeep, mismatchArgsMessage, openApiConverter, pascal, removeFiles, resolveDiscriminators, resolveExampleRefs, resolveObject, resolveRef, resolveValue, sanitize, snake, sortByPriority, startMessage, stringify, toObjectString, path as upath, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
1308
+ export { type AngularOptions, BODY_TYPE_NAME, type ClientBuilder, type ClientDependenciesBuilder, type ClientExtraFilesBuilder, type ClientFileBuilder, type ClientFooterBuilder, type ClientGeneratorsBuilder, type ClientHeaderBuilder, type ClientMockBuilder, type ClientTitleBuilder, type Config, type ConfigExternal, type ConfigFn, type ContextSpecs, type GenerateMockImports, type GeneratorApiBuilder, type GeneratorApiOperations, type GeneratorApiResponse, type GeneratorClient, type GeneratorClientExtra, type GeneratorClientFooter, type GeneratorClientHeader, type GeneratorClientImports, type GeneratorClientTitle, type GeneratorClients, type GeneratorDependency, type GeneratorImport, type GeneratorMutator, type GeneratorMutatorParsingInfo, type GeneratorOperation, type GeneratorOperations, type GeneratorOptions, type GeneratorSchema, type GeneratorTarget, type GeneratorTargetFull, type GeneratorVerbOptions, type GeneratorVerbsOptions, type GetterBody, type GetterParam, type GetterParameters, type GetterParams, type GetterProp, GetterPropType, type GetterProps, type GetterQueryParam, type GetterResponse, type GlobalMockOptions, type GlobalOptions, type HonoOptions, type Hook, type HookCommand, type HookFunction, type HookOption, type HooksOptions, type ImportOpenApi, type InputOptions, type InputTransformerFn, type LogLevel, LogLevels, type LogOptions, type LogType, type Logger, type LoggerOptions, type MockData, type MockDataArray, type MockDataArrayFn, type MockDataObject, type MockDataObjectFn, type MockOptions, type MockProperties, type MockPropertiesObject, type MockPropertiesObjectFn, type Mutator, type MutatorObject, type NormalizedConfig, type NormalizedHonoOptions, type NormalizedHookCommand, type NormalizedHookOptions, type NormalizedInputOptions, type NormalizedMutator, type NormalizedOperationOptions, type NormalizedOptions, type NormalizedOutputOptions, type NormalizedOverrideOutput, type NormalizedParamsSerializerOptions, type NormalizedQueryOptions, type OperationOptions, type Options, type OptionsExport, type OptionsFn, OutputClient, type OutputClientFunc, OutputMockType, OutputMode, type OutputOptions, type OverrideInput, type OverrideMockOptions, type OverrideOutput, type OverrideOutputContentType, type PackageJson, type ParamsSerializerOptions, type QueryOptions, RefComponentSuffix, type RefInfo, type ResReqTypesValue, type ResolverValue, type ScalarValue, SchemaType, type SwaggerParserOptions, type SwrOptions, type TsConfigTarget, type Tsconfig, URL_REGEX, VERBS_WITH_BODY, Verbs, type WriteModeProps, type WriteSpecsBuilder, _filteredVerbs, addDependency, asyncReduce, camel, combineSchemas, compareVersions, count, createDebugger, createLogger, createSuccessMessage, dynamicImport, escape, generalJSTypes, generalJSTypesWithArray, generateAxiosOptions, generateBodyMutatorConfig, generateBodyOptions, generateComponentDefinition, generateDependencyImports, generateFormDataAndUrlEncodedFunction, generateImports, generateModelInline, generateModelsInline, generateMutator, generateMutatorConfig, generateMutatorImports, generateMutatorRequestOptions, generateOptions, generateParameterDefinition, generateQueryParamsAxiosConfig, generateSchemasDefinition, generateTarget, generateTargetForTags, generateVerbImports, generateVerbsOptions, getArray, getBody, getEnum, getEnumImplementation, getExtension, getFileInfo, getKey, getMockFileExtensionByTypeName, getNumberWord, getObject, getOperationId, getOrvalGeneratedTypes, getParameters, getParams, getParamsInPath, getProps, getQueryParams, getRefInfo, getResReqTypes, getResponse, getRoute, getRouteAsArray, getScalar, ibmOpenapiValidator, ibmOpenapiValidatorErrors, ibmOpenapiValidatorWarnings, isBoolean, isDirectory, isFunction, isModule, isNull, isNumber, isNumeric, isObject, isReference, isRootKey, isSchema, isString, isSyntheticDefaultImportsAllow, isUndefined, isUrl, isVerb, jsDoc, jsStringEscape, kebab, loadFile, log, logError, mergeDeep, mismatchArgsMessage, openApiConverter, pascal, removeFiles, resolveDiscriminators, resolveExampleRefs, resolveObject, resolveRef, resolveValue, sanitize, snake, sortByPriority, startMessage, stringify, toObjectString, path as upath, upper, writeModelInline, writeModelsInline, writeSchema, writeSchemas, writeSingleMode, writeSplitMode, writeSplitTagsMode, writeTagsMode };
package/dist/index.js CHANGED
@@ -39866,7 +39866,8 @@ var OutputClient = {
39866
39866
  SVELTE_QUERY: "svelte-query",
39867
39867
  VUE_QUERY: "vue-query",
39868
39868
  SWR: "swr",
39869
- ZOD: "zod"
39869
+ ZOD: "zod",
39870
+ HONO: "hono"
39870
39871
  };
39871
39872
  var OutputMode = {
39872
39873
  SINGLE: "single",
@@ -40649,13 +40650,34 @@ var regex = new RegExp(search, "g");
40649
40650
  function jsDoc({
40650
40651
  description,
40651
40652
  deprecated,
40652
- summary
40653
+ summary,
40654
+ minLength,
40655
+ maxLength,
40656
+ minimum,
40657
+ maximum,
40658
+ exclusiveMinimum,
40659
+ exclusiveMaximum,
40660
+ minItems,
40661
+ maxItems,
40662
+ nullable,
40663
+ pattern
40653
40664
  }, tryOneLine = false) {
40654
40665
  const lines = (Array.isArray(description) ? description.filter((d2) => !d2.includes("eslint-disable")) : [description || ""]).map((line) => line.replace(regex, replacement));
40655
- const count2 = [description, deprecated, summary].reduce(
40656
- (acc, it) => it ? acc + 1 : acc,
40657
- 0
40658
- );
40666
+ const count2 = [
40667
+ description,
40668
+ deprecated,
40669
+ summary,
40670
+ minLength?.toString(),
40671
+ maxLength?.toString(),
40672
+ minimum?.toString(),
40673
+ maximum?.toString(),
40674
+ exclusiveMinimum?.toString(),
40675
+ exclusiveMaximum?.toString(),
40676
+ minItems?.toString(),
40677
+ maxItems?.toString(),
40678
+ nullable?.toString(),
40679
+ pattern
40680
+ ].reduce((acc, it) => it ? acc + 1 : acc, 0);
40659
40681
  if (!count2) {
40660
40682
  return "";
40661
40683
  }
@@ -40670,20 +40692,42 @@ ${tryOneLine ? " " : ""} *`;
40670
40692
  }
40671
40693
  doc += ` ${lines.join("\n * ")}`;
40672
40694
  }
40673
- if (deprecated) {
40695
+ function appendPrefix() {
40674
40696
  if (!oneLine) {
40675
40697
  doc += `
40676
40698
  ${tryOneLine ? " " : ""} *`;
40677
40699
  }
40678
- doc += " @deprecated";
40679
40700
  }
40680
- if (summary) {
40681
- if (!oneLine) {
40682
- doc += `
40683
- ${tryOneLine ? " " : ""} *`;
40701
+ function tryAppendStringDocLine(key, value) {
40702
+ if (value) {
40703
+ appendPrefix();
40704
+ doc += ` @${key} ${value}`;
40705
+ }
40706
+ }
40707
+ function tryAppendBooleanDocLine(key, value) {
40708
+ if (value === true) {
40709
+ appendPrefix();
40710
+ doc += ` @${key}`;
40684
40711
  }
40685
- doc += ` @summary ${summary.replace(regex, replacement)}`;
40686
40712
  }
40713
+ function tryAppendNumberDocLine(key, value) {
40714
+ if (value !== void 0) {
40715
+ appendPrefix();
40716
+ doc += ` @${key} ${value}`;
40717
+ }
40718
+ }
40719
+ tryAppendBooleanDocLine("deprecated", deprecated);
40720
+ tryAppendStringDocLine("summary", summary?.replace(regex, replacement));
40721
+ tryAppendNumberDocLine("minLength", minLength);
40722
+ tryAppendNumberDocLine("maxLength", maxLength);
40723
+ tryAppendNumberDocLine("minimum", minimum);
40724
+ tryAppendNumberDocLine("maximum", maximum);
40725
+ tryAppendBooleanDocLine("exclusiveMinimum", exclusiveMinimum);
40726
+ tryAppendBooleanDocLine("exclusiveMaximum", exclusiveMaximum);
40727
+ tryAppendNumberDocLine("minItems", minItems);
40728
+ tryAppendNumberDocLine("maxItems", maxItems);
40729
+ tryAppendBooleanDocLine("nullable", nullable);
40730
+ tryAppendStringDocLine("pattern", pattern);
40687
40731
  doc += !oneLine ? `
40688
40732
  ${tryOneLine ? " " : ""}` : " ";
40689
40733
  doc += "*/\n";
@@ -40927,10 +40971,10 @@ var ibmOpenapiValidator = async (specs) => {
40927
40971
  const spectral = new Spectral();
40928
40972
  spectral.setRuleset(ibmOpenapiRuleset);
40929
40973
  const { errors, warnings } = await spectral.run(specs);
40930
- if (warnings.length) {
40974
+ if (warnings && warnings.length) {
40931
40975
  ibmOpenapiValidatorWarnings(warnings);
40932
40976
  }
40933
- if (errors.length) {
40977
+ if (errors && errors.length) {
40934
40978
  ibmOpenapiValidatorErrors(errors);
40935
40979
  }
40936
40980
  };
@@ -41372,7 +41416,7 @@ var getResReqContentTypes = ({
41372
41416
  });
41373
41417
  return resolvedObject;
41374
41418
  };
41375
- var getResReqTypes = (responsesOrRequests, name, context, defaultType = "unknown") => {
41419
+ var getResReqTypes = (responsesOrRequests, name, context, defaultType = "unknown", uniqueKey = "value") => {
41376
41420
  const typesArray = responsesOrRequests.filter(([_2, res]) => Boolean(res)).map(([key, res]) => {
41377
41421
  if (isReference(res)) {
41378
41422
  const {
@@ -41504,7 +41548,7 @@ var getResReqTypes = (responsesOrRequests, name, context, defaultType = "unknown
41504
41548
  });
41505
41549
  return (0, import_lodash5.default)(
41506
41550
  typesArray.flatMap((it) => it),
41507
- "value"
41551
+ uniqueKey
41508
41552
  );
41509
41553
  };
41510
41554
  var getSchemaFormDataAndUrlEncoded = ({
@@ -41639,6 +41683,7 @@ var getBody = ({
41639
41683
  const hasReadonlyProps = filteredBodyTypes.some((x3) => x3.hasReadonlyProps);
41640
41684
  const nonReadonlyDefinition = hasReadonlyProps && definition ? `NonReadonly<${definition}>` : definition;
41641
41685
  let implementation = generalJSTypesWithArray.includes(definition.toLowerCase()) || filteredBodyTypes.length > 1 ? camel(operationName) + context.output.override.components.requestBodies.suffix : camel(definition);
41686
+ let isOptional = false;
41642
41687
  if (implementation) {
41643
41688
  implementation = sanitize(implementation, {
41644
41689
  underscore: "_",
@@ -41647,6 +41692,17 @@ var getBody = ({
41647
41692
  es5keyword: true,
41648
41693
  es5IdentifierName: true
41649
41694
  });
41695
+ if (isReference(requestBody)) {
41696
+ const { schema: bodySchema } = resolveRef(
41697
+ requestBody,
41698
+ context
41699
+ );
41700
+ if (bodySchema.required !== void 0) {
41701
+ isOptional = !bodySchema.required;
41702
+ }
41703
+ } else if (requestBody.required !== void 0) {
41704
+ isOptional = !requestBody.required;
41705
+ }
41650
41706
  }
41651
41707
  return {
41652
41708
  originalSchema: requestBody,
@@ -41654,6 +41710,7 @@ var getBody = ({
41654
41710
  implementation,
41655
41711
  imports,
41656
41712
  schemas,
41713
+ isOptional,
41657
41714
  ...filteredBodyTypes.length === 1 ? {
41658
41715
  formData: filteredBodyTypes[0].formData,
41659
41716
  formUrlEncoded: filteredBodyTypes[0].formUrlEncoded,
@@ -41831,10 +41888,8 @@ var getObject = ({
41831
41888
  hasReadonlyProps: item.readOnly || false
41832
41889
  };
41833
41890
  }
41834
- const useTypeOverInterfaces = context?.output.override?.useTypeOverInterfaces;
41835
- const blankValue = item.type === "object" ? "{ [key: string]: any }" : useTypeOverInterfaces ? "unknown" : "{}";
41836
41891
  return {
41837
- value: blankValue + nullable,
41892
+ value: (item.type === "object" ? "{ [key: string]: any }" : "unknown") + nullable,
41838
41893
  imports: [],
41839
41894
  schemas: [],
41840
41895
  isEnum: false,
@@ -42294,10 +42349,10 @@ var getProps = ({
42294
42349
  }) => {
42295
42350
  const bodyProp = {
42296
42351
  name: body.implementation,
42297
- definition: `${body.implementation}: ${body.definition}`,
42298
- implementation: `${body.implementation}: ${body.definition}`,
42352
+ definition: `${body.implementation}${body.isOptional ? "?" : ""}: ${body.definition}`,
42353
+ implementation: `${body.implementation}${body.isOptional ? "?" : ""}: ${body.definition}`,
42299
42354
  default: false,
42300
- required: true,
42355
+ required: !body.isOptional,
42301
42356
  type: GetterPropType.BODY
42302
42357
  };
42303
42358
  const queryParamsProp = {
@@ -42473,7 +42528,8 @@ var getResponse = ({
42473
42528
  Object.entries(responses),
42474
42529
  operationName,
42475
42530
  context,
42476
- "void"
42531
+ "void",
42532
+ (type) => type.key.startsWith("2") + type.value
42477
42533
  );
42478
42534
  const filteredTypes = contentType ? types.filter((type) => {
42479
42535
  let include = true;
@@ -43302,7 +43358,8 @@ var generateInterface = ({
43302
43358
  }
43303
43359
  }
43304
43360
  if (scalar.type === "object" && !context?.output.override?.useTypeOverInterfaces) {
43305
- model += `export interface ${name} ${scalar.value}
43361
+ const blankInterfaceValue = scalar.value === "unknown" ? "{}" : scalar.value;
43362
+ model += `export interface ${name} ${blankInterfaceValue}
43306
43363
  `;
43307
43364
  } else {
43308
43365
  model += `export type ${name} = ${scalar.value};
@@ -43406,6 +43463,7 @@ var generateVerbOptions = async ({
43406
43463
  output,
43407
43464
  operation,
43408
43465
  route,
43466
+ pathRoute,
43409
43467
  verbParameters = [],
43410
43468
  context
43411
43469
  }) => {
@@ -43506,6 +43564,8 @@ var generateVerbOptions = async ({
43506
43564
  const verbOption = {
43507
43565
  verb,
43508
43566
  tags,
43567
+ route,
43568
+ pathRoute,
43509
43569
  summary: operation.summary,
43510
43570
  operationId,
43511
43571
  operationName,
@@ -43535,6 +43595,7 @@ var generateVerbsOptions = ({
43535
43595
  input,
43536
43596
  output,
43537
43597
  route,
43598
+ pathRoute,
43538
43599
  context
43539
43600
  }) => asyncReduce(
43540
43601
  _filteredVerbs(verbs, input.filters),
@@ -43545,6 +43606,7 @@ var generateVerbsOptions = ({
43545
43606
  output,
43546
43607
  verbParameters: verbs.parameters,
43547
43608
  route,
43609
+ pathRoute,
43548
43610
  operation,
43549
43611
  context
43550
43612
  });
@@ -43680,31 +43742,32 @@ ${exports2}`;
43680
43742
 
43681
43743
  // src/writers/types.ts
43682
43744
  var getOrvalGeneratedTypes = () => `
43683
- // https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
43684
- type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <
43685
- T,
43686
- >() => T extends Y ? 1 : 2
43687
- ? A
43688
- : B;
43689
-
43690
- type WritableKeys<T> = {
43691
- [P in keyof T]-?: IfEquals<
43692
- { [Q in P]: T[P] },
43693
- { -readonly [Q in P]: T[P] },
43694
- P
43695
- >;
43696
- }[keyof T];
43697
-
43698
- type UnionToIntersection<U> =
43699
- (U extends any ? (k: U)=>void : never) extends ((k: infer I)=>void) ? I : never;
43700
- type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
43701
-
43702
- type Writable<T> = Pick<T, WritableKeys<T>>;
43703
- type NonReadonly<T> = [T] extends [UnionToIntersection<T>] ? {
43704
- [P in keyof Writable<T>]: T[P] extends object
43705
- ? NonReadonly<NonNullable<T[P]>>
43706
- : T[P];
43707
- } : DistributeReadOnlyOverUnions<T>;
43745
+ type IsAny<T> = 0 extends 1 & T ? true : false;
43746
+ type IsUnknown<T> = IsAny<T> extends true ? false : unknown extends T ? true : false;
43747
+ type Primitive = string | number | boolean | bigint | symbol | undefined | null;
43748
+ type isBuiltin = Primitive | Function | Date | Error | RegExp;
43749
+ type NonReadonly<T> =
43750
+ T extends Exclude<isBuiltin, Error>
43751
+ ? T
43752
+ : T extends Map<infer Key, infer Value>
43753
+ ? Map<NonReadonly<Key>, NonReadonly<Value>>
43754
+ : T extends ReadonlyMap<infer Key, infer Value>
43755
+ ? Map<NonReadonly<Key>, NonReadonly<Value>>
43756
+ : T extends WeakMap<infer Key, infer Value>
43757
+ ? WeakMap<NonReadonly<Key>, NonReadonly<Value>>
43758
+ : T extends Set<infer Values>
43759
+ ? Set<NonReadonly<Values>>
43760
+ : T extends ReadonlySet<infer Values>
43761
+ ? Set<NonReadonly<Values>>
43762
+ : T extends WeakSet<infer Values>
43763
+ ? WeakSet<NonReadonly<Values>>
43764
+ : T extends Promise<infer Value>
43765
+ ? Promise<NonReadonly<Value>>
43766
+ : T extends {}
43767
+ ? { -readonly [Key in keyof T]: NonReadonly<T[Key]> }
43768
+ : IsUnknown<T> extends true
43769
+ ? unknown
43770
+ : T;
43708
43771
  `;
43709
43772
 
43710
43773
  // src/writers/single-mode.ts
@@ -43760,7 +43823,9 @@ var generateTarget = (builder, options) => {
43760
43823
  provideIn: options.override.angular.provideIn,
43761
43824
  hasAwaitedType,
43762
43825
  titles,
43763
- output: options
43826
+ output: options,
43827
+ verbOptions: builder.verbOptions,
43828
+ clientImplementation: acc.implementation
43764
43829
  });
43765
43830
  acc.implementation = header.implementation + acc.implementation;
43766
43831
  acc.implementationMock.handler = acc.implementationMock.handler + header.implementationMock + acc.implementationMock.handlerName;
@@ -44092,7 +44157,10 @@ var generateTargetForTags = (builder, options) => {
44092
44157
  provideIn: options.override.angular.provideIn,
44093
44158
  hasAwaitedType,
44094
44159
  titles,
44095
- output: options
44160
+ output: options,
44161
+ verbOptions: builder.verbOptions,
44162
+ tag,
44163
+ clientImplementation: target.implementation
44096
44164
  });
44097
44165
  acc2[tag] = {
44098
44166
  implementation: header.implementation + target.implementation + footer.implementation,