express-openapi-validator
express-openapi-validator copied to clipboard
feat: support cyclical schema references
Is your feature request related to a problem? Please describe.
Yes, I have a schema that has cyclical references and because of this two things are happening with the current version:
- The serialization used to generate the cache keys crashes (easy to solve if you pass in the right parameter to the underlying library to not choke on cycles)
- Bigger problem:
json-schema-traverseonly supports cyclical references in the schema if they are unresolved (e.g. left as $ref) => https://github.com/epoberezkin/json-schema-traverse/issues/43
Describe the solution you'd like
Support cyclical references either by
- using a different library for traversal that does not choke on cyclical JS object references
- (big) refactoring of this lib so that it doesn't resolve $refs prior to traversal
- (small) refactoring of this lib so that it detects cycles and breaks them somehow (multiple ideas but I'm not a 100% sure of either of them being robust because I'm not that familiar with the rest of the codebase of
express-openapi-validator)
Describe alternatives you've considered
- Eliminate cycles from the API schema. No go unfortunately.
Additional context
https://github.com/hyperledger/cactus/blob/main/packages/cactus-plugin-ledger-connector-corda/src/main/json/openapi.json#L180
You can see that the JvmType and the JvmObject schema components are referencing each other, but one of the references is optional so an infinite loop is not a problem with regards the reference chain.