@sdk-it/spec 0.26.0 → 0.28.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 (44) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +2 -2
  5. package/dist/lib/operation.js +1 -1
  6. package/dist/lib/operation.js.map +1 -1
  7. package/dist/lib/options.d.ts +2 -2
  8. package/dist/lib/options.d.ts.map +1 -1
  9. package/dist/lib/options.js +9 -1
  10. package/dist/lib/options.js.map +2 -2
  11. package/dist/lib/overview-docs/overview-auth.d.ts +4 -0
  12. package/dist/lib/overview-docs/overview-auth.d.ts.map +1 -0
  13. package/dist/lib/overview-docs/overview-auth.js +173 -0
  14. package/dist/lib/overview-docs/overview-auth.js.map +7 -0
  15. package/dist/lib/overview-docs/overview-docs.d.ts +4 -0
  16. package/dist/lib/overview-docs/overview-docs.d.ts.map +1 -0
  17. package/dist/lib/overview-docs/overview-docs.js +20 -0
  18. package/dist/lib/overview-docs/overview-docs.js.map +7 -0
  19. package/dist/lib/overview-docs/overview-errors.d.ts +4 -0
  20. package/dist/lib/overview-docs/overview-errors.d.ts.map +1 -0
  21. package/dist/lib/overview-docs/overview-errors.js +137 -0
  22. package/dist/lib/overview-docs/overview-errors.js.map +7 -0
  23. package/dist/lib/overview-docs/overview-intro.d.ts +4 -0
  24. package/dist/lib/overview-docs/overview-intro.d.ts.map +1 -0
  25. package/dist/lib/overview-docs/overview-intro.js +77 -0
  26. package/dist/lib/overview-docs/overview-intro.js.map +7 -0
  27. package/dist/lib/overview-docs/overview-pagination.d.ts +4 -0
  28. package/dist/lib/overview-docs/overview-pagination.d.ts.map +1 -0
  29. package/dist/lib/overview-docs/overview-pagination.js +80 -0
  30. package/dist/lib/overview-docs/overview-pagination.js.map +7 -0
  31. package/dist/lib/overview-docs/overview-quick-reference.d.ts +4 -0
  32. package/dist/lib/overview-docs/overview-quick-reference.d.ts.map +1 -0
  33. package/dist/lib/overview-docs/overview-sdk-examples.d.ts +4 -0
  34. package/dist/lib/overview-docs/overview-sdk-examples.d.ts.map +1 -0
  35. package/dist/lib/overview-docs/overview-usage.d.ts +4 -0
  36. package/dist/lib/overview-docs/overview-usage.d.ts.map +1 -0
  37. package/dist/lib/tune-request-body.d.ts.map +1 -1
  38. package/dist/lib/tune-request-body.js +5 -2
  39. package/dist/lib/tune-request-body.js.map +2 -2
  40. package/dist/lib/types.d.ts +1 -1
  41. package/dist/lib/types.d.ts.map +1 -1
  42. package/package.json +2 -2
  43. package/dist/lib/overview-docs.js +0 -276
  44. package/dist/lib/overview-docs.js.map +0 -7
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './lib/loaders/remote-loader.js';
12
12
  export * from './lib/metadata.js';
13
13
  export * from './lib/operation.js';
14
14
  export * from './lib/options.js';
15
+ export * from './lib/overview-docs/overview-errors.js';
15
16
  export * from './lib/reserved-keywords.js';
16
17
  export * from './lib/security.js';
17
18
  export * from './lib/sidebar.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export * from "./lib/loaders/remote-loader.js";
12
12
  export * from "./lib/metadata.js";
13
13
  export * from "./lib/operation.js";
14
14
  export * from "./lib/options.js";
15
+ export * from "./lib/overview-docs/overview-errors.js";
15
16
  export * from "./lib/reserved-keywords.js";
16
17
  export * from "./lib/security.js";
