Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
38dc755
chore: add support for entity files node types and validation
kamil1094 Oct 20, 2025
85ce02d
chore: remove catalogEntity1 format
kamil1094 Oct 22, 2025
9ee2a9b
Merge branch 'main' into chore/entity-file-types-and-validation
kamil1094 Oct 22, 2025
513275c
Merge branch 'main' into chore/entity-file-types-and-validation
kamil1094 Oct 24, 2025
456b5cb
chore: update redocly/config
kamil1094 Oct 24, 2025
9379f7d
tests: update lint tests
kamil1094 Oct 24, 2025
20187e5
chore: remove unnecessary files
kamil1094 Oct 24, 2025
a071540
tests: update entity-yaml test imports
kamil1094 Oct 24, 2025
656df76
tests: revert snapshot
kamil1094 Oct 24, 2025
4333b1f
Merge branch 'main' into chore/entity-file-types-and-validation
kamil1094 Oct 28, 2025
39b1f48
tests: update entity-yaml test file
kamil1094 Oct 28, 2025
bcd91fb
chore: update entity-key-valid test
kamil1094 Oct 28, 2025
10ddef3
chore: apply review suggestions
kamil1094 Oct 29, 2025
ae71ae8
chore: apply review suggestions
kamil1094 Oct 29, 2025
8e247fc
Merge branch 'main' into chore/entity-file-types-and-validation
kamil1094 Oct 29, 2025
1640493
Merge branch 'main' into chore/entity-file-types-and-validation
kamil1094 Oct 29, 2025
09f88e3
chore: add fixme for entity lint methods
kamil1094 Oct 29, 2025
ddd8adb
Merge branch 'main' into chore/entity-file-types-and-validation
kamil1094 Oct 29, 2025
7244ff0
chore: apply review suggestions
kamil1094 Oct 29, 2025
1817ef1
chore: apply review suggestions
kamil1094 Oct 29, 2025
d475d60
tests: add outdent to entity-key-valid test file
kamil1094 Oct 29, 2025
7d7d681
chore: use document instead of whole config in lintEntityFile method
kamil1094 Oct 29, 2025
f4972a4
tests: remove unnecessary var
kamil1094 Oct 29, 2025
4b6116d
chore: add catalogEntity visitor types
kamil1094 Oct 29, 2025
830ee3c
chore: remove unnecessary imports/exports
kamil1094 Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/floppy-rules-like.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/openapi-core": patch
---

Updated @redocly/config to v0.36.2.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
],
"dependencies": {
"@redocly/ajv": "^8.11.2",
"@redocly/config": "^0.31.0",
"@redocly/config": "^0.36.2",
"ajv-formats": "^2.1.1",
"colorette": "^1.2.0",
"js-levenshtein": "^1.1.6",
Expand Down
71 changes: 71 additions & 0 deletions packages/core/src/__tests__/entity-yaml.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { describe, it, expect } from 'vitest';
import { createEntityTypes } from '../types/entity-yaml.js';
import { NormalizedNodeType, normalizeTypes, ResolveTypeFn } from '../types/index.js';
import { entityFileSchema, entityFileDefaultSchema } from '@redocly/config';
describe('entity-yaml', () => {
it('should create entity types with discriminator', () => {
const entityTypes = createEntityTypes(entityFileSchema, entityFileDefaultSchema);

expect(entityTypes).toHaveProperty('user');
expect(entityTypes).toHaveProperty('api-operation');
expect(entityTypes).toHaveProperty('data-schema');
expect(entityTypes).toHaveProperty('api-description');
expect(entityTypes).toHaveProperty('service');
expect(entityTypes).toHaveProperty('domain');
expect(entityTypes).toHaveProperty('team');
expect(entityTypes).toHaveProperty('EntityFileDefault');
expect(entityTypes).toHaveProperty('EntityFileArray');
});

it('should resolve entity type to default for array items', () => {
const entityTypes = createEntityTypes(entityFileSchema, entityFileDefaultSchema);
const normalizedTypes = normalizeTypes(entityTypes);

const entityFileArrayNode = normalizedTypes['EntityFileArray'];

const unknownEntity = { key: 'unknown', title: 'Unknown' };
const resolvedType = (entityFileArrayNode.items as ResolveTypeFn)(
unknownEntity,
'root'
) as NormalizedNodeType;

expect(resolvedType).toBeTruthy();
expect(resolvedType.name).toBe('EntityFileDefault');
});

it('should resolve entity type based on discriminator for array items', () => {
const entityTypes = createEntityTypes(entityFileSchema, entityFileDefaultSchema);
const normalizedTypes = normalizeTypes(entityTypes);

const entityFileArrayNode = normalizedTypes['EntityFileArray'];
const userEntity = {
type: 'user',
key: 'john-doe',
title: 'John Doe',
metadata: { email: 'john@example.com' },
};
const resolvedType = (entityFileArrayNode.items as ResolveTypeFn)(
userEntity,
'root'
) as NormalizedNodeType;

expect(resolvedType).toBeTruthy();
expect(resolvedType.name).toBe('user');
expect(resolvedType.properties).toHaveProperty('metadata');
});

it('should have correct required fields for entity types', () => {
const entityTypes = createEntityTypes(entityFileSchema, entityFileDefaultSchema);
const normalizedTypes = normalizeTypes(entityTypes);

const userNode = normalizedTypes['user'];
expect(userNode.required).toContain('key');
expect(userNode.required).toContain('title');
expect(userNode.required).toContain('type');

const defaultNode = normalizedTypes['EntityFileDefault'];
expect(defaultNode.required).toContain('type');
expect(defaultNode.required).toContain('key');
expect(defaultNode.required).toContain('title');
});
});
Loading
Loading