@omnigraph/openapi 0.109.10 → 0.109.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.futureLinks = void 0;
|
|
3
4
|
exports.getJSONSchemaOptionsFromOpenAPIOptions = getJSONSchemaOptionsFromOpenAPIOptions;
|
|
5
|
+
exports.getJSONSchemaOptionsFromMultipleOpenAPIOptions = getJSONSchemaOptionsFromMultipleOpenAPIOptions;
|
|
4
6
|
const graphql_1 = require("graphql");
|
|
5
7
|
const json_machete_1 = require("json-machete");
|
|
6
8
|
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
@@ -15,8 +17,12 @@ const defaultHateoasConfig = {
|
|
|
15
17
|
linkObjectIdentifier: '_links',
|
|
16
18
|
linkObjectExtensionIdentifier: 'x-links',
|
|
17
19
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
// Global fallback for backward compatibility - exported for testing
|
|
21
|
+
exports.futureLinks = new Set();
|
|
22
|
+
async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fallbackFormat, cwd, fetch: fetchFn, endpoint, schemaHeaders, operationHeaders, queryParams = {}, selectQueryOrMutationField = [], logger = new utils_1.DefaultLogger('getJSONSchemaOptionsFromOpenAPIOptions'), jsonApi, HATEOAS, }, hateoasContext) {
|
|
23
|
+
// Use provided context or create/use global fallback
|
|
24
|
+
const contextFutureLinks = hateoasContext?.futureLinks || exports.futureLinks;
|
|
25
|
+
const loadedSchemas = hateoasContext?.loadedSchemas || new Map();
|
|
20
26
|
const hateOasConfig = HATEOAS === true
|
|
21
27
|
? defaultHateoasConfig
|
|
22
28
|
: HATEOAS === false
|
|
@@ -118,9 +124,18 @@ async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fallbackFo
|
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
const methodObjFieldMap = new WeakMap();
|
|
121
|
-
|
|
127
|
+
// Try to resolve any pending future links with currently loaded schemas
|
|
128
|
+
for (const [schemaName, schemaData] of loadedSchemas) {
|
|
129
|
+
for (const futureLink of Array.from(contextFutureLinks)) {
|
|
130
|
+
if (futureLink(schemaName, schemaData.oasDoc, schemaData.methodObjFieldMap)) {
|
|
131
|
+
contextFutureLinks.delete(futureLink);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Try to resolve future links with current schema
|
|
136
|
+
for (const futureLink of Array.from(contextFutureLinks)) {
|
|
122
137
|
if (futureLink(name, oasOrSwagger, methodObjFieldMap)) {
|
|
123
|
-
|
|
138
|
+
contextFutureLinks.delete(futureLink);
|
|
124
139
|
}
|
|
125
140
|
}
|
|
126
141
|
for (const relativePath in oasOrSwagger.paths) {
|
|
@@ -445,16 +460,19 @@ async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fallbackFo
|
|
|
445
460
|
const xLinkObj = schemaObj.properties?.[hateOasConfig.linkObjectIdentifier]?.[hateOasConfig.linkObjectExtensionIdentifier]?.find(link => link[hateOasConfig.linkNameIdentifier] === linkName);
|
|
446
461
|
if (xLinkObj) {
|
|
447
462
|
const xLinkHref = xLinkObj[hateOasConfig.linkPathIdentifier];
|
|
448
|
-
|
|
463
|
+
// Remove query parameters and path parameters for comparison
|
|
464
|
+
const cleanXLinkHref = xLinkHref.split('?')[0].replace(/{[^}]+}/g, '{}');
|
|
449
465
|
const deferred = (0, utils_2.createDeferred)();
|
|
450
466
|
function findActualOperationAndPath(possibleName, possibleOasDoc, possibleMethodObjFieldMap) {
|
|
451
467
|
let actualOperation;
|
|
452
468
|
let actualPath;
|
|
453
469
|
for (const path in possibleOasDoc.paths) {
|
|
454
|
-
const cleanPath = path.replace(/{[^}]+}/g, '{}');
|
|
470
|
+
const cleanPath = path.split('?')[0].replace(/{[^}]+}/g, '{}');
|
|
455
471
|
if (cleanPath === cleanXLinkHref) {
|
|
456
472
|
actualPath = path;
|
|
457
|
-
|
|
473
|
+
// Find the operation by looking for GET method or first available method
|
|
474
|
+
const pathObj = possibleOasDoc.paths[path];
|
|
475
|
+
actualOperation = pathObj.get || pathObj[Object.keys(pathObj)[0]];
|
|
458
476
|
break;
|
|
459
477
|
}
|
|
460
478
|
}
|
|
@@ -529,19 +547,26 @@ async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fallbackFo
|
|
|
529
547
|
}
|
|
530
548
|
}
|
|
531
549
|
}
|
|
532
|
-
|
|
550
|
+
contextFutureLinks.delete(findActualOperationAndPath);
|
|
533
551
|
deferred.resolve();
|
|
534
552
|
return true;
|
|
535
553
|
}
|
|
536
554
|
return false;
|
|
537
555
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
556
|
+
// Only set timeout if we're not in batch mode (no context provided)
|
|
557
|
+
if (!hateoasContext) {
|
|
558
|
+
setTimeout(() => {
|
|
559
|
+
logger.warn(`Could not find operation for link ${linkName} in ${name} for ${xLinkHref}`);
|
|
560
|
+
contextFutureLinks.delete(findActualOperationAndPath);
|
|
561
|
+
deferred.resolve();
|
|
562
|
+
}, 5000);
|
|
563
|
+
}
|
|
543
564
|
if (!findActualOperationAndPath(name, oasOrSwagger, methodObjFieldMap)) {
|
|
544
|
-
|
|
565
|
+
contextFutureLinks.add(findActualOperationAndPath);
|
|
566
|
+
}
|
|
567
|
+
// In batch mode, resolve immediately since we'll handle resolution later
|
|
568
|
+
if (hateoasContext) {
|
|
569
|
+
deferred.resolve();
|
|
545
570
|
}
|
|
546
571
|
return deferred.promise;
|
|
547
572
|
}
|
|
@@ -664,6 +689,13 @@ async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fallbackFo
|
|
|
664
689
|
}
|
|
665
690
|
}
|
|
666
691
|
}
|
|
692
|
+
// Register this schema in the context for future cross-references
|
|
693
|
+
if (hateoasContext) {
|
|
694
|
+
loadedSchemas.set(name, {
|
|
695
|
+
oasDoc: oasOrSwagger,
|
|
696
|
+
methodObjFieldMap,
|
|
697
|
+
});
|
|
698
|
+
}
|
|
667
699
|
return {
|
|
668
700
|
operations,
|
|
669
701
|
endpoint,
|
|
@@ -673,3 +705,44 @@ async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fallbackFo
|
|
|
673
705
|
operationHeaders,
|
|
674
706
|
};
|
|
675
707
|
}
|
|
708
|
+
/**
|
|
709
|
+
* Loads multiple OpenAPI schemas with proper HATEOAS cross-reference resolution.
|
|
710
|
+
* This function ensures that schemas referencing operations from other schemas
|
|
711
|
+
* are resolved correctly regardless of loading order.
|
|
712
|
+
*/
|
|
713
|
+
async function getJSONSchemaOptionsFromMultipleOpenAPIOptions(schemas) {
|
|
714
|
+
// Create shared context for cross-schema HATEOAS resolution
|
|
715
|
+
const hateoasContext = {
|
|
716
|
+
futureLinks: new Set(),
|
|
717
|
+
loadedSchemas: new Map(),
|
|
718
|
+
};
|
|
719
|
+
const results = [];
|
|
720
|
+
// First pass: Load all schemas
|
|
721
|
+
for (const { name, options } of schemas) {
|
|
722
|
+
const result = await getJSONSchemaOptionsFromOpenAPIOptions(name, options, hateoasContext);
|
|
723
|
+
results.push({ name, result });
|
|
724
|
+
}
|
|
725
|
+
// Second pass: Attempt to resolve any remaining future links
|
|
726
|
+
let maxAttempts = schemas.length * 2; // Prevent infinite loops
|
|
727
|
+
while (hateoasContext.futureLinks.size > 0 && maxAttempts > 0) {
|
|
728
|
+
const initialSize = hateoasContext.futureLinks.size;
|
|
729
|
+
for (const [schemaName, schemaData] of hateoasContext.loadedSchemas) {
|
|
730
|
+
for (const futureLink of Array.from(hateoasContext.futureLinks)) {
|
|
731
|
+
if (futureLink(schemaName, schemaData.oasDoc, schemaData.methodObjFieldMap)) {
|
|
732
|
+
hateoasContext.futureLinks.delete(futureLink);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
// If no progress was made, break to avoid infinite loop
|
|
737
|
+
if (hateoasContext.futureLinks.size === initialSize) {
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
maxAttempts--;
|
|
741
|
+
}
|
|
742
|
+
// Log remaining unresolved links
|
|
743
|
+
if (hateoasContext.futureLinks.size > 0) {
|
|
744
|
+
const logger = new utils_1.DefaultLogger('getJSONSchemaOptionsFromMultipleOpenAPIOptions');
|
|
745
|
+
logger.warn(`${hateoasContext.futureLinks.size} HATEOAS links could not be resolved after loading all schemas. This may indicate missing operations or circular dependencies.`);
|
|
746
|
+
}
|
|
747
|
+
return results;
|
|
748
|
+
}
|
|
@@ -12,8 +12,12 @@ const defaultHateoasConfig = {
|
|
|
12
12
|
linkObjectIdentifier: '_links',
|
|
13
13
|
linkObjectExtensionIdentifier: 'x-links',
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
export
|
|
15
|
+
// Global fallback for backward compatibility - exported for testing
|
|
16
|
+
export const futureLinks = new Set();
|
|
17
|
+
export async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fallbackFormat, cwd, fetch: fetchFn, endpoint, schemaHeaders, operationHeaders, queryParams = {}, selectQueryOrMutationField = [], logger = new DefaultLogger('getJSONSchemaOptionsFromOpenAPIOptions'), jsonApi, HATEOAS, }, hateoasContext) {
|
|
18
|
+
// Use provided context or create/use global fallback
|
|
19
|
+
const contextFutureLinks = hateoasContext?.futureLinks || futureLinks;
|
|
20
|
+
const loadedSchemas = hateoasContext?.loadedSchemas || new Map();
|
|
17
21
|
const hateOasConfig = HATEOAS === true
|
|
18
22
|
? defaultHateoasConfig
|
|
19
23
|
: HATEOAS === false
|
|
@@ -115,9 +119,18 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fal
|
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
const methodObjFieldMap = new WeakMap();
|
|
118
|
-
|
|
122
|
+
// Try to resolve any pending future links with currently loaded schemas
|
|
123
|
+
for (const [schemaName, schemaData] of loadedSchemas) {
|
|
124
|
+
for (const futureLink of Array.from(contextFutureLinks)) {
|
|
125
|
+
if (futureLink(schemaName, schemaData.oasDoc, schemaData.methodObjFieldMap)) {
|
|
126
|
+
contextFutureLinks.delete(futureLink);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Try to resolve future links with current schema
|
|
131
|
+
for (const futureLink of Array.from(contextFutureLinks)) {
|
|
119
132
|
if (futureLink(name, oasOrSwagger, methodObjFieldMap)) {
|
|
120
|
-
|
|
133
|
+
contextFutureLinks.delete(futureLink);
|
|
121
134
|
}
|
|
122
135
|
}
|
|
123
136
|
for (const relativePath in oasOrSwagger.paths) {
|
|
@@ -442,16 +455,19 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fal
|
|
|
442
455
|
const xLinkObj = schemaObj.properties?.[hateOasConfig.linkObjectIdentifier]?.[hateOasConfig.linkObjectExtensionIdentifier]?.find(link => link[hateOasConfig.linkNameIdentifier] === linkName);
|
|
443
456
|
if (xLinkObj) {
|
|
444
457
|
const xLinkHref = xLinkObj[hateOasConfig.linkPathIdentifier];
|
|
445
|
-
|
|
458
|
+
// Remove query parameters and path parameters for comparison
|
|
459
|
+
const cleanXLinkHref = xLinkHref.split('?')[0].replace(/{[^}]+}/g, '{}');
|
|
446
460
|
const deferred = createDeferred();
|
|
447
461
|
function findActualOperationAndPath(possibleName, possibleOasDoc, possibleMethodObjFieldMap) {
|
|
448
462
|
let actualOperation;
|
|
449
463
|
let actualPath;
|
|
450
464
|
for (const path in possibleOasDoc.paths) {
|
|
451
|
-
const cleanPath = path.replace(/{[^}]+}/g, '{}');
|
|
465
|
+
const cleanPath = path.split('?')[0].replace(/{[^}]+}/g, '{}');
|
|
452
466
|
if (cleanPath === cleanXLinkHref) {
|
|
453
467
|
actualPath = path;
|
|
454
|
-
|
|
468
|
+
// Find the operation by looking for GET method or first available method
|
|
469
|
+
const pathObj = possibleOasDoc.paths[path];
|
|
470
|
+
actualOperation = pathObj.get || pathObj[Object.keys(pathObj)[0]];
|
|
455
471
|
break;
|
|
456
472
|
}
|
|
457
473
|
}
|
|
@@ -526,19 +542,26 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fal
|
|
|
526
542
|
}
|
|
527
543
|
}
|
|
528
544
|
}
|
|
529
|
-
|
|
545
|
+
contextFutureLinks.delete(findActualOperationAndPath);
|
|
530
546
|
deferred.resolve();
|
|
531
547
|
return true;
|
|
532
548
|
}
|
|
533
549
|
return false;
|
|
534
550
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
551
|
+
// Only set timeout if we're not in batch mode (no context provided)
|
|
552
|
+
if (!hateoasContext) {
|
|
553
|
+
setTimeout(() => {
|
|
554
|
+
logger.warn(`Could not find operation for link ${linkName} in ${name} for ${xLinkHref}`);
|
|
555
|
+
contextFutureLinks.delete(findActualOperationAndPath);
|
|
556
|
+
deferred.resolve();
|
|
557
|
+
}, 5000);
|
|
558
|
+
}
|
|
540
559
|
if (!findActualOperationAndPath(name, oasOrSwagger, methodObjFieldMap)) {
|
|
541
|
-
|
|
560
|
+
contextFutureLinks.add(findActualOperationAndPath);
|
|
561
|
+
}
|
|
562
|
+
// In batch mode, resolve immediately since we'll handle resolution later
|
|
563
|
+
if (hateoasContext) {
|
|
564
|
+
deferred.resolve();
|
|
542
565
|
}
|
|
543
566
|
return deferred.promise;
|
|
544
567
|
}
|
|
@@ -661,6 +684,13 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fal
|
|
|
661
684
|
}
|
|
662
685
|
}
|
|
663
686
|
}
|
|
687
|
+
// Register this schema in the context for future cross-references
|
|
688
|
+
if (hateoasContext) {
|
|
689
|
+
loadedSchemas.set(name, {
|
|
690
|
+
oasDoc: oasOrSwagger,
|
|
691
|
+
methodObjFieldMap,
|
|
692
|
+
});
|
|
693
|
+
}
|
|
664
694
|
return {
|
|
665
695
|
operations,
|
|
666
696
|
endpoint,
|
|
@@ -670,3 +700,44 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions(name, { source, fal
|
|
|
670
700
|
operationHeaders,
|
|
671
701
|
};
|
|
672
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Loads multiple OpenAPI schemas with proper HATEOAS cross-reference resolution.
|
|
705
|
+
* This function ensures that schemas referencing operations from other schemas
|
|
706
|
+
* are resolved correctly regardless of loading order.
|
|
707
|
+
*/
|
|
708
|
+
export async function getJSONSchemaOptionsFromMultipleOpenAPIOptions(schemas) {
|
|
709
|
+
// Create shared context for cross-schema HATEOAS resolution
|
|
710
|
+
const hateoasContext = {
|
|
711
|
+
futureLinks: new Set(),
|
|
712
|
+
loadedSchemas: new Map(),
|
|
713
|
+
};
|
|
714
|
+
const results = [];
|
|
715
|
+
// First pass: Load all schemas
|
|
716
|
+
for (const { name, options } of schemas) {
|
|
717
|
+
const result = await getJSONSchemaOptionsFromOpenAPIOptions(name, options, hateoasContext);
|
|
718
|
+
results.push({ name, result });
|
|
719
|
+
}
|
|
720
|
+
// Second pass: Attempt to resolve any remaining future links
|
|
721
|
+
let maxAttempts = schemas.length * 2; // Prevent infinite loops
|
|
722
|
+
while (hateoasContext.futureLinks.size > 0 && maxAttempts > 0) {
|
|
723
|
+
const initialSize = hateoasContext.futureLinks.size;
|
|
724
|
+
for (const [schemaName, schemaData] of hateoasContext.loadedSchemas) {
|
|
725
|
+
for (const futureLink of Array.from(hateoasContext.futureLinks)) {
|
|
726
|
+
if (futureLink(schemaName, schemaData.oasDoc, schemaData.methodObjFieldMap)) {
|
|
727
|
+
hateoasContext.futureLinks.delete(futureLink);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
// If no progress was made, break to avoid infinite loop
|
|
732
|
+
if (hateoasContext.futureLinks.size === initialSize) {
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
maxAttempts--;
|
|
736
|
+
}
|
|
737
|
+
// Log remaining unresolved links
|
|
738
|
+
if (hateoasContext.futureLinks.size > 0) {
|
|
739
|
+
const logger = new DefaultLogger('getJSONSchemaOptionsFromMultipleOpenAPIOptions');
|
|
740
|
+
logger.warn(`${hateoasContext.futureLinks.size} HATEOAS links could not be resolved after loading all schemas. This may indicate missing operations or circular dependencies.`);
|
|
741
|
+
}
|
|
742
|
+
return results;
|
|
743
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIV2, OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import type { Logger, MeshFetch } from '@graphql-mesh/types';
|
|
3
|
-
import type { JSONSchemaOperationConfig, OperationHeadersConfiguration } from '@omnigraph/json-schema';
|
|
3
|
+
import type { JSONSchemaHTTPJSONOperationConfig, JSONSchemaOperationConfig, JSONSchemaOperationResponseConfig, OperationHeadersConfiguration } from '@omnigraph/json-schema';
|
|
4
4
|
import type { SelectQueryOrMutationFieldConfig } from './types.cjs';
|
|
5
5
|
export interface HATEOASConfig {
|
|
6
6
|
/**
|
|
@@ -34,7 +34,19 @@ interface GetJSONSchemaOptionsFromOpenAPIOptionsParams {
|
|
|
34
34
|
jsonApi?: boolean;
|
|
35
35
|
HATEOAS?: Partial<HATEOASConfig> | boolean;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
type FutureLink = (name: string, oasDoc: OpenAPIV3.Document | OpenAPIV2.Document, methodObjFieldMap: MethodObjFieldMap) => boolean;
|
|
38
|
+
type MethodObjFieldMap = WeakMap<OpenAPIV2.OperationObject | OpenAPIV3.OperationObject, JSONSchemaHTTPJSONOperationConfig & {
|
|
39
|
+
responseByStatusCode: Record<string, JSONSchemaOperationResponseConfig>;
|
|
40
|
+
}>;
|
|
41
|
+
export interface HATEOASContext {
|
|
42
|
+
futureLinks: Set<FutureLink>;
|
|
43
|
+
loadedSchemas: Map<string, {
|
|
44
|
+
oasDoc: OpenAPIV3.Document | OpenAPIV2.Document;
|
|
45
|
+
methodObjFieldMap: MethodObjFieldMap;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export declare const futureLinks: Set<FutureLink>;
|
|
49
|
+
export declare function getJSONSchemaOptionsFromOpenAPIOptions(name: string, { source, fallbackFormat, cwd, fetch: fetchFn, endpoint, schemaHeaders, operationHeaders, queryParams, selectQueryOrMutationField, logger, jsonApi, HATEOAS, }: GetJSONSchemaOptionsFromOpenAPIOptionsParams, hateoasContext?: HATEOASContext): Promise<{
|
|
38
50
|
operations: JSONSchemaOperationConfig[];
|
|
39
51
|
endpoint: string;
|
|
40
52
|
cwd: string;
|
|
@@ -42,4 +54,16 @@ export declare function getJSONSchemaOptionsFromOpenAPIOptions(name: string, { s
|
|
|
42
54
|
schemaHeaders: Record<string, string>;
|
|
43
55
|
operationHeaders: OperationHeadersConfiguration;
|
|
44
56
|
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Loads multiple OpenAPI schemas with proper HATEOAS cross-reference resolution.
|
|
59
|
+
* This function ensures that schemas referencing operations from other schemas
|
|
60
|
+
* are resolved correctly regardless of loading order.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getJSONSchemaOptionsFromMultipleOpenAPIOptions(schemas: Array<{
|
|
63
|
+
name: string;
|
|
64
|
+
options: GetJSONSchemaOptionsFromOpenAPIOptionsParams;
|
|
65
|
+
}>): Promise<Array<{
|
|
66
|
+
name: string;
|
|
67
|
+
result: Awaited<ReturnType<typeof getJSONSchemaOptionsFromOpenAPIOptions>>;
|
|
68
|
+
}>>;
|
|
45
69
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIV2, OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import type { Logger, MeshFetch } from '@graphql-mesh/types';
|
|
3
|
-
import type { JSONSchemaOperationConfig, OperationHeadersConfiguration } from '@omnigraph/json-schema';
|
|
3
|
+
import type { JSONSchemaHTTPJSONOperationConfig, JSONSchemaOperationConfig, JSONSchemaOperationResponseConfig, OperationHeadersConfiguration } from '@omnigraph/json-schema';
|
|
4
4
|
import type { SelectQueryOrMutationFieldConfig } from './types.js';
|
|
5
5
|
export interface HATEOASConfig {
|
|
6
6
|
/**
|
|
@@ -34,7 +34,19 @@ interface GetJSONSchemaOptionsFromOpenAPIOptionsParams {
|
|
|
34
34
|
jsonApi?: boolean;
|
|
35
35
|
HATEOAS?: Partial<HATEOASConfig> | boolean;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
type FutureLink = (name: string, oasDoc: OpenAPIV3.Document | OpenAPIV2.Document, methodObjFieldMap: MethodObjFieldMap) => boolean;
|
|
38
|
+
type MethodObjFieldMap = WeakMap<OpenAPIV2.OperationObject | OpenAPIV3.OperationObject, JSONSchemaHTTPJSONOperationConfig & {
|
|
39
|
+
responseByStatusCode: Record<string, JSONSchemaOperationResponseConfig>;
|
|
40
|
+
}>;
|
|
41
|
+
export interface HATEOASContext {
|
|
42
|
+
futureLinks: Set<FutureLink>;
|
|
43
|
+
loadedSchemas: Map<string, {
|
|
44
|
+
oasDoc: OpenAPIV3.Document | OpenAPIV2.Document;
|
|
45
|
+
methodObjFieldMap: MethodObjFieldMap;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export declare const futureLinks: Set<FutureLink>;
|
|
49
|
+
export declare function getJSONSchemaOptionsFromOpenAPIOptions(name: string, { source, fallbackFormat, cwd, fetch: fetchFn, endpoint, schemaHeaders, operationHeaders, queryParams, selectQueryOrMutationField, logger, jsonApi, HATEOAS, }: GetJSONSchemaOptionsFromOpenAPIOptionsParams, hateoasContext?: HATEOASContext): Promise<{
|
|
38
50
|
operations: JSONSchemaOperationConfig[];
|
|
39
51
|
endpoint: string;
|
|
40
52
|
cwd: string;
|
|
@@ -42,4 +54,16 @@ export declare function getJSONSchemaOptionsFromOpenAPIOptions(name: string, { s
|
|
|
42
54
|
schemaHeaders: Record<string, string>;
|
|
43
55
|
operationHeaders: OperationHeadersConfiguration;
|
|
44
56
|
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Loads multiple OpenAPI schemas with proper HATEOAS cross-reference resolution.
|
|
59
|
+
* This function ensures that schemas referencing operations from other schemas
|
|
60
|
+
* are resolved correctly regardless of loading order.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getJSONSchemaOptionsFromMultipleOpenAPIOptions(schemas: Array<{
|
|
63
|
+
name: string;
|
|
64
|
+
options: GetJSONSchemaOptionsFromOpenAPIOptionsParams;
|
|
65
|
+
}>): Promise<Array<{
|
|
66
|
+
name: string;
|
|
67
|
+
result: Awaited<ReturnType<typeof getJSONSchemaOptionsFromOpenAPIOptions>>;
|
|
68
|
+
}>>;
|
|
45
69
|
export {};
|