17
18
  export * from "./lib/sidebar.js";
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["export * from './lib/create-operation.js';\nexport * from './lib/find-polymorphic-varients.js';\nexport * from './lib/find-unique-schema-name.js';\nexport * from './lib/for-each-operation.js';\nexport * from './lib/format-name.js';\nexport * from './lib/get-ref-usage.js';\nexport * from './lib/is-primitive-schema.js';\nexport * from './lib/is.js';\nexport * from './lib/loaders/load-spec.js';\nexport * from './lib/loaders/local-loader.js';\nexport * from './lib/loaders/remote-loader.js';\nexport * from './lib/metadata.js';\nexport * from './lib/operation.js';\nexport * from './lib/options.js';\nexport * from './lib/reserved-keywords.js';\nexport * from './lib/security.js';\nexport * from './lib/sidebar.js';\nexport * from './lib/tag.js';\nexport * from './lib/tune-request-body.js';\nexport * from './lib/tune-response.js';\nexport * from './lib/tune.js';\nexport * from './lib/types.js';\n"],
5
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["export * from './lib/create-operation.js';\nexport * from './lib/find-polymorphic-varients.js';\nexport * from './lib/find-unique-schema-name.js';\nexport * from './lib/for-each-operation.js';\nexport * from './lib/format-name.js';\nexport * from './lib/get-ref-usage.js';\nexport * from './lib/is-primitive-schema.js';\nexport * from './lib/is.js';\nexport * from './lib/loaders/load-spec.js';\nexport * from './lib/loaders/local-loader.js';\nexport * from './lib/loaders/remote-loader.js';\nexport * from './lib/metadata.js';\nexport * from './lib/operation.js';\nexport * from './lib/options.js';\nexport * from './lib/overview-docs/overview-errors.js';\nexport * from './lib/reserved-keywords.js';\nexport * from './lib/security.js';\nexport * from './lib/sidebar.js';\nexport * from './lib/tag.js';\nexport * from './lib/tune-request-body.js';\nexport * from './lib/tune-response.js';\nexport * from './lib/tune.js';\nexport * from './lib/types.js';\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -3,7 +3,7 @@ import { resolveRef } from "@sdk-it/core/ref.js";
3
3
  import { snakecase } from "@sdk-it/core/utils.js";
4
4
  import { toResource } from "./guess/guess-resource.js";
5
5
  import { coeraceConfig } from "./options.js";
6
- import { extractOverviewDocs } from "./overview-docs.js";
6
+ import { extractOverviewDocs } from "./overview-docs/overview-docs.js";
7
7
  import { toPagination } from "./pagination/pagination.js";
8
8
  import { tuneRequestBody } from "./tune-request-body.js";
9
9
  import { resolveResponses } from "./tune-response.js";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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.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"],
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
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;AAE9C,UAAM,eAAe,KAAK,IAAI,UAAU,GAAG,QAAQ,SAAS,CAAC;AAC7D,UAAM,SAAS,QAAQ,YAAY;AAEnC,QAAI,eAAe,QAAQ,SAAS,GAAG;AAErC,0BAAoB;AAAA,QAClB,GAAG,MAAM,GAAG,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC,CAAC;AAAA,MACpE;AAAA,IACF,OAAO;AAEL,0BAAoB;AAAA,QAClB,GAAG,MAAM,GAAG,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC,CAAC,GAAG,UAAU,QAAQ,SAAS,CAAC;AAAA,MACnG;AAAA,IACF;AACA;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;AAAA,QACjB;AAAA,QACA,aAAa;AAAA,UACX,eAAe;AAAA,UACf;AAAA;AAAA,UAEA;AAAA,UACA;AAAA,UACA,UAAU,YAAY,CAAC;AAAA,QACzB;AAAA,MACF;AAEA,UAAI,eAAe,WAAW,SAAS;AACrC,YAAI,eAAe,WAAW,OAAO;AACnC,yBAAe,cAAc,IAAI;AAAA,YAC/B,eAAe;AAAA,YACf;AAAA,UACF;AAAA,QACF;AAAA,MACF,OAAO;AACL,eAAO,eAAe,cAAc;AAAA,MACtC;AAEA,aAAO,OAAO,OAAO;AAAA,QACnB,CAAC,SAAS,GAAG;AAAA,UACX,GAAG,MAAM,SAAS;AAAA,UAClB,CAAC,MAAM,GAAG;AAAA,QACZ;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA;AAAA,IACE,eAAe;AAAA,IACf,OAAO,OAAO,eAAe,KAAK,WAAW,OAAO;AAAA,EACtD;AAEA,MAAI,SAAS;AACX,UAAM,UAAmD,CAAC;AAC1D;AAAA,MACE,eAAe;AAAA,MACf,eAAe,KAAK,WAAW;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG,eAAe;AAAA,IAClB;AAAA,IACA,UAAU,oBAAoB,eAAe,IAAI;AAAA,IACjD,mBAAmB;AAAA,EACrB;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import type { OpenAPIObject, OperationObject } from 'openapi3-ts/oas31';
1
+ import type { OpenAPIObject, OperationObject, SecuritySchemeObject } from 'openapi3-ts/oas31';
2
2
  export interface GenerateSdkConfig {
3
3
  spec: OpenAPIObject;
4
4
  responses?: ResponsesConfig;
@@ -26,7 +26,7 @@ export declare function coeraceConfig(config: GenerateSdkConfig): {
26
26
  [schema: string]: import("openapi3-ts/oas31").SchemaObject | import("openapi3-ts/oas31").ReferenceObject;
27
27
  };
28
28
  securitySchemes: {
29
- [securityScheme: string]: import("openapi3-ts/oas31").ReferenceObject | import("openapi3-ts/oas31").SecuritySchemeObject;
29
+ [k: string]: SecuritySchemeObject;
30
30
  };
31
31
  responses?: {
32
32
  [response: string]: import("openapi3-ts/oas31").ResponseObject | import("openapi3-ts/oas31").ReferenceObject;
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/lib/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMxE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;IACtC,WAAW,CAAC,EAAE,CACZ,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,KACX,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5D;AACD,MAAM,WAAW,eAAe;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,UAOnD;AAED,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAC/C,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,KAAK,CAAC,CAkBxD,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA5CxC,eAAe,QACpB,MAAM,UACJ,MAAM,KACX,MAAM;qBACO,eAAe,QAAQ,MAAM,KAAK,MAAM;EA+D3D;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,KAAK;;;EAmB9C"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/lib/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;IACtC,WAAW,CAAC,EAAE,CACZ,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,KACX,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5D;AACD,MAAM,WAAW,eAAe;IAC9B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,UAOnD;AAED,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAC/C,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,KAAK,CAAC,CAkBxD,CAAC;AAEF,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA5CxC,eAAe,QACpB,MAAM,UACJ,MAAM,KACX,MAAM;qBACO,eAAe,QAAQ,MAAM,KAAK,MAAM;EAsE3D;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,GAAG,SAAS,GAAG,KAAK;;;EAmB9C"}
@@ -1,4 +1,5 @@
1
1
  import { camelcase } from "stringcase";
2
+ import { resolveRef } from "@sdk-it/core";
2
3
  import { determineGenericTag, sanitizeTag } from "./tag.js";
3
4
  function cleanOperationId(operationId) {
4
5
  return camelcase(
@@ -27,7 +28,14 @@ function coeraceConfig(config) {
27
28
  components: {
28
29
  ...config.spec.components,
29
30
  schemas: config.spec.components?.schemas ?? {},
30
- securitySchemes: config.spec.components?.securitySchemes ?? {}
31
+ securitySchemes: Object.fromEntries(
32
+ Object.entries(config.spec.components?.securitySchemes ?? {}).map(
33
+ ([name, schema]) => [
34
+ name,
35
+ resolveRef(config.spec, schema)
36
+ ]
37
+ )
38
+ )
31
39
  },
32
40
  paths: config.spec.paths ?? {},
33
41
  "x-docs": [],
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/lib/options.ts"],
4
- "sourcesContent": ["import type { OpenAPIObject, OperationObject } from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\n\nimport { determineGenericTag, sanitizeTag } from './tag.js';\nimport type { OurOpenAPIObject } from './types.js';\n\nexport interface GenerateSdkConfig {\n spec: OpenAPIObject;\n responses?: ResponsesConfig;\n pagination?: PaginationConfig | false;\n operationId?: (\n operation: OperationObject,\n path: string,\n method: string,\n ) => string;\n tag?: (operation: OperationObject, path: string) => string;\n}\nexport interface ResponsesConfig {\n flattenErrorResponses?: boolean;\n}\n\nexport type PaginationConfig = {\n guess?: boolean;\n};\n\nexport function cleanOperationId(operationId: string) {\n return camelcase(\n operationId\n .split('#')\n .pop()!\n .replace(/-(?=\\d)/g, ''),\n );\n}\n\nexport const defaults: Partial<GenerateSdkConfig> &\n Required<Pick<GenerateSdkConfig, 'operationId' | 'tag'>> = {\n operationId: (operation, path, method) => {\n if (operation.operationId) {\n return cleanOperationId(operation.operationId);\n }\n\n return camelcase(\n [method, ...path.replace(/[\\\\/\\\\{\\\\}]/g, ' ').split(' ')]\n .filter(Boolean)\n .join(' ')\n .trim(),\n );\n },\n tag: (operation, path) => {\n return operation.tags?.[0]\n ? sanitizeTag(operation.tags?.[0])\n : determineGenericTag(path, operation);\n },\n};\n\nexport function coeraceConfig(config: GenerateSdkConfig) {\n return {\n pagination: coearcePaginationConfig(config.pagination),\n responses: config.responses ?? {},\n spec: {\n ...config.spec,\n components: {\n ...config.spec.components,\n schemas: config.spec.components?.schemas ?? {},\n securitySchemes: config.spec.components?.securitySchemes ?? {},\n },\n paths: config.spec.paths ?? {},\n 'x-docs': [],\n 'x-tagGroups': config.spec['x-tagGroups'] ?? [\n {\n name: 'API',\n tags: config.spec.tags?.map((tag) => tag.name) ?? [],\n },\n ],\n } satisfies OurOpenAPIObject,\n operationId: config.operationId ?? defaults.operationId,\n tag: config.tag ?? defaults.tag,\n };\n}\n\nexport function coearcePaginationConfig(\n options: PaginationConfig | undefined | false,\n) {\n if (options === undefined) {\n return {\n guess: true,\n enabled: true,\n };\n }\n if (options === false) {\n return {\n enabled: false,\n guess: false,\n };\n }\n // If options is true, we assume pagination is enabled with guessing\n return {\n guess: options.guess ?? true,\n enabled: true,\n };\n}\n"],
5
- "mappings": "AACA,SAAS,iBAAiB;AAE1B,SAAS,qBAAqB,mBAAmB;AAsB1C,SAAS,iBAAiB,aAAqB;AACpD,SAAO;AAAA,IACL,YACG,MAAM,GAAG,EACT,IAAI,EACJ,QAAQ,YAAY,EAAE;AAAA,EAC3B;AACF;AAEO,MAAM,WACgD;AAAA,EAC3D,aAAa,CAAC,WAAW,MAAM,WAAW;AACxC,QAAI,UAAU,aAAa;AACzB,aAAO,iBAAiB,UAAU,WAAW;AAAA,IAC/C;AAEA,WAAO;AAAA,MACL,CAAC,QAAQ,GAAG,KAAK,QAAQ,gBAAgB,GAAG,EAAE,MAAM,GAAG,CAAC,EACrD,OAAO,OAAO,EACd,KAAK,GAAG,EACR,KAAK;AAAA,IACV;AAAA,EACF;AAAA,EACA,KAAK,CAAC,WAAW,SAAS;AACxB,WAAO,UAAU,OAAO,CAAC,IACrB,YAAY,UAAU,OAAO,CAAC,CAAC,IAC/B,oBAAoB,MAAM,SAAS;AAAA,EACzC;AACF;AAEO,SAAS,cAAc,QAA2B;AACvD,SAAO;AAAA,IACL,YAAY,wBAAwB,OAAO,UAAU;AAAA,IACrD,WAAW,OAAO,aAAa,CAAC;AAAA,IAChC,MAAM;AAAA,MACJ,GAAG,OAAO;AAAA,MACV,YAAY;AAAA,QACV,GAAG,OAAO,KAAK;AAAA,QACf,SAAS,OAAO,KAAK,YAAY,WAAW,CAAC;AAAA,QAC7C,iBAAiB,OAAO,KAAK,YAAY,mBAAmB,CAAC;AAAA,MAC/D;AAAA,MACA,OAAO,OAAO,KAAK,SAAS,CAAC;AAAA,MAC7B,UAAU,CAAC;AAAA,MACX,eAAe,OAAO,KAAK,aAAa,KAAK;AAAA,QAC3C;AAAA,UACE,MAAM;AAAA,UACN,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,IAAI,IAAI,KAAK,CAAC;AAAA,QACrD;AAAA,MACF;AAAA,IACF;AAAA,IACA,aAAa,OAAO,eAAe,SAAS;AAAA,IAC5C,KAAK,OAAO,OAAO,SAAS;AAAA,EAC9B;AACF;AAEO,SAAS,wBACd,SACA;AACA,MAAI,YAAY,QAAW;AACzB,WAAO;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AACA,MAAI,YAAY,OAAO;AACrB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,QAAQ,SAAS;AAAA,IACxB,SAAS;AAAA,EACX;AACF;",
4
+ "sourcesContent": ["import type {\n OpenAPIObject,\n OperationObject,\n SecuritySchemeObject,\n} from 'openapi3-ts/oas31';\nimport { camelcase } from 'stringcase';\n\nimport { resolveRef } from '@sdk-it/core';\n\nimport { determineGenericTag, sanitizeTag } from './tag.js';\nimport type { OurOpenAPIObject } from './types.js';\n\nexport interface GenerateSdkConfig {\n spec: OpenAPIObject;\n responses?: ResponsesConfig;\n pagination?: PaginationConfig | false;\n operationId?: (\n operation: OperationObject,\n path: string,\n method: string,\n ) => string;\n tag?: (operation: OperationObject, path: string) => string;\n}\nexport interface ResponsesConfig {\n flattenErrorResponses?: boolean;\n}\n\nexport type PaginationConfig = {\n guess?: boolean;\n};\n\nexport function cleanOperationId(operationId: string) {\n return camelcase(\n operationId\n .split('#')\n .pop()!\n .replace(/-(?=\\d)/g, ''),\n );\n}\n\nexport const defaults: Partial<GenerateSdkConfig> &\n Required<Pick<GenerateSdkConfig, 'operationId' | 'tag'>> = {\n operationId: (operation, path, method) => {\n if (operation.operationId) {\n return cleanOperationId(operation.operationId);\n }\n\n return camelcase(\n [method, ...path.replace(/[\\\\/\\\\{\\\\}]/g, ' ').split(' ')]\n .filter(Boolean)\n .join(' ')\n .trim(),\n );\n },\n tag: (operation, path) => {\n return operation.tags?.[0]\n ? sanitizeTag(operation.tags?.[0])\n : determineGenericTag(path, operation);\n },\n};\n\nexport function coeraceConfig(config: GenerateSdkConfig) {\n return {\n pagination: coearcePaginationConfig(config.pagination),\n responses: config.responses ?? {},\n spec: {\n ...config.spec,\n components: {\n ...config.spec.components,\n schemas: config.spec.components?.schemas ?? {},\n securitySchemes: Object.fromEntries(\n Object.entries(config.spec.components?.securitySchemes ?? {}).map(\n ([name, schema]) => [\n name,\n resolveRef<SecuritySchemeObject>(config.spec, schema),\n ],\n ),\n ),\n },\n paths: config.spec.paths ?? {},\n 'x-docs': [],\n 'x-tagGroups': config.spec['x-tagGroups'] ?? [\n {\n name: 'API',\n tags: config.spec.tags?.map((tag) => tag.name) ?? [],\n },\n ],\n } satisfies OurOpenAPIObject,\n operationId: config.operationId ?? defaults.operationId,\n tag: config.tag ?? defaults.tag,\n };\n}\n\nexport function coearcePaginationConfig(\n options: PaginationConfig | undefined | false,\n) {\n if (options === undefined) {\n return {\n guess: true,\n enabled: true,\n };\n }\n if (options === false) {\n return {\n enabled: false,\n guess: false,\n };\n }\n // If options is true, we assume pagination is enabled with guessing\n return {\n guess: options.guess ?? true,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AAO,KAAK,aAAa,KAAK;AAAA,QAC3C;AAAA,UACE,MAAM;AAAA,UACN,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,IAAI,IAAI,KAAK,CAAC;AAAA,QACrD;AAAA,MACF;AAAA,IACF;AAAA,IACA,aAAa,OAAO,eAAe,SAAS;AAAA,IAC5C,KAAK,OAAO,OAAO,SAAS;AAAA,EAC9B;AACF;AAEO,SAAS,wBACd,SACA;AACA,MAAI,YAAY,QAAW;AACzB,WAAO;AAAA,MACL,OAAO;AAAA,MACP,SAAS;AAAA,IACX;AAAA,EACF;AACA,MAAI,YAAY,OAAO;AACrB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,QAAQ,SAAS;AAAA,IACxB,SAAS;AAAA,EACX;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,4 @@
1
+ import type { NavItem } from '../sidebar.js';
2
+ import type { OurOpenAPIObject } from '../types.js';
3
+ export declare function generateAuthOverview(spec: OurOpenAPIObject): NavItem;
4
+ //# sourceMappingURL=overview-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overview-auth.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA+GpD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAsDpE"}
@@ -0,0 +1,173 @@
1
+ import { resolveRef } from "@sdk-it/core";
2
+ function getSecuritySchemeDescription(scheme) {
3
+ switch (scheme.type) {
4
+ case "apiKey": {
5
+ const location = scheme.in === "header" ? "HTTP header" : scheme.in === "query" ? "query parameter" : "cookie";
6
+ return `API Key authentication requires you to provide an API key in the ${location} named \`${scheme.name}\`.`;
7
+ }
8
+ case "http":
9
+ if (scheme.scheme === "bearer") {
10
+ const format = scheme.bearerFormat ? ` The expected token format is \`${scheme.bearerFormat}\`.` : "";
11
+ return `Bearer token authentication requires you to include a bearer token in the \`Authorization\` header of your requests.${format}`;
12
+ }
13
+ if (scheme.scheme === "basic") {
14
+ return `Basic authentication requires you to provide a username and password, encoded in base64 format in the \`Authorization\` header.`;
15
+ }
16
+ return `HTTP ${scheme.scheme} authentication is required for accessing this API.`;
17
+ case "oauth2": {
18
+ const flows = Object.keys(scheme.flows || {});
19
+ const flowDescriptions = flows.map((flow) => {
20
+ switch (flow) {
21
+ case "authorizationCode":
22
+ return "Authorization Code (for server-side applications)";
23
+ case "implicit":
24
+ return "Implicit (for browser-based applications)";
25
+ case "password":
26
+ return "Resource Owner Password Credentials";
27
+ case "clientCredentials":
28
+ return "Client Credentials (for machine-to-machine authentication)";
29
+ default:
30
+ return flow;
31
+ }
32
+ });
33
+ return `OAuth 2.0 authentication is supported with the following grant type(s): ${flowDescriptions.join(", ")}.`;
34
+ }
35
+ case "openIdConnect":
36
+ return `OpenID Connect authentication is used for this API. You will need to authenticate through the OpenID provider to obtain access tokens.`;
37
+ default:
38
+ return "This API uses a custom authentication scheme. Please refer to the API documentation for specific details.";
39
+ }
40
+ }
41
+ function formatOAuth2Flows(flows) {
42
+ let result = "";
43
+ for (const [flowType, flow] of Object.entries(flows || {})) {
44
+ result += `#### ${getFlowDisplayName(flowType)}
45
+
46
+ `;
47
+ if (flow.authorizationUrl) {
48
+ result += `- **Authorization URL:** \`${flow.authorizationUrl}\`
49
+ `;
50
+ }
51
+ if (flow.tokenUrl) {
52
+ result += `- **Token URL:** \`${flow.tokenUrl}\`
53
+ `;
54
+ }
55
+ if (flow.refreshUrl) {
56
+ result += `- **Refresh URL:** \`${flow.refreshUrl}\`
57
+ `;
58
+ }
59
+ if (flow.scopes && Object.keys(flow.scopes).length > 0) {
60
+ result += `- **Available Scopes:**
61
+ `;
62
+ for (const [scope, description] of Object.entries(flow.scopes)) {
63
+ result += ` - \`${scope}\`: ${description}
64
+ `;
65
+ }
66
+ }
67
+ result += "\n";
68
+ }
69
+ return result;
70
+ }
71
+ function getFlowDisplayName(flowType) {
72
+ const flowNames = {
73
+ authorizationCode: "Authorization Code Flow",
74
+ implicit: "Implicit Flow",
75
+ password: "Resource Owner Password Flow",
76
+ clientCredentials: "Client Credentials Flow"
77
+ };
78
+ return flowNames[flowType] || flowType;
79
+ }
80
+ function formatSecurityRequirements(requirements) {
81
+ if (!requirements || requirements.length === 0) return "";
82
+ let result = "";
83
+ requirements.forEach((req, index) => {
84
+ const schemes = Object.entries(req);
85
+ if (schemes.length === 0) {
86
+ result += `${index + 1}. No authentication required
87
+ `;
88
+ } else {
89
+ result += `${index + 1}. Requires: `;
90
+ const schemeDescriptions = schemes.map(([scheme, scopes]) => {
91
+ const scopeArray = scopes;
92
+ if (scopeArray && scopeArray.length > 0) {
93
+ return `\`${scheme}\` with scopes: ${scopeArray.map((s) => `\`${s}\``).join(", ")}`;
94
+ }
95
+ return `\`${scheme}\``;
96
+ });
97
+ result += schemeDescriptions.join(" AND ") + "\n";
98
+ }
99
+ });
100
+ return result;
101
+ }
102
+ function generateAuthOverview(spec) {
103
+ let markdown = `# Authorization
104
+
105
+ `;
106
+ const securitySchemes = spec.components?.securitySchemes || {};
107
+ const globalSecurity = spec.security || [];
108
+ if (Object.keys(securitySchemes).length === 0 && globalSecurity.length === 0) {
109
+ markdown += `This API does not require authentication.
110
+
111
+ `;
112
+ } else {
113
+ markdown += `This API provides secure access through various authentication methods. Below you'll find details about each available authentication scheme and how to use them.
114
+
115
+ `;
116
+ if (Object.keys(securitySchemes).length > 0) {
117
+ markdown += `## Available Authentication Methods
118
+
119
+ `;
120
+ for (const [name, scheme] of Object.entries(securitySchemes)) {
121
+ const schemeObj = resolveRef(spec, scheme);
122
+ markdown += `### ${name}
123
+
124
+ `;
125
+ const description = schemeObj.description || getSecuritySchemeDescription(schemeObj);
126
+ markdown += `${description}
127
+
128
+ `;
129
+ if (schemeObj.type === "apiKey") {
130
+ markdown += `**Details:**
131
+ `;
132
+ markdown += `- Parameter Name: \`${schemeObj.name}\`
133
+ `;
134
+ markdown += `- Location: ${schemeObj.in === "header" ? "HTTP Header" : schemeObj.in === "query" ? "Query Parameter" : "Cookie"}
135
+
136
+ `;
137
+ } else if (schemeObj.type === "http") {
138
+ markdown += `**Details:**
139
+ `;
140
+ markdown += `- Scheme: \`${schemeObj.scheme}\`
141
+ `;
142
+ if (schemeObj.bearerFormat) {
143
+ markdown += `- Token Format: \`${schemeObj.bearerFormat}\`
144
+ `;
145
+ }
146
+ markdown += "\n";
147
+ } else if (schemeObj.type === "oauth2" && schemeObj.flows) {
148
+ markdown += `**OAuth 2.0 Flows:**
149
+
150
+ `;
151
+ markdown += formatOAuth2Flows(schemeObj.flows);
152
+ } else if (schemeObj.type === "openIdConnect") {
153
+ markdown += `**Details:**
154
+ `;
155
+ markdown += `- Discovery URL: \`${schemeObj.openIdConnectUrl}\`
156
+
157
+ `;
158
+ }
159
+ }
160
+ }
161
+ }
162
+ return {
163
+ id: "authorization",
164
+ url: "/authorization",
165
+ title: "Authorization",
166
+ description: "Authentication methods and security schemes",
167
+ content: markdown
168
+ };
169
+ }
170
+ export {
171
+ generateAuthOverview
172
+ };
173
+ //# sourceMappingURL=overview-auth.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/overview-docs/overview-auth.ts"],
4
+ "sourcesContent": ["import type { OAuthFlowsObject, SecuritySchemeObject } from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core';\n\nimport type { NavItem } from '../sidebar.js';\nimport type { OurOpenAPIObject } from '../types.js';\n\nfunction getSecuritySchemeDescription(scheme: SecuritySchemeObject): string {\n switch (scheme.type) {\n case 'apiKey': {\n const location =\n scheme.in === 'header'\n ? 'HTTP header'\n : scheme.in === 'query'\n ? 'query parameter'\n : 'cookie';\n return `API Key authentication requires you to provide an API key in the ${location} named \\`${scheme.name}\\`.`;\n }\n case 'http':\n if (scheme.scheme === 'bearer') {\n const format = scheme.bearerFormat\n ? ` The expected token format is \\`${scheme.bearerFormat}\\`.`\n : '';\n return `Bearer token authentication requires you to include a bearer token in the \\`Authorization\\` header of your requests.${format}`;\n }\n if (scheme.scheme === 'basic') {\n return `Basic authentication requires you to provide a username and password, encoded in base64 format in the \\`Authorization\\` header.`;\n }\n return `HTTP ${scheme.scheme} authentication is required for accessing this API.`;\n case 'oauth2': {\n const flows = Object.keys(scheme.flows || {});\n const flowDescriptions = flows.map((flow) => {\n switch (flow) {\n case 'authorizationCode':\n return 'Authorization Code (for server-side applications)';\n case 'implicit':\n return 'Implicit (for browser-based applications)';\n case 'password':\n return 'Resource Owner Password Credentials';\n case 'clientCredentials':\n return 'Client Credentials (for machine-to-machine authentication)';\n default:\n return flow;\n }\n });\n return `OAuth 2.0 authentication is supported with the following grant type(s): ${flowDescriptions.join(', ')}.`;\n }\n case 'openIdConnect':\n return `OpenID Connect authentication is used for this API. You will need to authenticate through the OpenID provider to obtain access tokens.`;\n default:\n return 'This API uses a custom authentication scheme. Please refer to the API documentation for specific details.';\n }\n}\n\nfunction formatOAuth2Flows(flows: OAuthFlowsObject): string {\n let result = '';\n\n for (const [flowType, flow] of Object.entries(flows || {})) {\n result += `#### ${getFlowDisplayName(flowType)}\\n\\n`;\n\n if (flow.authorizationUrl) {\n result += `- **Authorization URL:** \\`${flow.authorizationUrl}\\`\\n`;\n }\n if (flow.tokenUrl) {\n result += `- **Token URL:** \\`${flow.tokenUrl}\\`\\n`;\n }\n if (flow.refreshUrl) {\n result += `- **Refresh URL:** \\`${flow.refreshUrl}\\`\\n`;\n }\n if (flow.scopes && Object.keys(flow.scopes).length > 0) {\n result += `- **Available Scopes:**\\n`;\n for (const [scope, description] of Object.entries(flow.scopes)) {\n result += ` - \\`${scope}\\`: ${description}\\n`;\n }\n }\n result += '\\n';\n }\n\n return result;\n}\n\nfunction getFlowDisplayName(flowType: string): string {\n const flowNames: Record<string, string> = {\n authorizationCode: 'Authorization Code Flow',\n implicit: 'Implicit Flow',\n password: 'Resource Owner Password Flow',\n clientCredentials: 'Client Credentials Flow',\n };\n return flowNames[flowType] || flowType;\n}\n\nfunction formatSecurityRequirements(\n requirements: Array<Record<string, string[]>>,\n): string {\n if (!requirements || requirements.length === 0) return '';\n\n let result = '';\n requirements.forEach((req, index) => {\n const schemes = Object.entries(req);\n if (schemes.length === 0) {\n result += `${index + 1}. No authentication required\\n`;\n } else {\n result += `${index + 1}. Requires: `;\n const schemeDescriptions = schemes.map(([scheme, scopes]) => {\n const scopeArray = scopes as string[];\n if (scopeArray && scopeArray.length > 0) {\n return `\\`${scheme}\\` with scopes: ${scopeArray.map((s) => `\\`${s}\\``).join(', ')}`;\n }\n return `\\`${scheme}\\``;\n });\n result += schemeDescriptions.join(' AND ') + '\\n';\n }\n });\n return result;\n}\n\nexport function generateAuthOverview(spec: OurOpenAPIObject): NavItem {\n let markdown = `# Authorization\\n\\n`;\n\n const securitySchemes = spec.components?.securitySchemes || {};\n const globalSecurity = spec.security || [];\n\n if (\n Object.keys(securitySchemes).length === 0 &&\n globalSecurity.length === 0\n ) {\n markdown += `This API does not require authentication.\\n\\n`;\n } else {\n markdown += `This API provides secure access through various authentication methods. Below you'll find details about each available authentication scheme and how to use them.\\n\\n`;\n\n if (Object.keys(securitySchemes).length > 0) {\n markdown += `## Available Authentication Methods\\n\\n`;\n\n for (const [name, scheme] of Object.entries(securitySchemes)) {\n const schemeObj = resolveRef<SecuritySchemeObject>(spec, scheme);\n markdown += `### ${name}\\n\\n`;\n\n const description =\n schemeObj.description || getSecuritySchemeDescription(schemeObj);\n markdown += `${description}\\n\\n`;\n\n if (schemeObj.type === 'apiKey') {\n markdown += `**Details:**\\n`;\n markdown += `- Parameter Name: \\`${schemeObj.name}\\`\\n`;\n markdown += `- Location: ${schemeObj.in === 'header' ? 'HTTP Header' : schemeObj.in === 'query' ? 'Query Parameter' : 'Cookie'}\\n\\n`;\n } else if (schemeObj.type === 'http') {\n markdown += `**Details:**\\n`;\n markdown += `- Scheme: \\`${schemeObj.scheme}\\`\\n`;\n if (schemeObj.bearerFormat) {\n markdown += `- Token Format: \\`${schemeObj.bearerFormat}\\`\\n`;\n }\n markdown += '\\n';\n } else if (schemeObj.type === 'oauth2' && schemeObj.flows) {\n markdown += `**OAuth 2.0 Flows:**\\n\\n`;\n markdown += formatOAuth2Flows(schemeObj.flows);\n } else if (schemeObj.type === 'openIdConnect') {\n markdown += `**Details:**\\n`;\n markdown += `- Discovery URL: \\`${schemeObj.openIdConnectUrl}\\`\\n\\n`;\n }\n }\n }\n }\n\n return {\n id: 'authorization',\n url: '/authorization',\n title: 'Authorization',\n description: 'Authentication methods and security schemes',\n content: markdown,\n };\n}\n"],
5
+ "mappings": "AAEA,SAAS,kBAAkB;AAK3B,SAAS,6BAA6B,QAAsC;AAC1E,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK,UAAU;AACb,YAAM,WACJ,OAAO,OAAO,WACV,gBACA,OAAO,OAAO,UACZ,oBACA;AACR,aAAO,oEAAoE,QAAQ,YAAY,OAAO,IAAI;AAAA,IAC5G;AAAA,IACA,KAAK;AACH,UAAI,OAAO,WAAW,UAAU;AAC9B,cAAM,SAAS,OAAO,eAClB,mCAAmC,OAAO,YAAY,QACtD;AACJ,eAAO,uHAAuH,MAAM;AAAA,MACtI;AACA,UAAI,OAAO,WAAW,SAAS;AAC7B,eAAO;AAAA,MACT;AACA,aAAO,QAAQ,OAAO,MAAM;AAAA,IAC9B,KAAK,UAAU;AACb,YAAM,QAAQ,OAAO,KAAK,OAAO,SAAS,CAAC,CAAC;AAC5C,YAAM,mBAAmB,MAAM,IAAI,CAAC,SAAS;AAC3C,gBAAQ,MAAM;AAAA,UACZ,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT,KAAK;AACH,mBAAO;AAAA,UACT;AACE,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AAY,eAAe,UAAU,MAAM;AAAA;AAC3C,cAAI,UAAU,cAAc;AAC1B,wBAAY,qBAAqB,UAAU,YAAY;AAAA;AAAA,UACzD;AACA,sBAAY;AAAA,QACd,WAAW,UAAU,SAAS,YAAY,UAAU,OAAO;AACzD,sBAAY;AAAA;AAAA;AACZ,sBAAY,kBAAkB,UAAU,KAAK;AAAA,QAC/C,WAAW,UAAU,SAAS,iBAAiB;AAC7C,sBAAY;AAAA;AACZ,sBAAY,sBAAsB,UAAU,gBAAgB;AAAA;AAAA;AAAA,QAC9D;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { SidebarData } from '../sidebar.js';
2
+ import type { OurOpenAPIObject } from '../types.js';
3
+ export declare function extractOverviewDocs(spec: OurOpenAPIObject, availableSdks?: string[]): SidebarData;
4
+ //# sourceMappingURL=overview-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overview-docs.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKpD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,gBAAgB,EACtB,aAAa,GAAE,MAAM,EAAmB,GACvC,WAAW,CAYb"}
@@ -0,0 +1,20 @@
1
+ import { generateAuthOverview } from "./overview-auth.js";
2
+ import { generateErrorsOverview } from "./overview-errors.js";
3
+ import { generateIntroOverview } from "./overview-intro.js";
4
+ function extractOverviewDocs(spec, availableSdks = ["typescript"]) {
5
+ return [
6
+ {
7
+ id: "overview",
8
+ category: "Overview",
9
+ items: [
10
+ generateIntroOverview(spec, availableSdks),
11
+ generateAuthOverview(spec),
12
+ generateErrorsOverview(spec)
13
+ ]
14
+ }
15
+ ];
16
+ }
17
+ export {
18
+ extractOverviewDocs
19
+ };
20
+ //# sourceMappingURL=overview-docs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/overview-docs/overview-docs.ts"],
4
+ "sourcesContent": ["import type { SidebarData } from '../sidebar.js';\nimport type { OurOpenAPIObject } from '../types.js';\nimport { generateAuthOverview } from './overview-auth.js';\nimport { generateErrorsOverview } from './overview-errors.js';\nimport { generateIntroOverview } from './overview-intro.js';\n\nexport function extractOverviewDocs(\n spec: OurOpenAPIObject,\n availableSdks: string[] = ['typescript'],\n): SidebarData {\n return [\n {\n id: 'overview',\n category: 'Overview',\n items: [\n generateIntroOverview(spec, availableSdks),\n generateAuthOverview(spec),\n generateErrorsOverview(spec),\n ],\n },\n ];\n}\n"],
5
+ "mappings": "AAEA,SAAS,4BAA4B;AACrC,SAAS,8BAA8B;AACvC,SAAS,6BAA6B;AAE/B,SAAS,oBACd,MACA,gBAA0B,CAAC,YAAY,GAC1B;AACb,SAAO;AAAA,IACL;AAAA,MACE,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,OAAO;AAAA,QACL,sBAAsB,MAAM,aAAa;AAAA,QACzC,qBAAqB,IAAI;AAAA,QACzB,uBAAuB,IAAI;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { NavItem } from '../sidebar.js';
2
+ import type { OurOpenAPIObject } from '../types.js';
3
+ export declare function generateErrorsOverview(spec: OurOpenAPIObject): NavItem;
4
+ //# sourceMappingURL=overview-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overview-errors.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-errors.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA6GpD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAyFtE"}
@@ -0,0 +1,137 @@
1
+ import { resolveRef } from "@sdk-it/core";
2
+ import { forEachOperation } from "../for-each-operation.js";
3
+ import { isErrorStatusCode } from "../is.js";
4
+ function resolveSchema(spec, schema) {
5
+ return resolveRef(spec, schema);
6
+ }
7
+ function formatSchemaForDisplay(spec, schema) {
8
+ const resolvedSchema = resolveSchema(spec, schema);
9
+ return `\`\`\`json
10
+ ${JSON.stringify(resolvedSchema, null, 2)}
11
+ \`\`\``;
12
+ }
13
+ function getStatusDescription(statusCode) {
14
+ const descriptions = {
15
+ "400": "Bad Request - The request was invalid or cannot be served.",
16
+ "401": "Unauthorized - Authentication is required and has failed or has not been provided.",
17
+ "402": "Payment Required - Payment is required to access this resource.",
18
+ "403": "Forbidden - The request was valid, but the server is refusing action.",
19
+ "404": "Not Found - The requested resource could not be found.",
20
+ "405": "Method Not Allowed - The request method is not supported for this resource.",
21
+ "406": "Not Acceptable - The requested resource cannot generate content acceptable to the client.",
22
+ "407": "Proxy Authentication Required - Authentication with the proxy is required.",
23
+ "408": "Request Timeout - The server timed out waiting for the request.",
24
+ "409": "Conflict - The request could not be completed due to a conflict.",
25
+ "410": "Gone - The requested resource is no longer available.",
26
+ "411": "Length Required - The request did not specify the length of its content.",
27
+ "412": "Precondition Failed - The server does not meet one of the preconditions.",
28
+ "413": "Payload Too Large - The request is larger than the server is willing to process.",
29
+ "414": "URI Too Long - The URI provided was too long for the server to process.",
30
+ "415": "Unsupported Media Type - The request entity has a media type which the server does not support.",
31
+ "416": "Range Not Satisfiable - The client has asked for a portion of the file that the server cannot supply.",
32
+ "417": "Expectation Failed - The server cannot meet the requirements of the Expect request-header field.",
33
+ "418": "I'm a teapot - The server refuses the attempt to brew coffee with a teapot.",
34
+ "421": "Misdirected Request - The request was directed at a server that is not able to produce a response.",
35
+ "422": "Unprocessable Entity - The request was well-formed but contains semantic errors.",
36
+ "423": "Locked - The resource that is being accessed is locked.",
37
+ "424": "Failed Dependency - The request failed due to failure of a previous request.",
38
+ "425": "Too Early - The server is unwilling to risk processing a request that might be replayed.",
39
+ "426": "Upgrade Required - The client should switch to a different protocol.",
40
+ "428": "Precondition Required - The origin server requires the request to be conditional.",
41
+ "429": "Too Many Requests - The user has sent too many requests in a given amount of time.",
42
+ "431": "Request Header Fields Too Large - The server is unwilling to process the request because header fields are too large.",
43
+ "451": "Unavailable For Legal Reasons - The server is denying access to the resource for legal reasons.",
44
+ "500": "Internal Server Error - The server encountered an unexpected condition.",
45
+ "501": "Not Implemented - The server does not support the functionality required to fulfill the request.",
46
+ "502": "Bad Gateway - The server received an invalid response from the upstream server.",
47
+ "503": "Service Unavailable - The server is currently unavailable.",
48
+ "504": "Gateway Timeout - The server did not receive a timely response from the upstream server.",
49
+ "505": "HTTP Version Not Supported - The server does not support the HTTP protocol version used in the request.",
50
+ "506": "Variant Also Negotiates - The server has an internal configuration error.",
51
+ "507": "Insufficient Storage - The server is unable to store the representation needed to complete the request.",
52
+ "508": "Loop Detected - The server detected an infinite loop while processing the request.",
53
+ "510": "Not Extended - Further extensions to the request are required for the server to fulfill it.",
54
+ "511": "Network Authentication Required - The client needs to authenticate to gain network access."
55
+ };
56
+ return descriptions[statusCode] || "An error occurred while processing the request.";
57
+ }
58
+ function generateErrorsOverview(spec) {
59
+ const errorSchemas = /* @__PURE__ */ new Map();
60
+ const markdown = [];
61
+ markdown.push(`# Error Handling`);
62
+ markdown.push(
63
+ `This API uses conventional HTTP response codes to indicate the success or failure of an API request.`
64
+ );
65
+ markdown.push(`## Official API Clients`);
66
+ markdown.push(
67
+ `Vellum maintains official API clients for Python, Node/Typescript, and Go. We recommend using these clients to interact with all stable endpoints. You can find them here:`
68
+ );
69
+ markdown.push(`## HTTP Status Codes`);
70
+ forEachOperation(spec, (entry, operation) => {
71
+ if (operation.responses) {
72
+ for (const [statusCode, response] of Object.entries(
73
+ operation.responses
74
+ )) {
75
+ if (isErrorStatusCode(statusCode)) {
76
+ const content = response.content;
77
+ if (content?.["application/json"]?.schema) {
78
+ const key = `${statusCode}`;
79
+ const operationId = `${entry.method.toUpperCase()} ${entry.path}`;
80
+ if (!errorSchemas.has(key)) {
81
+ errorSchemas.set(key, {
82
+ statusCode,
83
+ title: response.description || `${statusCode} Error`,
84
+ description: response.description,
85
+ schema: content["application/json"].schema,
86
+ operations: [operationId]
87
+ });
88
+ } else {
89
+ const existing = errorSchemas.get(key);
90
+ if (existing && !existing.operations.includes(operationId)) {
91
+ existing.operations.push(operationId);
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ });
99
+ const errors = Array.from(errorSchemas.values()).sort(
100
+ (a, b) => parseInt(a.statusCode) - parseInt(b.statusCode)
101
+ );
102
+ if (errors.length === 0) {
103
+ markdown.push(
104
+ `No error responses are documented in this API specification.`
105
+ );
106
+ } else {
107
+ for (const error of errors) {
108
+ markdown.push(`### ${error.statusCode} - ${error.title}`);
109
+ const description = error.description || getStatusDescription(error.statusCode);
110
+ if (description) {
111
+ markdown.push(description);
112
+ }
113
+ if (error.operations.length > 0) {
114
+ const operationsList = [`**Used by operations:**`];
115
+ for (const operation of error.operations) {
116
+ operationsList.push(`- \`${operation}\``);
117
+ }
118
+ markdown.push(operationsList.join("\n"));
119
+ }
120
+ if (error.schema) {
121
+ markdown.push(`**Response Schema:**`);
122
+ markdown.push(formatSchemaForDisplay(spec, error.schema));
123
+ }
124
+ }
125
+ }
126
+ return {
127
+ id: "errors",
128
+ title: "Errors",
129
+ url: "/errors",
130
+ description: "Error handling and HTTP status codes",
131
+ content: markdown.join("\n\n")
132
+ };
133
+ }
134
+ export {
135
+ generateErrorsOverview
136
+ };
137
+ //# sourceMappingURL=overview-errors.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/overview-docs/overview-errors.ts"],
4
+ "sourcesContent": ["import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';\n\nimport { resolveRef } from '@sdk-it/core';\n\nimport { forEachOperation } from '../for-each-operation.js';\nimport { isErrorStatusCode } from '../is.js';\nimport type { NavItem } from '../sidebar.js';\nimport type { OurOpenAPIObject } from '../types.js';\n\ninterface ErrorSchema {\n statusCode: string;\n title: string;\n description?: string;\n schema: SchemaObject | ReferenceObject;\n operations: string[]; // Track which operations use this error\n}\n\nfunction resolveSchema(\n spec: OurOpenAPIObject,\n schema: SchemaObject | ReferenceObject,\n): SchemaObject {\n return resolveRef<SchemaObject>(spec, schema);\n}\n\nfunction formatSchemaForDisplay(\n spec: OurOpenAPIObject,\n schema: SchemaObject | ReferenceObject,\n): string {\n const resolvedSchema = resolveSchema(spec, schema);\n\n return `\\`\\`\\`json\n${JSON.stringify(resolvedSchema, null, 2)}\n\\`\\`\\``;\n}\n\nfunction getStatusDescription(statusCode: string): string {\n const descriptions: Record<string, string> = {\n '400': 'Bad Request - The request was invalid or cannot be served.',\n '401':\n 'Unauthorized - Authentication is required and has failed or has not been provided.',\n '402': 'Payment Required - Payment is required to access this resource.',\n '403':\n 'Forbidden - The request was valid, but the server is refusing action.',\n '404': 'Not Found - The requested resource could not be found.',\n '405':\n 'Method Not Allowed - The request method is not supported for this resource.',\n '406':\n 'Not Acceptable - The requested resource cannot generate content acceptable to the client.',\n '407':\n 'Proxy Authentication Required - Authentication with the proxy is required.',\n '408': 'Request Timeout - The server timed out waiting for the request.',\n '409': 'Conflict - The request could not be completed due to a conflict.',\n '410': 'Gone - The requested resource is no longer available.',\n '411':\n 'Length Required - The request did not specify the length of its content.',\n '412':\n 'Precondition Failed - The server does not meet one of the preconditions.',\n '413':\n 'Payload Too Large - The request is larger than the server is willing to process.',\n '414':\n 'URI Too Long - The URI provided was too long for the server to process.',\n '415':\n 'Unsupported Media Type - The request entity has a media type which the server does not support.',\n '416':\n 'Range Not Satisfiable - The client has asked for a portion of the file that the server cannot supply.',\n '417':\n 'Expectation Failed - The server cannot meet the requirements of the Expect request-header field.',\n '418':\n \"I'm a teapot - The server refuses the attempt to brew coffee with a teapot.\",\n '421':\n 'Misdirected Request - The request was directed at a server that is not able to produce a response.',\n '422':\n 'Unprocessable Entity - The request was well-formed but contains semantic errors.',\n '423': 'Locked - The resource that is being accessed is locked.',\n '424':\n 'Failed Dependency - The request failed due to failure of a previous request.',\n '425':\n 'Too Early - The server is unwilling to risk processing a request that might be replayed.',\n '426':\n 'Upgrade Required - The client should switch to a different protocol.',\n '428':\n 'Precondition Required - The origin server requires the request to be conditional.',\n '429':\n 'Too Many Requests - The user has sent too many requests in a given amount of time.',\n '431':\n 'Request Header Fields Too Large - The server is unwilling to process the request because header fields are too large.',\n '451':\n 'Unavailable For Legal Reasons - The server is denying access to the resource for legal reasons.',\n '500':\n 'Internal Server Error - The server encountered an unexpected condition.',\n '501':\n 'Not Implemented - The server does not support the functionality required to fulfill the request.',\n '502':\n 'Bad Gateway - The server received an invalid response from the upstream server.',\n '503': 'Service Unavailable - The server is currently unavailable.',\n '504':\n 'Gateway Timeout - The server did not receive a timely response from the upstream server.',\n '505':\n 'HTTP Version Not Supported - The server does not support the HTTP protocol version used in the request.',\n '506':\n 'Variant Also Negotiates - The server has an internal configuration error.',\n '507':\n 'Insufficient Storage - The server is unable to store the representation needed to complete the request.',\n '508':\n 'Loop Detected - The server detected an infinite loop while processing the request.',\n '510':\n 'Not Extended - Further extensions to the request are required for the server to fulfill it.',\n '511':\n 'Network Authentication Required - The client needs to authenticate to gain network access.',\n };\n return (\n descriptions[statusCode] ||\n 'An error occurred while processing the request.'\n );\n}\n\nexport function generateErrorsOverview(spec: OurOpenAPIObject): NavItem {\n const errorSchemas: Map<string, ErrorSchema> = new Map();\n const markdown: string[] = [];\n markdown.push(`# Error Handling`);\n markdown.push(\n `This API uses conventional HTTP response codes to indicate the success or failure of an API request.`,\n );\n markdown.push(`## Official API Clients`);\n markdown.push(\n `Vellum maintains official API clients for Python, Node/Typescript, and Go. We recommend using these clients to interact with all stable endpoints. You can find them here:`,\n );\n markdown.push(`## HTTP Status Codes`);\n\n // First, collect all error schemas from operations\n forEachOperation(spec, (entry, operation) => {\n if (operation.responses) {\n for (const [statusCode, response] of Object.entries(\n operation.responses,\n )) {\n if (isErrorStatusCode(statusCode)) {\n const content = response.content;\n if (content?.['application/json']?.schema) {\n const key = `${statusCode}`;\n const operationId = `${entry.method.toUpperCase()} ${entry.path}`;\n\n if (!errorSchemas.has(key)) {\n errorSchemas.set(key, {\n statusCode,\n title: response.description || `${statusCode} Error`,\n description: response.description,\n schema: content['application/json'].schema as\n | SchemaObject\n | ReferenceObject,\n operations: [operationId],\n });\n } else {\n // Add this operation to the existing error schema\n const existing = errorSchemas.get(key);\n if (existing && !existing.operations.includes(operationId)) {\n existing.operations.push(operationId);\n }\n }\n }\n }\n }\n }\n });\n\n // Then sort and generate documentation\n const errors = Array.from(errorSchemas.values()).sort(\n (a, b) => parseInt(a.statusCode) - parseInt(b.statusCode),\n );\n\n if (errors.length === 0) {\n markdown.push(\n `No error responses are documented in this API specification.`,\n );\n } else {\n for (const error of errors) {\n markdown.push(`### ${error.statusCode} - ${error.title}`);\n const description =\n error.description || getStatusDescription(error.statusCode);\n if (description) {\n markdown.push(description);\n }\n\n // Show which operations return this error\n if (error.operations.length > 0) {\n const operationsList = [`**Used by operations:**`];\n for (const operation of error.operations) {\n operationsList.push(`- \\`${operation}\\``);\n }\n markdown.push(operationsList.join('\\n'));\n }\n\n if (error.schema) {\n markdown.push(`**Response Schema:**`);\n markdown.push(formatSchemaForDisplay(spec, error.schema));\n }\n }\n }\n\n return {\n id: 'errors',\n title: 'Errors',\n url: '/errors',\n description: 'Error handling and HTTP status codes',\n content: markdown.join('\\n\\n'),\n };\n}\n"],
5
+ "mappings": "AAEA,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAYlC,SAAS,cACP,MACA,QACc;AACd,SAAO,WAAyB,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Ae,KAAK,OAAO,SAAS,IAAI;AAAA,QAC1C;AACA,iBAAS,KAAK,eAAe,KAAK,IAAI,CAAC;AAAA,MACzC;AAEA,UAAI,MAAM,QAAQ;AAChB,iBAAS,KAAK,sBAAsB;AACpC,iBAAS,KAAK,uBAAuB,MAAM,MAAM,MAAM,CAAC;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,KAAK;AAAA,IACL,aAAa;AAAA,IACb,SAAS,SAAS,KAAK,MAAM;AAAA,EAC/B;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { NavItem } from '../sidebar.js';
2
+ import type { OurOpenAPIObject } from '../types.js';
3
+ export declare function generateIntroOverview(spec: OurOpenAPIObject, availablesdks?: string[]): NavItem;
4
+ //# sourceMappingURL=overview-intro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overview-intro.d.ts","sourceRoot":"","sources":["../../../src/lib/overview-docs/overview-intro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,gBAAgB,EACtB,aAAa,WAAiB,GAC7B,OAAO,CAgFT"}