Skip to content

Parser API should expose functions for traversing through schemasΒ #166

@derberg

Description

@derberg

Reason/Context

Traversing through JSON schemas with nested structure is not an easy task and requires a good knowledge of JSON Schema. The parser should make it easy especially that it already has a needed logic for anonymous id's assignment to messages and schemas, or detection of circular references.

Description

  • expose something like this on the API level asyncapi.traverseSchemas(callback, schemaType)
    • schemaType would by default traverse all schemas, but you could specify that you for example only want payload schemas or only parameters schemas
    • callback would be a function that you can pass into the traverse, that will be invoked on each schema found during
      the traverse
  • would be great if the callback execution result could be returned by the function
  • refactor existing logic for traversing schemas. We cannot just expose 1:1 what we have. Current traversing logic cares directly for circular refs detection and marking schemas as circular during parsing. Would be good to not just repeat everything again when traversing through the document after it is parsed
  • this is where the current traversing logic is located

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions