@sdk-it/spec 0.28.0 → 0.30.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.
Files changed (91) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/find-polymorphic-varients.d.ts +3 -3
  6. package/dist/lib/find-polymorphic-varients.d.ts.map +1 -1
  7. package/dist/lib/find-polymorphic-varients.js.map +1 -1
  8. package/dist/lib/find-polymorphic-varients.test.js +2 -2
  9. package/dist/lib/find-polymorphic-varients.test.js.map +2 -2
  10. package/dist/lib/for-each-operation.d.ts +2 -2
  11. package/dist/lib/for-each-operation.d.ts.map +1 -1
  12. package/dist/lib/for-each-operation.js.map +1 -1
  13. package/dist/lib/get-ref-usage.d.ts +2 -2
  14. package/dist/lib/get-ref-usage.d.ts.map +1 -1
  15. package/dist/lib/get-ref-usage.js.map +1 -1
  16. package/dist/lib/guess/guess-resource.d.ts.map +1 -1
  17. package/dist/lib/ir.d.ts +4 -0
  18. package/dist/lib/ir.d.ts.map +1 -0
  19. package/dist/lib/{operation.js → ir.js} +3 -3
  20. package/dist/lib/ir.js.map +7 -0
  21. package/dist/lib/ir.test.d.ts +2 -0
  22. package/dist/lib/ir.test.d.ts.map +1 -0
  23. package/dist/lib/{operation.test.js → ir.test.js} +1 -1
  24. package/dist/lib/{operation.test.js.map → ir.test.js.map} +1 -1
  25. package/dist/lib/options.d.ts +1 -1
  26. package/dist/lib/options.d.ts.map +1 -1
  27. package/dist/lib/options.js +2 -1
  28. package/dist/lib/options.js.map +2 -2
  29. package/dist/lib/overview-docs/doc-templates.d.ts +51 -0
  30. package/dist/lib/overview-docs/doc-templates.d.ts.map +1 -0
  31. package/dist/lib/overview-docs/doc-templates.js +123 -0
  32. package/dist/lib/overview-docs/doc-templates.js.map +7 -0
  33. package/dist/lib/overview-docs/doc-text-utils.d.ts +86 -0
  34. package/dist/lib/overview-docs/doc-text-utils.d.ts.map +1 -0
  35. package/dist/lib/overview-docs/doc-text-utils.js +108 -0
  36. package/dist/lib/overview-docs/doc-text-utils.js.map +7 -0
  37. package/dist/lib/overview-docs/overview-auth.d.ts +2 -2
  38. package/dist/lib/overview-docs/overview-auth.d.ts.map +1 -1
  39. package/dist/lib/overview-docs/overview-auth.js +34 -52
  40. package/dist/lib/overview-docs/overview-auth.js.map +2 -2
  41. package/dist/lib/overview-docs/overview-docs.d.ts +2 -2
  42. package/dist/lib/overview-docs/overview-docs.d.ts.map +1 -1
  43. package/dist/lib/overview-docs/overview-docs.js.map +1 -1
  44. package/dist/lib/overview-docs/overview-errors.d.ts +2 -2
  45. package/dist/lib/overview-docs/overview-errors.d.ts.map +1 -1
  46. package/dist/lib/overview-docs/overview-errors.js +11 -28
  47. package/dist/lib/overview-docs/overview-errors.js.map +2 -2
  48. package/dist/lib/overview-docs/overview-intro.d.ts +2 -2
  49. package/dist/lib/overview-docs/overview-intro.d.ts.map +1 -1
  50. package/dist/lib/overview-docs/overview-intro.js +41 -36
  51. package/dist/lib/overview-docs/overview-intro.js.map +2 -2
  52. package/dist/lib/overview-docs/overview-pagination.d.ts +2 -2
  53. package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -1
  54. package/dist/lib/overview-docs/overview-pagination.js +27 -9
  55. package/dist/lib/overview-docs/overview-pagination.js.map +2 -2
  56. package/dist/lib/pagination/pagination.d.ts +2 -2
  57. package/dist/lib/pagination/pagination.d.ts.map +1 -1
  58. package/dist/lib/pagination/pagination.js.map +2 -2
  59. package/dist/lib/security.d.ts +3 -3
  60. package/dist/lib/security.d.ts.map +1 -1
  61. package/dist/lib/security.js.map +2 -2
  62. package/dist/lib/sidebar.d.ts +2 -2
  63. package/dist/lib/sidebar.d.ts.map +1 -1
  64. package/dist/lib/sidebar.js.map +2 -2
  65. package/dist/lib/tune-request-body.d.ts +3 -3
  66. package/dist/lib/tune-request-body.d.ts.map +1 -1
  67. package/dist/lib/tune-request-body.js.map +1 -1
  68. package/dist/lib/tune-response.d.ts +2 -2
  69. package/dist/lib/tune-response.d.ts.map +1 -1
  70. package/dist/lib/tune-response.js.map +1 -1
  71. package/dist/lib/tune.d.ts +3 -3
  72. package/dist/lib/tune.d.ts.map +1 -1
  73. package/dist/lib/tune.js.map +1 -1
  74. package/dist/lib/tune.test.js +2 -2
  75. package/dist/lib/tune.test.js.map +2 -2
  76. package/dist/lib/types.d.ts +3 -2
  77. package/dist/lib/types.d.ts.map +1 -1
  78. package/package.json +2 -2
  79. package/dist/lib/operation.d.ts +0 -4
  80. package/dist/lib/operation.d.ts.map +0 -1
  81. package/dist/lib/operation.js.map +0 -7
  82. package/dist/lib/operation.test.d.ts +0 -2
  83. package/dist/lib/operation.test.d.ts.map +0 -1
  84. package/dist/lib/overview-docs/overview-quick-reference.d.ts +0 -4
  85. package/dist/lib/overview-docs/overview-quick-reference.d.ts.map +0 -1
  86. package/dist/lib/overview-docs/overview-sdk-examples.d.ts +0 -4
  87. package/dist/lib/overview-docs/overview-sdk-examples.d.ts.map +0 -1
  88. package/dist/lib/overview-docs/overview-usage.d.ts +0 -4
  89. package/dist/lib/overview-docs/overview-usage.d.ts.map +0 -1
  90. package/dist/lib/overview-docs.d.ts +0 -4
  91. package/dist/lib/overview-docs.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { OperationObject } from 'openapi3-ts/oas31';
2
2
  import { type ResponsesConfig } from './options.js';
3
- import type { OurOpenAPIObject } from './types.js';
4
- export declare function resolveResponses(spec: OurOpenAPIObject, operationId: string, operation: OperationObject, responsesConfig?: ResponsesConfig): import("openapi3-ts/oas31").ResponsesObject;
3
+ import type { IR } from './types.js';
4
+ export declare function resolveResponses(spec: IR, operationId: string, operation: OperationObject, responsesConfig?: ResponsesConfig): import("openapi3-ts/oas31").ResponsesObject;
5
5
  //# sourceMappingURL=tune-response.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tune-response.d.ts","sourceRoot":"","sources":["../../src/lib/tune-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,eAAe,EAC1B,eAAe,CAAC,EAAE,eAAe,+CAuHlC"}
1
+ {"version":3,"file":"tune-response.d.ts","sourceRoot":"","sources":["../../src/lib/tune-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,EAAE,EACR,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,eAAe,EAC1B,eAAe,CAAC,EAAE,eAAe,+CAuHlC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/tune-response.ts"],
4
- "sourcesContent": ["import type {\n MediaTypeObject,\n OperationObject,\n ResponseObject,\n} from 'openapi3-ts/oas31';\n\nimport { isRef, parseRef, resolveRef } from '@sdk-it/core/ref.js';\nimport { isEmpty, pascalcase } from '@sdk-it/core/utils.js';\n\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport {\n isSseContentType,\n isSuccessStatusCode,\n isTextContentType,\n parseJsonContentType,\n} from './is.js';\nimport { type ResponsesConfig } from './options.js';\nimport type { OurOpenAPIObject } from './types.js';\n\nexport function resolveResponses(\n spec: OurOpenAPIObject,\n operationId: string,\n operation: OperationObject,\n responsesConfig?: ResponsesConfig,\n) {\n const responses = operation.responses ?? {};\n operation.responses ??= {};\n let foundSuccessResponse = false;\n for (const status in responses) {\n if (status === 'default') {\n delete responses[status]; // Skip default response\n continue;\n }\n // use structuredClone to avoid mutating a response object\n // that is referenced by multiple operations\n operation.responses[status] = structuredClone(\n resolveRef<ResponseObject>(spec, responses[status]),\n );\n\n if (isSuccessStatusCode(status)) {\n foundSuccessResponse = true;\n }\n }\n\n if (!foundSuccessResponse) {\n operation.responses['200'] = {\n description: 'OK',\n content: {\n 'application/json': {\n schema: {},\n },\n },\n };\n }\n\n for (const status in operation.responses) {\n const response = operation.responses[status] as ResponseObject;\n const statusCode = +status;\n\n const outputName =\n statusCode !== 200\n ? pascalcase(operationId) + status\n : findUniqueSchemaName(spec, operationId, [\n 'output',\n 'payload',\n 'result',\n ]);\n\n if (!responsesConfig?.flattenErrorResponses) {\n if (!isSuccessStatusCode(status)) {\n continue;\n }\n }\n\n if (isEmpty(response.content)) {\n response.content = {\n 'application/octet-stream': {},\n };\n }\n\n response['x-response-name'] = outputName;\n\n // if (isErrorStatusCode(status)) {\n // const mediaType = response.content?.['application/json'];\n // if (mediaType && isRef(mediaType.schema)) {\n // const { model } = parseRef(mediaType.schema.$ref);\n // Object.assign(config.spec.components.schemas[model], {\n // 'x-responsebody': true,\n // // do not assign response ref to a group\n // // because they are supposed to be in a separate file only inlined\n // // schemas are grouped by operationId\n // });\n // response['x-response-name'] = model;\n // }\n // continue;\n // }\n\n for (const [contentType, mediaType] of Object.entries(\n response.content as Record<string, MediaTypeObject>,\n )) {\n if (isRef(mediaType.schema)) {\n const { model } = parseRef(mediaType.schema.$ref);\n Object.assign(spec.components.schemas[model], {\n 'x-responsebody': true,\n // do not assign response ref to a group\n // because they are supposed to be in a separate file only inlined\n // schemas are grouped by operationId\n });\n response['x-response-name'] = model;\n continue;\n }\n if (isSseContentType(contentType)) {\n continue; // Skip SSE content types\n }\n if (parseJsonContentType(contentType)) {\n if (isEmpty(mediaType.schema)) {\n // add \"additionalProperties\" because we're certain this is a response body is of json type\n spec.components.schemas[outputName] = {\n type: 'object',\n additionalProperties: true,\n };\n }\n } else {\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n 'x-stream': !isTextContentType(contentType),\n };\n }\n\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n ...mediaType.schema,\n 'x-responsebody': true,\n 'x-response-group': operationId,\n };\n operation.responses[status].content[contentType].schema = {\n $ref: `#/components/schemas/${outputName}`,\n };\n }\n }\n\n return operation.responses;\n}\n"],
4
+ "sourcesContent": ["import type {\n MediaTypeObject,\n OperationObject,\n ResponseObject,\n} from 'openapi3-ts/oas31';\n\nimport { isRef, parseRef, resolveRef } from '@sdk-it/core/ref.js';\nimport { isEmpty, pascalcase } from '@sdk-it/core/utils.js';\n\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport {\n isSseContentType,\n isSuccessStatusCode,\n isTextContentType,\n parseJsonContentType,\n} from './is.js';\nimport { type ResponsesConfig } from './options.js';\nimport type { IR } from './types.js';\n\nexport function resolveResponses(\n spec: IR,\n operationId: string,\n operation: OperationObject,\n responsesConfig?: ResponsesConfig,\n) {\n const responses = operation.responses ?? {};\n operation.responses ??= {};\n let foundSuccessResponse = false;\n for (const status in responses) {\n if (status === 'default') {\n delete responses[status]; // Skip default response\n continue;\n }\n // use structuredClone to avoid mutating a response object\n // that is referenced by multiple operations\n operation.responses[status] = structuredClone(\n resolveRef<ResponseObject>(spec, responses[status]),\n );\n\n if (isSuccessStatusCode(status)) {\n foundSuccessResponse = true;\n }\n }\n\n if (!foundSuccessResponse) {\n operation.responses['200'] = {\n description: 'OK',\n content: {\n 'application/json': {\n schema: {},\n },\n },\n };\n }\n\n for (const status in operation.responses) {\n const response = operation.responses[status] as ResponseObject;\n const statusCode = +status;\n\n const outputName =\n statusCode !== 200\n ? pascalcase(operationId) + status\n : findUniqueSchemaName(spec, operationId, [\n 'output',\n 'payload',\n 'result',\n ]);\n\n if (!responsesConfig?.flattenErrorResponses) {\n if (!isSuccessStatusCode(status)) {\n continue;\n }\n }\n\n if (isEmpty(response.content)) {\n response.content = {\n 'application/octet-stream': {},\n };\n }\n\n response['x-response-name'] = outputName;\n\n // if (isErrorStatusCode(status)) {\n // const mediaType = response.content?.['application/json'];\n // if (mediaType && isRef(mediaType.schema)) {\n // const { model } = parseRef(mediaType.schema.$ref);\n // Object.assign(config.spec.components.schemas[model], {\n // 'x-responsebody': true,\n // // do not assign response ref to a group\n // // because they are supposed to be in a separate file only inlined\n // // schemas are grouped by operationId\n // });\n // response['x-response-name'] = model;\n // }\n // continue;\n // }\n\n for (const [contentType, mediaType] of Object.entries(\n response.content as Record<string, MediaTypeObject>,\n )) {\n if (isRef(mediaType.schema)) {\n const { model } = parseRef(mediaType.schema.$ref);\n Object.assign(spec.components.schemas[model], {\n 'x-responsebody': true,\n // do not assign response ref to a group\n // because they are supposed to be in a separate file only inlined\n // schemas are grouped by operationId\n });\n response['x-response-name'] = model;\n continue;\n }\n if (isSseContentType(contentType)) {\n continue; // Skip SSE content types\n }\n if (parseJsonContentType(contentType)) {\n if (isEmpty(mediaType.schema)) {\n // add \"additionalProperties\" because we're certain this is a response body is of json type\n spec.components.schemas[outputName] = {\n type: 'object',\n additionalProperties: true,\n };\n }\n } else {\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n 'x-stream': !isTextContentType(contentType),\n };\n }\n\n spec.components.schemas[outputName] = {\n ...spec.components.schemas[outputName],\n ...mediaType.schema,\n 'x-responsebody': true,\n 'x-response-group': operationId,\n };\n operation.responses[status].content[contentType].schema = {\n $ref: `#/components/schemas/${outputName}`,\n };\n }\n }\n\n return operation.responses;\n}\n"],
5
5
  "mappings": "AAMA,SAAS,OAAO,UAAU,kBAAkB;AAC5C,SAAS,SAAS,kBAAkB;AAEpC,SAAS,4BAA4B;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,eAAqC;AAG9B,SAAS,iBACd,MACA,aACA,WACA,iB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,QAIpB,CAAC;AACD,iBAAS,iBAAiB,IAAI;AAC9B;AAAA,MACF;AACA,UAAI,iBAAiB,WAAW,GAAG;AACjC;AAAA,MACF;AACA,UAAI,qBAAqB,WAAW,GAAG;AACrC,YAAI,QAAQ,UAAU,MAAM,GAAG;AAE7B,eAAK,WAAW,QAAQ,UAAU,IAAI;AAAA,YACpC,MAAM;AAAA,YACN,sBAAsB;AAAA,UACxB;AAAA,QACF;AAAA,MACF,OAAO;AACL,aAAK,WAAW,QAAQ,UAAU,IAAI;AAAA,UACpC,GAAG,KAAK,WAAW,QAAQ,UAAU;AAAA,UACrC,YAAY,CAAC,kBAAkB,WAAW;AAAA,QAC5C;AAAA,MACF;AAEA,WAAK,WAAW,QAAQ,UAAU,IAAI;AAAA,QACpC,GAAG,KAAK,WAAW,QAAQ,UAAU;AAAA,QACrC,GAAG,UAAU;AAAA,QACb,kBAAkB;AAAA,QAClB,oBAAoB;AAAA,MACtB;AACA,gBAAU,UAAU,MAAM,EAAE,QAAQ,WAAW,EAAE,SAAS;AAAA,QACxD,MAAM,wBAAwB,UAAU;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AAEA,SAAO,UAAU;AACnB;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,11 @@
1
1
  import type { ReferenceObject, SchemaObject, SchemaObjectType } from 'openapi3-ts/oas31';
2
- import type { OurOpenAPIObject } from './types.js';
3
- export declare function fixSpec(spec: OurOpenAPIObject, schemas: (SchemaObject | ReferenceObject)[], visited?: Set<string>): void;
2
+ import type { IR } from './types.js';
3
+ export declare function fixSpec(spec: IR, schemas: (SchemaObject | ReferenceObject)[], visited?: Set<string>): void;
4
4
  type Refs = {
5
5
  name: string;
6
6
  value: SchemaObject;
7
7
  }[];
8
- export declare function expandSpec(spec: OurOpenAPIObject, schemas: Record<string, SchemaObject | ReferenceObject>, refs: Refs): void;
8
+ export declare function expandSpec(spec: IR, schemas: Record<string, SchemaObject | ReferenceObject>, refs: Refs): void;
9
9
  export declare function coerceTypes(schema: SchemaObject, excludeNull?: boolean): SchemaObjectType[];
10
10
  export {};
11
11
  //# sourceMappingURL=tune.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tune.d.ts","sourceRoot":"","sources":["../../src/lib/tune.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAgB3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,OAAO,CACrB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAC3C,OAAO,cAAoB,QAsK5B;AAED,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,EAAE,CAAC;AAEpD,wBAAgB,UAAU,CACxB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,EACvD,IAAI,EAAE,IAAI,QAoJX;AA0CD,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,EACpB,WAAW,UAAO,GACjB,gBAAgB,EAAE,CAUpB"}
1
+ {"version":3,"file":"tune.d.ts","sourceRoot":"","sources":["../../src/lib/tune.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAgB3B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAErC,wBAAgB,OAAO,CACrB,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAC3C,OAAO,cAAoB,QAsK5B;AAED,KAAK,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,EAAE,CAAC;AAEpD,wBAAgB,UAAU,CACxB,IAAI,EAAE,EAAE,EACR,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,EACvD,IAAI,EAAE,IAAI,QAoJX;AA0CD,wBAAgB,WAAW,CACzB,MAAM,EAAE,YAAY,EACpB,WAAW,UAAO,GACjB,gBAAgB,EAAE,CAUpB"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/tune.ts"],
4
- "sourcesContent": ["import { merge, uniq } from 'lodash-es';\nimport assert from 'node:assert';\nimport type {\n ReferenceObject,\n SchemaObject,\n SchemaObjectType,\n} from 'openapi3-ts/oas31';\n\nimport {\n isEmpty,\n isRef,\n joinSkipDigits,\n notRef,\n pascalcase,\n resolveRef,\n snakecase,\n} from '@sdk-it/core';\n\nimport { type Varient, findVarients } from './find-polymorphic-varients.js';\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport { formatName } from './format-name.js';\nimport { isPrimitiveSchema } from './is-primitive-schema.js';\nimport type { OurOpenAPIObject } from './types.js';\n\nexport function fixSpec(\n spec: OurOpenAPIObject,\n schemas: (SchemaObject | ReferenceObject)[],\n visited = new Set<string>(),\n) {\n for (const schema of schemas) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.properties)) {\n schema.type = 'object';\n delete schema.oneOf;\n delete schema.anyOf;\n fixSpec(spec, Object.values(schema.properties), visited);\n // path param are required and if it happens to have\n // body with defaults then zod would break off. so flat the defaults from object itself to properties\n for (const [key, value] of Object.entries(schema.properties)) {\n if (notRef(value) && isPrimitiveSchema(value)) {\n value.default ??= schema.default?.[key];\n delete schema.default?.[key];\n }\n }\n delete schema.default; // default should not be in properties\n }\n\n if (!isEmpty(schema['x-properties'])) {\n fixSpec(spec, Object.values(schema['x-properties']), visited);\n }\n\n if (!isEmpty(schema.items)) {\n delete schema.oneOf;\n delete schema.anyOf;\n schema.type = 'array';\n fixSpec(spec, [schema.items], visited);\n const items = resolveRef<SchemaObject>(spec, schema.items);\n if (Array.isArray(items.default)) {\n schema.default ??= structuredClone(items.default);\n }\n delete items.default; // default should not be in items\n }\n\n if (!isEmpty(schema.anyOf) && !isEmpty(schema.oneOf)) {\n delete schema.anyOf;\n }\n\n if (isEmpty(schema.enum)) {\n delete schema.enum;\n }\n\n if (!isEmpty(schema.enum)) {\n if (schema.enum.length === 1) {\n schema.const = schema.enum[0];\n delete schema.enum;\n } else {\n const valuesSet = new Set<string>();\n const valuesList = [];\n for (const it of schema.enum) {\n const formattedValue = formatName(snakecase(formatName(it)));\n if (!valuesSet.has(formattedValue)) {\n valuesSet.add(formattedValue);\n valuesList.push(it);\n }\n }\n schema.enum = valuesList;\n }\n delete schema.allOf;\n }\n\n if (schema.const !== undefined) {\n schema.default = schema.const;\n }\n\n if (!isEmpty(schema.allOf)) {\n const schemas = schema.allOf;\n // if (schemas.length === 1) {\n // fixSpec(spec, [schemas[0]], visited);\n // Object.assign(schema, schemas[0]);\n // delete schema.allOf;\n // } else {\n // }\n const resolved = schemas.map((it) => resolveRef<SchemaObject>(spec, it));\n const hasObjects = resolved.some((it) => it.type === 'object');\n const hasOtherTypes = resolved.some(\n (it) => it.type && it.type !== 'object',\n );\n if (hasObjects && hasOtherTypes) {\n assert(false, `allOf must be an object`);\n }\n merge(\n schema,\n ...resolved.map((it) => {\n fixSpec(spec, [it], visited);\n return it;\n }),\n );\n delete schema.allOf;\n } else {\n delete schema.allOf;\n }\n\n if (\n schema.type === 'object' &&\n isEmpty(schema.properties) &&\n typeof schema.additionalProperties === 'object' &&\n !isEmpty(schema.additionalProperties) &&\n notRef(schema.additionalProperties) &&\n !isEmpty(schema.additionalProperties.properties)\n ) {\n // additionalProperties is of type object and properties is empty\n fixSpec(\n spec,\n Object.values(schema.additionalProperties.properties),\n visited,\n );\n Object.assign(schema, schema.additionalProperties);\n delete schema.additionalProperties;\n }\n\n for (const kind of ['oneOf', 'anyOf'] as const) {\n if (!isEmpty(schema[kind])) {\n delete schema.type; // type is not allowed with oneOf or anyOf\n fixSpec(spec, schema[kind], visited);\n if (isEmpty(schema[kind])) {\n // fixSpec can remove oneOf or anyOf if it has no items so we need to check again\n // after fixing\n continue;\n }\n\n let enumSchemaIndex = -1;\n const enumValues: string[] = [];\n for (let idx = 0; idx < schema[kind].length; idx++) {\n // for (const idx in schema[kind]) {\n const item = schema[kind][idx];\n // just handle non ref for now\n if (notRef(item) && item.type === 'string') {\n // if enum equal one it'd already have been converted to const so check for more than one\n if (item.enum && item.enum.length > 1) {\n // foundEnum = true;\n enumValues.push(...item.enum);\n if (enumSchemaIndex === -1) {\n enumSchemaIndex = idx;\n }\n }\n }\n }\n if (enumSchemaIndex !== -1) {\n const enumSchema = schema[kind][enumSchemaIndex];\n if (notRef(enumSchema)) {\n enumSchema.enum = uniq(enumValues);\n }\n // delete the other schemas that have enum\n schema[kind] = schema[kind].filter(\n (it, idx) => idx === enumSchemaIndex || isRef(it),\n );\n }\n const otherTypes = schema[kind].filter(\n (it) => resolveRef<SchemaObject>(spec, it).type !== 'null',\n );\n if (otherTypes.length === 1) {\n Object.assign(schema, otherTypes[0]);\n delete schema[kind];\n continue;\n }\n\n schema['x-varients'] = findVarients(spec, schema[kind]);\n } else {\n delete schema[kind];\n }\n }\n }\n}\n\ntype Refs = { name: string; value: SchemaObject }[];\n\nexport function expandSpec(\n spec: OurOpenAPIObject,\n schemas: Record<string, SchemaObject | ReferenceObject>,\n refs: Refs,\n) {\n for (const [name, schema] of Object.entries(schemas)) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.properties)) {\n if (!isEmpty(schema.oneOf)) {\n for (const oneOfIdx in schema.oneOf) {\n const oneOf = schema.oneOf[oneOfIdx];\n if (isRef(oneOf)) continue;\n for (const key of ['properties', 'x-properties'] as const) {\n if (!isEmpty(oneOf.required) && schema[key]) {\n schema.oneOf[oneOfIdx] = schema[key][oneOf.required[0]];\n }\n }\n }\n delete schema.type;\n expandSpec(spec, schemas, refs);\n continue;\n }\n if (schema.additionalProperties) {\n continue;\n }\n // refs.push({ name, value: schema });\n spec.components.schemas[name] = schema;\n const properties = schema.properties as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropName = propName.replace('[]', '');\n // this neeeds inheritance logic first otherwise it'll create class mess\n // const refName = findUniqueSchemaName(\n // spec,\n // propName,\n // ['Property', 'Field', 'Attribute'],\n // pascalcase(joinSkipDigits([name, fixedPropName], ' ')),\n // );\n const refName = pascalcase(joinSkipDigits([name, fixedPropName], ' '));\n\n if (!isEmpty(value.properties)) {\n // refs.push({ name: refName, value: value });\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.oneOf)) {\n expandOneOf(spec, name, value, refs, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.anyOf)) {\n expandOneOf(spec, name, value, refs, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else {\n expandSpec(spec, { [refName]: value }, refs);\n }\n }\n\n continue;\n }\n if (!isEmpty(schema['x-properties'])) {\n // refs.push({ name, value: schema });\n spec.components.schemas[name] = schema;\n\n const properties = schema['x-properties'] as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropName = propName.replace('[]', '');\n // this neeeds inheritance logic first otherwise it'll create class mess\n // const refName = findUniqueSchemaName(\n // spec,\n // propName,\n // ['Property', 'Field', 'Attribute'],\n // pascalcase(joinSkipDigits([name, fixedPropName], ' ')),\n // );\n const refName = pascalcase(joinSkipDigits([name, fixedPropName], ' '));\n\n if (!isEmpty(value.properties)) {\n // refs.push({ name: refName, value: value });\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.oneOf)) {\n expandOneOf(spec, name, value, refs, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.anyOf)) {\n expandOneOf(spec, name, value, refs, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else {\n expandSpec(spec, { [refName]: value }, refs);\n }\n }\n continue;\n }\n\n if (schema.type === 'array') {\n if (isRef(schema.items)) continue;\n if (isEmpty(schema.items)) continue;\n const refName = findUniqueSchemaName(spec, name, ['Item', 'Entry']);\n if (schema.items.type === 'object') {\n // const refName = findUniqueSchemaName(spec, name, ['Object']);\n // refs.push({ name: refName, value: schema.items });\n spec.components.schemas[refName] = schema.items;\n expandSpec(spec, { [refName]: schema.items }, refs);\n schema.items = { $ref: `#/components/schemas/${refName}` };\n continue;\n }\n if (schema.items.type === 'array') {\n // for nested arrays, we need to move the last nested items only\n // so {type: 'array', items: { type: 'array', items: { type: 'object', properties: ... } }}\n // only object schema is moved while the array hirarchy is intact.\n expandSpec(spec, { [refName]: schema.items }, refs);\n continue;\n }\n if (!isEmpty(schema.items.oneOf)) {\n expandOneOf(spec, refName, schema.items, refs, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.items.anyOf)) {\n expandOneOf(spec, refName, schema.items, refs, 'anyOf');\n continue;\n }\n }\n if (!isEmpty(schema.oneOf)) {\n expandOneOf(spec, name, schema, refs, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.anyOf)) {\n expandOneOf(spec, name, schema, refs, 'anyOf');\n continue;\n }\n }\n}\n\nfunction expandOneOf(\n spec: OurOpenAPIObject,\n name: string,\n schema: SchemaObject,\n refs: Refs,\n kind: 'oneOf' | 'anyOf',\n) {\n const varients = schema['x-varients'] as Varient[];\n if (!varients || varients.length === 0) {\n console.warn(\n `No varients found for ${name}. This might be an error in the OpenAPI spec.`,\n );\n }\n varients.forEach((varient) => {\n const varientSchema = schema[kind]![varient.position];\n if (isRef(varientSchema)) return;\n const refName = findUniqueSchemaName(\n spec,\n pascalcase(`${name} ${varient.name}`),\n ['Varient'],\n );\n\n if (varientSchema.type === 'object') {\n expandSpec(spec, { [refName]: varientSchema }, refs);\n schema[kind]![varient.position] = {\n $ref: `#/components/schemas/${refName}`,\n };\n } else {\n expandSpec(spec, { [refName]: varientSchema }, refs);\n }\n\n // const referable = (['array', 'object'] as SchemaObjectType[]).some((type) =>\n // coerceTypes(varientSchema).includes(type),\n // );\n // if (!referable) {\n // return;\n // }\n });\n}\n\nexport function coerceTypes(\n schema: SchemaObject,\n excludeNull = true,\n): SchemaObjectType[] {\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n if (excludeNull) {\n return types.filter((type) => type !== 'null');\n }\n return types;\n}\n"],
4
+ "sourcesContent": ["import { merge, uniq } from 'lodash-es';\nimport assert from 'node:assert';\nimport type {\n ReferenceObject,\n SchemaObject,\n SchemaObjectType,\n} from 'openapi3-ts/oas31';\n\nimport {\n isEmpty,\n isRef,\n joinSkipDigits,\n notRef,\n pascalcase,\n resolveRef,\n snakecase,\n} from '@sdk-it/core';\n\nimport { type Varient, findVarients } from './find-polymorphic-varients.js';\nimport { findUniqueSchemaName } from './find-unique-schema-name.js';\nimport { formatName } from './format-name.js';\nimport { isPrimitiveSchema } from './is-primitive-schema.js';\nimport type { IR } from './types.js';\n\nexport function fixSpec(\n spec: IR,\n schemas: (SchemaObject | ReferenceObject)[],\n visited = new Set<string>(),\n) {\n for (const schema of schemas) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.properties)) {\n schema.type = 'object';\n delete schema.oneOf;\n delete schema.anyOf;\n fixSpec(spec, Object.values(schema.properties), visited);\n // path param are required and if it happens to have\n // body with defaults then zod would break off. so flat the defaults from object itself to properties\n for (const [key, value] of Object.entries(schema.properties)) {\n if (notRef(value) && isPrimitiveSchema(value)) {\n value.default ??= schema.default?.[key];\n delete schema.default?.[key];\n }\n }\n delete schema.default; // default should not be in properties\n }\n\n if (!isEmpty(schema['x-properties'])) {\n fixSpec(spec, Object.values(schema['x-properties']), visited);\n }\n\n if (!isEmpty(schema.items)) {\n delete schema.oneOf;\n delete schema.anyOf;\n schema.type = 'array';\n fixSpec(spec, [schema.items], visited);\n const items = resolveRef<SchemaObject>(spec, schema.items);\n if (Array.isArray(items.default)) {\n schema.default ??= structuredClone(items.default);\n }\n delete items.default; // default should not be in items\n }\n\n if (!isEmpty(schema.anyOf) && !isEmpty(schema.oneOf)) {\n delete schema.anyOf;\n }\n\n if (isEmpty(schema.enum)) {\n delete schema.enum;\n }\n\n if (!isEmpty(schema.enum)) {\n if (schema.enum.length === 1) {\n schema.const = schema.enum[0];\n delete schema.enum;\n } else {\n const valuesSet = new Set<string>();\n const valuesList = [];\n for (const it of schema.enum) {\n const formattedValue = formatName(snakecase(formatName(it)));\n if (!valuesSet.has(formattedValue)) {\n valuesSet.add(formattedValue);\n valuesList.push(it);\n }\n }\n schema.enum = valuesList;\n }\n delete schema.allOf;\n }\n\n if (schema.const !== undefined) {\n schema.default = schema.const;\n }\n\n if (!isEmpty(schema.allOf)) {\n const schemas = schema.allOf;\n // if (schemas.length === 1) {\n // fixSpec(spec, [schemas[0]], visited);\n // Object.assign(schema, schemas[0]);\n // delete schema.allOf;\n // } else {\n // }\n const resolved = schemas.map((it) => resolveRef<SchemaObject>(spec, it));\n const hasObjects = resolved.some((it) => it.type === 'object');\n const hasOtherTypes = resolved.some(\n (it) => it.type && it.type !== 'object',\n );\n if (hasObjects && hasOtherTypes) {\n assert(false, `allOf must be an object`);\n }\n merge(\n schema,\n ...resolved.map((it) => {\n fixSpec(spec, [it], visited);\n return it;\n }),\n );\n delete schema.allOf;\n } else {\n delete schema.allOf;\n }\n\n if (\n schema.type === 'object' &&\n isEmpty(schema.properties) &&\n typeof schema.additionalProperties === 'object' &&\n !isEmpty(schema.additionalProperties) &&\n notRef(schema.additionalProperties) &&\n !isEmpty(schema.additionalProperties.properties)\n ) {\n // additionalProperties is of type object and properties is empty\n fixSpec(\n spec,\n Object.values(schema.additionalProperties.properties),\n visited,\n );\n Object.assign(schema, schema.additionalProperties);\n delete schema.additionalProperties;\n }\n\n for (const kind of ['oneOf', 'anyOf'] as const) {\n if (!isEmpty(schema[kind])) {\n delete schema.type; // type is not allowed with oneOf or anyOf\n fixSpec(spec, schema[kind], visited);\n if (isEmpty(schema[kind])) {\n // fixSpec can remove oneOf or anyOf if it has no items so we need to check again\n // after fixing\n continue;\n }\n\n let enumSchemaIndex = -1;\n const enumValues: string[] = [];\n for (let idx = 0; idx < schema[kind].length; idx++) {\n // for (const idx in schema[kind]) {\n const item = schema[kind][idx];\n // just handle non ref for now\n if (notRef(item) && item.type === 'string') {\n // if enum equal one it'd already have been converted to const so check for more than one\n if (item.enum && item.enum.length > 1) {\n // foundEnum = true;\n enumValues.push(...item.enum);\n if (enumSchemaIndex === -1) {\n enumSchemaIndex = idx;\n }\n }\n }\n }\n if (enumSchemaIndex !== -1) {\n const enumSchema = schema[kind][enumSchemaIndex];\n if (notRef(enumSchema)) {\n enumSchema.enum = uniq(enumValues);\n }\n // delete the other schemas that have enum\n schema[kind] = schema[kind].filter(\n (it, idx) => idx === enumSchemaIndex || isRef(it),\n );\n }\n const otherTypes = schema[kind].filter(\n (it) => resolveRef<SchemaObject>(spec, it).type !== 'null',\n );\n if (otherTypes.length === 1) {\n Object.assign(schema, otherTypes[0]);\n delete schema[kind];\n continue;\n }\n\n schema['x-varients'] = findVarients(spec, schema[kind]);\n } else {\n delete schema[kind];\n }\n }\n }\n}\n\ntype Refs = { name: string; value: SchemaObject }[];\n\nexport function expandSpec(\n spec: IR,\n schemas: Record<string, SchemaObject | ReferenceObject>,\n refs: Refs,\n) {\n for (const [name, schema] of Object.entries(schemas)) {\n if (isRef(schema)) continue;\n\n if (!isEmpty(schema.properties)) {\n if (!isEmpty(schema.oneOf)) {\n for (const oneOfIdx in schema.oneOf) {\n const oneOf = schema.oneOf[oneOfIdx];\n if (isRef(oneOf)) continue;\n for (const key of ['properties', 'x-properties'] as const) {\n if (!isEmpty(oneOf.required) && schema[key]) {\n schema.oneOf[oneOfIdx] = schema[key][oneOf.required[0]];\n }\n }\n }\n delete schema.type;\n expandSpec(spec, schemas, refs);\n continue;\n }\n if (schema.additionalProperties) {\n continue;\n }\n // refs.push({ name, value: schema });\n spec.components.schemas[name] = schema;\n const properties = schema.properties as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropName = propName.replace('[]', '');\n // this neeeds inheritance logic first otherwise it'll create class mess\n // const refName = findUniqueSchemaName(\n // spec,\n // propName,\n // ['Property', 'Field', 'Attribute'],\n // pascalcase(joinSkipDigits([name, fixedPropName], ' ')),\n // );\n const refName = pascalcase(joinSkipDigits([name, fixedPropName], ' '));\n\n if (!isEmpty(value.properties)) {\n // refs.push({ name: refName, value: value });\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.oneOf)) {\n expandOneOf(spec, name, value, refs, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.anyOf)) {\n expandOneOf(spec, name, value, refs, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else {\n expandSpec(spec, { [refName]: value }, refs);\n }\n }\n\n continue;\n }\n if (!isEmpty(schema['x-properties'])) {\n // refs.push({ name, value: schema });\n spec.components.schemas[name] = schema;\n\n const properties = schema['x-properties'] as Record<\n string,\n SchemaObject | ReferenceObject\n >;\n for (const [propName, value] of Object.entries(properties)) {\n if (isRef(value)) continue;\n\n const fixedPropName = propName.replace('[]', '');\n // this neeeds inheritance logic first otherwise it'll create class mess\n // const refName = findUniqueSchemaName(\n // spec,\n // propName,\n // ['Property', 'Field', 'Attribute'],\n // pascalcase(joinSkipDigits([name, fixedPropName], ' ')),\n // );\n const refName = pascalcase(joinSkipDigits([name, fixedPropName], ' '));\n\n if (!isEmpty(value.properties)) {\n // refs.push({ name: refName, value: value });\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.oneOf)) {\n expandOneOf(spec, name, value, refs, 'oneOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else if (!isEmpty(value.anyOf)) {\n expandOneOf(spec, name, value, refs, 'anyOf');\n\n spec.components.schemas[refName] = value;\n properties[propName] = { $ref: `#/components/schemas/${refName}` };\n expandSpec(spec, { [refName]: value }, refs);\n } else {\n expandSpec(spec, { [refName]: value }, refs);\n }\n }\n continue;\n }\n\n if (schema.type === 'array') {\n if (isRef(schema.items)) continue;\n if (isEmpty(schema.items)) continue;\n const refName = findUniqueSchemaName(spec, name, ['Item', 'Entry']);\n if (schema.items.type === 'object') {\n // const refName = findUniqueSchemaName(spec, name, ['Object']);\n // refs.push({ name: refName, value: schema.items });\n spec.components.schemas[refName] = schema.items;\n expandSpec(spec, { [refName]: schema.items }, refs);\n schema.items = { $ref: `#/components/schemas/${refName}` };\n continue;\n }\n if (schema.items.type === 'array') {\n // for nested arrays, we need to move the last nested items only\n // so {type: 'array', items: { type: 'array', items: { type: 'object', properties: ... } }}\n // only object schema is moved while the array hirarchy is intact.\n expandSpec(spec, { [refName]: schema.items }, refs);\n continue;\n }\n if (!isEmpty(schema.items.oneOf)) {\n expandOneOf(spec, refName, schema.items, refs, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.items.anyOf)) {\n expandOneOf(spec, refName, schema.items, refs, 'anyOf');\n continue;\n }\n }\n if (!isEmpty(schema.oneOf)) {\n expandOneOf(spec, name, schema, refs, 'oneOf');\n continue;\n }\n if (!isEmpty(schema.anyOf)) {\n expandOneOf(spec, name, schema, refs, 'anyOf');\n continue;\n }\n }\n}\n\nfunction expandOneOf(\n spec: IR,\n name: string,\n schema: SchemaObject,\n refs: Refs,\n kind: 'oneOf' | 'anyOf',\n) {\n const varients = schema['x-varients'] as Varient[];\n if (!varients || varients.length === 0) {\n console.warn(\n `No varients found for ${name}. This might be an error in the OpenAPI spec.`,\n );\n }\n varients.forEach((varient) => {\n const varientSchema = schema[kind]![varient.position];\n if (isRef(varientSchema)) return;\n const refName = findUniqueSchemaName(\n spec,\n pascalcase(`${name} ${varient.name}`),\n ['Varient'],\n );\n\n if (varientSchema.type === 'object') {\n expandSpec(spec, { [refName]: varientSchema }, refs);\n schema[kind]![varient.position] = {\n $ref: `#/components/schemas/${refName}`,\n };\n } else {\n expandSpec(spec, { [refName]: varientSchema }, refs);\n }\n\n // const referable = (['array', 'object'] as SchemaObjectType[]).some((type) =>\n // coerceTypes(varientSchema).includes(type),\n // );\n // if (!referable) {\n // return;\n // }\n });\n}\n\nexport function coerceTypes(\n schema: SchemaObject,\n excludeNull = true,\n): SchemaObjectType[] {\n const types = Array.isArray(schema.type)\n ? schema.type\n : schema.type\n ? [schema.type]\n : [];\n if (excludeNull) {\n return types.filter((type) => type !== 'null');\n }\n return types;\n}\n"],
5
5
  "mappings": "AAAA,SAAS,OAAO,YAAY;AAC5B,OAAO,YAAY;AAOnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAuB,oBAAoB;AAC3C,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB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merge } from "lodash-es";
2
2
  import { describe, it } from "node:test";
3
- import { augmentSpec } from "./operation.ts";
3
+ import { toIR } from "./ir.ts";
4
4
  function createSpec(openapi) {
5
- return augmentSpec(
5
+ return toIR(
6
6
  {
7
7
  spec: merge(
8
8
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/tune.test.ts"],
4
- "sourcesContent": ["import { merge } from 'lodash-es';\nimport { describe, it } from 'node:test';\nimport type { OpenAPIObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { augmentSpec } from './operation.ts';\nimport type { OurOpenAPIObject } from './types.ts';\n\nfunction createSpec(openapi?: Partial<OpenAPIObject>): OurOpenAPIObject {\n return augmentSpec(\n {\n spec: merge(\n {\n openapi: '3.1.0',\n info: {\n title: 'Test API',\n version: '1.0.0',\n },\n components: {\n schemas: {},\n securitySchemes: {},\n },\n paths: {},\n },\n openapi,\n ),\n },\n true,\n );\n}\n\ndescribe('merge allof', () => {\n // it('should merge allOf schemas', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // Base: {\n // type: 'object',\n // properties: {\n // id: { type: 'string' },\n // },\n // },\n // Extended: {\n // allOf: [\n // { $ref: '#/components/schemas/Base' },\n // {\n // type: 'object',\n // properties: {\n // name: { type: 'string' },\n // },\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // const extendedSchema = spec.components.schemas.Extended as SchemaObject;\n // console.log(extendedSchema);\n // assert.deepStrictEqual(extendedSchema.type, 'object');\n // assert.deepStrictEqual(extendedSchema.properties, {\n // id: { type: 'string' },\n // name: { type: 'string' },\n // });\n // });\n // it('should handle empty allOf', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // EmptyAllOf: {\n // allOf: [],\n // },\n // },\n // },\n // });\n\n // const emptySchema = spec.components.schemas.EmptyAllOf as SchemaObject;\n // assert.deepStrictEqual(emptySchema.allOf, undefined);\n // assert.deepStrictEqual(emptySchema.type, undefined);\n // });\n // it('should handle allOf with only references', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // Base: {\n // type: 'object',\n // properties: {\n // id: { type: 'string' },\n // },\n // },\n // Extended: {\n // allOf: [\n // {\n // $ref: '#/components/schemas/Base',\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // const extendedSchema = spec.components.schemas.Extended as SchemaObject;\n // assert.deepStrictEqual(extendedSchema.type, 'object');\n // assert.deepStrictEqual(extendedSchema.properties, {\n // id: {\n // type: 'string',\n // },\n // });\n // });\n\n it('should handle circular allOf references without stack overflow', () => {\n const spec = createSpec({\n components: {\n schemas: {\n A: {\n allOf: [\n { $ref: '#/components/schemas/B' },\n {\n type: 'object',\n properties: {\n nameA: { type: 'string' },\n },\n },\n ],\n },\n B: {\n allOf: [\n { $ref: '#/components/schemas/A' },\n {\n type: 'object',\n properties: {\n nameB: { type: 'string' },\n },\n },\n ],\n },\n },\n },\n });\n\n // This would cause a stack overflow with the current implementation\n const schemaA = spec.components.schemas.A as SchemaObject;\n console.dir(spec.components.schemas, { depth: null });\n // The test should not throw RangeError: Maximum call stack size exceeded\n });\n\n // it('should handle circular allOf references without stack overflow', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // A: {\n // allOf: [\n // { $ref: '#/components/schemas/B' },\n // {\n // type: 'object',\n // properties: {\n // nameA: { type: 'string' },\n // },\n // },\n // ],\n // },\n // B: {\n // allOf: [\n // { $ref: '#/components/schemas/A' },\n // {\n // type: 'object',\n // properties: {\n // nameB: { type: 'string' },\n // },\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // // This would cause a stack overflow with the current implementation\n // const schemaA = spec.components.schemas.A as SchemaObject;\n // console.dir(spec.components.schemas, { depth: null });\n // // The test should not throw RangeError: Maximum call stack size exceeded\n // });\n\n // it('should handle self-referencing allOf', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // SelfRef: {\n // allOf: [\n // { $ref: '#/components/schemas/SelfRef' },\n // {\n // type: 'object',\n // properties: {\n // name: { type: 'string' },\n // },\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // // This would also cause infinite recursion\n // const schema = spec.components.schemas.SelfRef as SchemaObject;\n // });\n});\n"],
5
- "mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,UAAU,UAAU;AAG7B,SAAS,mBAAmB;AAG5B,SAAS,WAAW,SAAoD;AACtE,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,QACJ;AAAA,UACE,SAAS;AAAA,UACT,MAAM;AAAA,YACJ,OAAO;AAAA,YACP,SAAS;AAAA,UACX;AAAA,UACA,YAAY;AAAA,YACV,SAAS,CAAC;AAAA,YACV,iBAAiB,CAAC;AAAA,UACpB;AAAA,UACA,OAAO,CAAC;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,eAAe,MAAM;AA+E5B,KAAG,kEAAkE,MAAM;AACzE,UAAM,OAAO,WAAW;AAAA,MACtB,YAAY;AAAA,QACV,SAAS;AAAA,UACP,GAAG;AAAA,YACD,OAAO;AAAA,cACL,EAAE,MAAM,yBAAyB;AAAA,cACjC;AAAA,gBACE,MAAM;AAAA,gBACN,YAAY;AAAA,kBACV,OAAO,EAAE,MAAM,SAAS;AAAA,gBAC1B;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,UACA,GAAG;AAAA,YACD,OAAO;AAAA,cACL,EAAE,MAAM,yBAAyB;AAAA,cACjC;AAAA,gBACE,MAAM;AAAA,gBACN,YAAY;AAAA,kBACV,OAAO,EAAE,MAAM,SAAS;AAAA,gBAC1B;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAGD,UAAM,UAAU,KAAK,WAAW,QAAQ;AACxC,YAAQ,IAAI,KAAK,WAAW,SAAS,EAAE,OAAO,KAAK,CAAC;AAAA,EAEtD,CAAC;AA4DH,CAAC;",
4
+ "sourcesContent": ["import { merge } from 'lodash-es';\nimport { describe, it } from 'node:test';\nimport type { OpenAPIObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { toIR } from './ir.ts';\nimport type { IR } from './types.ts';\n\nfunction createSpec(openapi?: Partial<OpenAPIObject>): IR {\n return toIR(\n {\n spec: merge(\n {\n openapi: '3.1.0',\n info: {\n title: 'Test API',\n version: '1.0.0',\n },\n components: {\n schemas: {},\n securitySchemes: {},\n },\n paths: {},\n },\n openapi,\n ),\n },\n true,\n );\n}\n\ndescribe('merge allof', () => {\n // it('should merge allOf schemas', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // Base: {\n // type: 'object',\n // properties: {\n // id: { type: 'string' },\n // },\n // },\n // Extended: {\n // allOf: [\n // { $ref: '#/components/schemas/Base' },\n // {\n // type: 'object',\n // properties: {\n // name: { type: 'string' },\n // },\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // const extendedSchema = spec.components.schemas.Extended as SchemaObject;\n // console.log(extendedSchema);\n // assert.deepStrictEqual(extendedSchema.type, 'object');\n // assert.deepStrictEqual(extendedSchema.properties, {\n // id: { type: 'string' },\n // name: { type: 'string' },\n // });\n // });\n // it('should handle empty allOf', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // EmptyAllOf: {\n // allOf: [],\n // },\n // },\n // },\n // });\n\n // const emptySchema = spec.components.schemas.EmptyAllOf as SchemaObject;\n // assert.deepStrictEqual(emptySchema.allOf, undefined);\n // assert.deepStrictEqual(emptySchema.type, undefined);\n // });\n // it('should handle allOf with only references', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // Base: {\n // type: 'object',\n // properties: {\n // id: { type: 'string' },\n // },\n // },\n // Extended: {\n // allOf: [\n // {\n // $ref: '#/components/schemas/Base',\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // const extendedSchema = spec.components.schemas.Extended as SchemaObject;\n // assert.deepStrictEqual(extendedSchema.type, 'object');\n // assert.deepStrictEqual(extendedSchema.properties, {\n // id: {\n // type: 'string',\n // },\n // });\n // });\n\n it('should handle circular allOf references without stack overflow', () => {\n const spec = createSpec({\n components: {\n schemas: {\n A: {\n allOf: [\n { $ref: '#/components/schemas/B' },\n {\n type: 'object',\n properties: {\n nameA: { type: 'string' },\n },\n },\n ],\n },\n B: {\n allOf: [\n { $ref: '#/components/schemas/A' },\n {\n type: 'object',\n properties: {\n nameB: { type: 'string' },\n },\n },\n ],\n },\n },\n },\n });\n\n // This would cause a stack overflow with the current implementation\n const schemaA = spec.components.schemas.A as SchemaObject;\n console.dir(spec.components.schemas, { depth: null });\n // The test should not throw RangeError: Maximum call stack size exceeded\n });\n\n // it('should handle circular allOf references without stack overflow', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // A: {\n // allOf: [\n // { $ref: '#/components/schemas/B' },\n // {\n // type: 'object',\n // properties: {\n // nameA: { type: 'string' },\n // },\n // },\n // ],\n // },\n // B: {\n // allOf: [\n // { $ref: '#/components/schemas/A' },\n // {\n // type: 'object',\n // properties: {\n // nameB: { type: 'string' },\n // },\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // // This would cause a stack overflow with the current implementation\n // const schemaA = spec.components.schemas.A as SchemaObject;\n // console.dir(spec.components.schemas, { depth: null });\n // // The test should not throw RangeError: Maximum call stack size exceeded\n // });\n\n // it('should handle self-referencing allOf', () => {\n // const spec = createSpec({\n // components: {\n // schemas: {\n // SelfRef: {\n // allOf: [\n // { $ref: '#/components/schemas/SelfRef' },\n // {\n // type: 'object',\n // properties: {\n // name: { type: 'string' },\n // },\n // },\n // ],\n // },\n // },\n // },\n // });\n\n // // This would also cause infinite recursion\n // const schema = spec.components.schemas.SelfRef as SchemaObject;\n // });\n});\n"],
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,UAAU,UAAU;AAG7B,SAAS,YAAY;AAGrB,SAAS,WAAW,SAAsC;AACxD,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,QACJ;AAAA,UACE,SAAS;AAAA,UACT,MAAM;AAAA,YACJ,OAAO;AAAA,YACP,SAAS;AAAA,UACX;AAAA,UACA,YAAY;AAAA,YACV,SAAS,CAAC;AAAA,YACV,iBAAiB,CAAC;AAAA,UACpB;AAAA,UACA,OAAO,CAAC;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,eAAe,MAAM;AA+E5B,KAAG,kEAAkE,MAAM;AACzE,UAAM,OAAO,WAAW;AAAA,MACtB,YAAY;AAAA,QACV,SAAS;AAAA,UACP,GAAG;AAAA,YACD,OAAO;AAAA,cACL,EAAE,MAAM,yBAAyB;AAAA,cACjC;AAAA,gBACE,MAAM;AAAA,gBACN,YAAY;AAAA,kBACV,OAAO,EAAE,MAAM,SAAS;AAAA,gBAC1B;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,UACA,GAAG;AAAA,YACD,OAAO;AAAA,cACL,EAAE,MAAM,yBAAyB;AAAA,cACjC;AAAA,gBACE,MAAM;AAAA,gBACN,YAAY;AAAA,kBACV,OAAO,EAAE,MAAM,SAAS;AAAA,gBAC1B;AAAA,cACF;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AAGD,UAAM,UAAU,KAAK,WAAW,QAAQ;AACxC,YAAQ,IAAI,KAAK,WAAW,SAAS,EAAE,OAAO,KAAK,CAAC;AAAA,EAEtD,CAAC;AA4DH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,8 @@
1
- import type { ComponentsObject, MediaTypeObject, OpenAPIObject, OperationObject, ParameterObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject, SecuritySchemeObject } from 'openapi3-ts/oas31';
1
+ import type { ComponentsObject, MediaTypeObject, OpenAPIObject, OperationObject, ParameterObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject, SecuritySchemeObject, ServerObject } from 'openapi3-ts/oas31';
2
2
  import type { PaginationGuess } from './pagination/guess-pagination.js';
3
3
  import type { SidebarData, TagGroups } from './sidebar.js';
4
- export interface OurOpenAPIObject extends OpenAPIObject {
4
+ export interface IR extends OpenAPIObject {
5
+ servers: ServerObject[];
5
6
  'x-sdk-augmented'?: boolean;
6
7
  'x-docs': SidebarData;
7
8
  'x-tagGroups': TagGroups[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,eAAe,EACf,eAAe,EACf,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,EAAE,WAAW,CAAC;IACtB,aAAa,EAAE,SAAS,EAAE,CAAC;IAC3B,UAAU,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;QAC9C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAAC,CAAC;QACxD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;KACvD,CAAC;IACF,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,OAAO,EAAE,MAAM,CACb,MAAM,EACN,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG;QAAE,MAAM,EAAE,eAAe,CAAA;KAAE,CAC9D,CAAC;CACH;AAED,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,eAAe,EACf,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,CAC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AAG,eAAe,GAAG;IAClD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdk-it/spec",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "!**/*.tsbuildinfo"
27
27
  ],
28
28
  "dependencies": {
29
- "@sdk-it/core": "0.28.0",
29
+ "@sdk-it/core": "0.30.0",
30
30
  "openapi3-ts": "4.4.0",
31
31
  "pluralize": "^8.0.0",
32
32
  "stringcase": "^4.3.1",
@@ -1,4 +0,0 @@
1
- import { type GenerateSdkConfig } from './options.js';
2
- import type { OurOpenAPIObject } from './types.js';
3
- export declare function augmentSpec(config: GenerateSdkConfig, verbose?: boolean): OurOpenAPIObject;
4
- //# sourceMappingURL=operation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/lib/operation.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,cAAc,CAAC;AAMrE,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAC;AAiCzE,wBAAgB,WAAW,CACzB,MAAM,EAAE,iBAAiB,EACzB,OAAO,UAAQ,GACd,gBAAgB,CAsGlB"}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/lib/operation.ts"],
4
- "sourcesContent": ["import type {\n OperationObject,\n ParameterObject,\n PathsObject,\n SchemaObject,\n} from 'openapi3-ts/oas31';\n\nimport { type Method, methods } from '@sdk-it/core/paths.js';\nimport { resolveRef } from '@sdk-it/core/ref.js';\nimport { snakecase } from '@sdk-it/core/utils.js';\n\nimport { toResource } from './guess/guess-resource.js';\nimport { type GenerateSdkConfig, coeraceConfig } from './options.js';\nimport { extractOverviewDocs } from './overview-docs/overview-docs.js';\nimport { toPagination } from './pagination/pagination.js';\nimport { tuneRequestBody } from './tune-request-body.js';\nimport { resolveResponses } from './tune-response.js';\nimport { expandSpec, fixSpec } from './tune.js';\nimport type { OurOpenAPIObject, TunedOperationObject } from './types.js';\n\nfunction findUniqueOperationId(\n usedOperationIds: Set<string>,\n initialId: string,\n choices: string[],\n formatter: (id: string) => string,\n) {\n let counter = 1;\n let uniqueOperationId = formatter(initialId);\n\n while (usedOperationIds.has(uniqueOperationId)) {\n // Try each prepend option\n const prependIndex = Math.min(counter - 1, choices.length - 1);\n const prefix = choices[prependIndex];\n\n if (prependIndex < choices.length - 1) {\n // Using one of the prepend options\n uniqueOperationId = formatter(\n `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}`,\n );\n } else {\n // If we've exhausted all prepend options, start adding numbers\n uniqueOperationId = formatter(\n `${prefix}${initialId.charAt(0).toUpperCase() + initialId.slice(1)}${counter - choices.length + 1}`,\n );\n }\n counter++;\n }\n\n return uniqueOperationId;\n}\n\nexport function augmentSpec(\n config: GenerateSdkConfig,\n verbose = false,\n): OurOpenAPIObject {\n const coearcedConfig = coeraceConfig(config);\n if ('x-sdk-augmented' in config.spec) {\n return config.spec as OurOpenAPIObject; // Already augmented\n }\n\n const paths: PathsObject = {};\n const usedOperationIds = new Set<string>();\n\n for (const [path, pathItem] of Object.entries(coearcedConfig.spec.paths)) {\n // Convert Express-style routes (:param) to OpenAPI-style routes ({param})\n const fixedPath = path.replace(/:([^/]+)/g, '{$1}');\n for (const [method, operation] of Object.entries(pathItem) as [\n Method,\n OperationObject,\n ][]) {\n if (!methods.includes(method)) {\n continue;\n }\n const { name } = toResource(operation, fixedPath, method);\n const operationTag = coearcedConfig.tag(operation, fixedPath);\n const operationId = findUniqueOperationId(\n usedOperationIds,\n coearcedConfig.operationId(operation, fixedPath, method),\n [operationTag, method, fixedPath.split('/').filter(Boolean).join('')],\n (id) =>\n coearcedConfig.operationId(\n { ...operation, operationId: id },\n fixedPath,\n method,\n ),\n );\n usedOperationIds.add(operationId);\n\n const parameters = [\n ...(pathItem.parameters ?? []),\n ...(operation.parameters ?? []),\n ].map((it) => resolveRef<ParameterObject>(coearcedConfig.spec, it));\n\n const tunedOperation: TunedOperationObject = {\n ...operation,\n parameters,\n 'x-fn-name': name,\n 'x-fn-group': operationTag,\n tags: [snakecase(operationTag)],\n operationId: operationId,\n responses: resolveResponses(\n coearcedConfig.spec,\n operationId,\n operation,\n coearcedConfig.responses,\n ),\n requestBody: tuneRequestBody(\n coearcedConfig.spec,\n operationId,\n // camelcase(`${name} ${operationTag}`),\n operation,\n parameters,\n operation.security ?? [],\n ),\n };\n\n if (coearcedConfig.pagination.enabled) {\n if (coearcedConfig.pagination.guess) {\n tunedOperation['x-pagination'] = toPagination(\n coearcedConfig.spec,\n tunedOperation,\n );\n }\n } else {\n delete tunedOperation['x-pagination'];\n }\n\n Object.assign(paths, {\n [fixedPath]: {\n ...paths[fixedPath],\n [method]: tunedOperation,\n },\n });\n }\n }\n\n fixSpec(\n coearcedConfig.spec,\n Object.values(coearcedConfig.spec.components.schemas),\n );\n\n if (verbose) {\n const newRefs: { name: string; value: SchemaObject }[] = [];\n expandSpec(\n coearcedConfig.spec,\n coearcedConfig.spec.components.schemas,\n newRefs,\n );\n }\n\n return {\n ...coearcedConfig.spec,\n paths,\n 'x-docs': extractOverviewDocs(coearcedConfig.spec),\n 'x-sdk-augmented': true,\n };\n}\n"],
5
- "mappings": "AAOA,SAAsB,eAAe;AACrC,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB;AAC3B,SAAiC,qBAAqB;AACtD,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,YAAY,eAAe;AAGpC,SAAS,sBACP,kBACA,WACA,SACA,WACA;AACA,MAAI,UAAU;AACd,MAAI,oBAAoB,UAAU,SAAS;AAE3C,SAAO,iBAAiB,IAAI,iBAAiB,GAAG;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AAmB;AAAA,EACrB;AACF;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=operation.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operation.test.d.ts","sourceRoot":"","sources":["../../src/lib/operation.test.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import type { NavItem } from '../sidebar.js';
2
- import type { OurOpenAPIObject } from '../types.js';
3
- export declare function generateQuickReferenceOverview(spec: OurOpenAPIObject): NavItem;
4
- //# sourceMappingURL=overview-quick-reference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overview-quick-reference.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-quick-reference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,gBAAgB,GACrB,OAAO,CA6KT"}
@@ -1,4 +0,0 @@
1
- import type { NavItem } from '../sidebar.js';
2
- import type { OurOpenAPIObject } from '../types.js';
3
- export declare function generateSdkExamplesOverview(spec: OurOpenAPIObject, availableSdks?: string[]): NavItem;
4
- //# sourceMappingURL=overview-sdk-examples.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overview-sdk-examples.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-sdk-examples.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,gBAAgB,EACtB,aAAa,GAAE,MAAM,EAAmB,GACvC,OAAO,CAwMT"}
@@ -1,4 +0,0 @@
1
- import type { NavItem } from '../sidebar.js';
2
- import type { OurOpenAPIObject } from '../types.js';
3
- export declare function generateUsageOverview(spec: OurOpenAPIObject): NavItem;
4
- //# sourceMappingURL=overview-usage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overview-usage.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-usage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CA2FrE"}
@@ -1,4 +0,0 @@
1
- import type { SidebarData } from './sidebar.js';
2
- import type { OurOpenAPIObject } from './types.js';
3
- export declare function extractOverviewDocs(spec: OurOpenAPIObject): SidebarData;
4
- //# sourceMappingURL=overview-docs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"overview-docs.d.ts","sourceRoot":"","sources":["../../src/lib/overview-docs.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAW,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAmMnD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,WAAW,CA0DvE"}