Skip to content

Commit 0e395f6

Browse files
committed
Fixing Gateway api publish
1 parent 017ed42 commit 0e395f6

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

src/lib/resource-path.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ import { ResourceDescriptor } from '../models/types.js';
1010
import { RESOURCE_TYPE_METADATA, ResourceType } from '../models/resource-types.js';
1111

1212
/**
13-
* Association resource types that represent parent-child relationships
14-
* (not independently publishable resources).
15-
* These are handled specially during publishing via association files
16-
* (apis.json, groups.json) and should not be discovered as individual resources.
13+
* Association resource types that are published by specialized parent publishers.
14+
*
15+
* Product associations are handled by product-publisher using the parent
16+
* product descriptor, so their association files should not be discovered as
17+
* independent resources.
18+
*
19+
* Gateway associations are intentionally excluded from this set because they
20+
* are published via the generic association path in resource-publisher and
21+
* must therefore be discovered from gateways/{gateway}/apis.json.
1722
*/
18-
const ASSOCIATION_TYPES = new Set<ResourceType>([
23+
const PARENT_PUBLISHED_ASSOCIATION_TYPES = new Set<ResourceType>([
1924
ResourceType.ProductApi,
2025
ResourceType.ProductGroup,
2126
ResourceType.ProductTag,
22-
ResourceType.GatewayApi,
2327
]);
2428

2529
const SUPPORTED_SPECIFICATION_EXTENSIONS = new Set([
@@ -384,8 +388,8 @@ export function parseArtifactPath(
384388

385389
// Skip association resource types — these are handled specially during publishing
386390
// via their parent's association files (apis.json, groups.json)
387-
if (ASSOCIATION_TYPES.has(type)) {
388-
return undefined;
391+
if (PARENT_PUBLISHED_ASSOCIATION_TYPES.has(type)) {
392+
continue;
389393
}
390394

391395
const nameParts = parseTemplatePath(

tests/unit/lib/resource-path.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,20 @@ describe('parseArtifactPath', () => {
285285
expect(result!.nameParts[0]).toBe('starter');
286286
});
287287

288+
it('should parse GatewayApi association file so gateway API links can be published', () => {
289+
const filePath = path.join(baseDir, 'gateways', 'gw1', 'apis.json');
290+
const result = parseArtifactPath(baseDir, filePath);
291+
expect(result).toBeDefined();
292+
expect(result!.type).toBe(ResourceType.GatewayApi);
293+
expect(result!.nameParts).toEqual(['gw1']);
294+
});
295+
296+
it('should ignore ProductApi association files because product publisher handles them', () => {
297+
const filePath = path.join(baseDir, 'products', 'starter', 'apis.json');
298+
const result = parseArtifactPath(baseDir, filePath);
299+
expect(result).toBeUndefined();
300+
});
301+
288302
it('should parse workspace-scoped resource', () => {
289303
const filePath = path.join(baseDir, 'workspaces', 'ws1', 'apis', 'ws-api', 'apiInformation.json');
290304
const result = parseArtifactPath(baseDir, filePath);

0 commit comments

Comments
 (0)