Skip to content

Commit e5e4222

Browse files
committed
fix: fix $ref resolution for metadata-schema
1 parent fa48180 commit e5e4222

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

packages/core/src/config/__tests__/config-resolvers.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,4 +634,33 @@ describe('resolveApis', () => {
634634
});
635635
expect(resolvedConfig.plugins).toEqual(['test-plugin', 'fixtures/plugin.cjs']);
636636
});
637+
638+
it('should work with nested schema', async () => {
639+
const { resolvedConfig } = await resolveConfig({
640+
rawConfigDocument: makeDocument(
641+
{
642+
rules: {
643+
'metadata-schema': {
644+
type: 'object',
645+
properties: {
646+
'service-domain': {
647+
$ref: 'sd.yaml',
648+
},
649+
},
650+
},
651+
},
652+
},
653+
configPath
654+
),
655+
});
656+
expect(resolvedConfig?.rules?.['metadata-schema']).toEqual({
657+
type: 'object',
658+
properties: {
659+
'service-domain': {
660+
type: 'string',
661+
enum: ['api', 'data'],
662+
},
663+
},
664+
});
665+
});
637666
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
type: string
2+
enum:
3+
- 'api'
4+
- 'data'

packages/core/src/types/redocly-yaml.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'node:path';
22
import { rootRedoclyConfigSchema } from '@redocly/config';
3-
import { listOf } from './index.js';
3+
import { listOf, mapOf } from './index.js';
44
import { specVersions, getTypes } from '../oas-types.js';
55
import { isCustomRuleId, omit } from '../utils.js';
66
import { getNodeTypesFromJSONSchema } from './json-schema-adapter.js';
@@ -317,7 +317,9 @@ const ObjectRule: NodeType = {
317317

318318
// TODO: add better type tree for this
319319
const Schema: NodeType = {
320-
properties: {},
320+
properties: {
321+
properties: mapOf('Schema'),
322+
},
321323
additionalProperties: {},
322324
};
323325

0 commit comments

Comments
 (0)