Skip to content

[Bug]: SpecificationHelpers.retrieveParsedSpec accepts ambiguous input shapes leading to unpredictable behavior #1226

@SHUBHANSHU602

Description

@SHUBHANSHU602

Description

SpecificationHelpers.retrieveParsedSpec accepts multiple unrelated input shapes:

AsyncAPIDocument instance
stringified parsed spec
parsed plain JS object
legacy object exposing .json() method

This behavior is validated in tests but introduces ambiguity and weakens API guarantees.
Invalid or partially parsed inputs may be silently accepted, leading to unpredictable runtime behavior.
From a testing perspective, this masks incorrect usage instead of surfacing errors.

Image

Expected Behavior

The helper should accept explicit and well-defined input types
Legacy or ambiguous input paths should:
be rejected, or
emit warnings, or
be explicitly deprecated
Tests should fail for unsupported or unclear input shapes

Steps to Reproduce

Open specification.test.ts
Call retrieveParsedSpec with:
a plain object marked with x-parser-spec-parsed
a legacy object exposing .json()

Observe that the function returns a parsed document without validating input origin or structure

File Affected:-asyncapi-react/library/src/helpers/tests/specification.test.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions