Skip to content

Feature: Support for recursive $ref #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

milux
Copy link

@milux milux commented Aug 21, 2024

This PR implements parsing and codegen for recursive $refs.
It requires pwall567/json-kotlin-schema#20 or another patched version of json-kotlin-schema that properly creates cyclic schema objects.

The cycle detection strategy is not very pretty, yet effective.
I tried to implement it as efficiently as possible. Each affected function call along the tracked call chains will have one more reference parameter. Apart from the check for the existence of an element in the call chain, which naturally is O(n) with n being the depth of the relevant call stack, the add/removeLast ops are all O(1).
Using HashSets/HashMaps may further improve performance for deep call stacks due to all ops being O(1) there, but due to higher costs of each operation I considered simple (Array)Lists the better option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant